Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions tests/Proto.Actor.Tests/ProcessRegistryTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using Proto.TestFixtures;
using Xunit;
Expand Down Expand Up @@ -87,4 +88,50 @@ public async Task Given_PIDExistsInHostResolver_GetShouldReturnIt()

Assert.Same(p, p2);
}

[Fact]
public async Task Given_ProcessRegistry_NextIdShouldReturnSequentialIds()
{
var system = new ActorSystem();
await using var _ = system;
var reg = new ProcessRegistry(system);

var id1 = reg.NextId();
var id2 = reg.NextId();

Assert.Equal("$1", id1);
Assert.Equal("$2", id2);
}

[Fact]
public async Task Given_PIDs_FindShouldReturnMatchingPIDs()
{
var system = new ActorSystem();
await using var _ = system;
var reg = new ProcessRegistry(system);
var p1 = new TestProcess(system);
var p2 = new TestProcess(system);
var p3 = new TestProcess(system);
reg.TryAdd("alpha", p1);
reg.TryAdd("beta", p2);
reg.TryAdd("ALPHANUM", p3);

var results = reg.Find("Alp").ToList();

Assert.Equal(2, results.Count);
Assert.All(results, pid => Assert.Equal(system.Address, pid.Address));
Assert.Contains(results, pid => pid.Id == "alpha");
Assert.Contains(results, pid => pid.Id == "ALPHANUM");
}

[Fact]
public async Task Given_RemotePIDWithoutResolver_GetShouldThrow()
{
var system = new ActorSystem();
await using var _ = system;
var reg = new ProcessRegistry(system);
var pid = PID.FromAddress("remote", "123");

Assert.Throws<NotSupportedException>(() => reg.Get(pid));
}
}
Loading