public void UnitTestFramework_ResolvedChildTestProbesHaveCorrectMessageHandlers() { //arrange const int initialChildCount = 0; const string createdChildName = "child-name"; Guid message = Guid.NewGuid(); Guid reply = Guid.NewGuid(); UnitTestFramework <ParentActor> sut = UnitTestFrameworkSettings .Empty .RegisterChildHandler <ReplyChildActor1, Guid>(mess => reply) .CreateFramework <ParentActor>( this, Props.Create(() => new ParentActor()), initialChildCount); sut.TellMessageAndWaitForChildren(new CreateChild(createdChildName, typeof(ReplyChildActor1)), 1); //act TestProbe childProbe = sut.ResolvedTestProbe(createdChildName); //assert childProbe.Ref.Tell(message); ExpectMsg(reply); }
public void UnitTestFramework_TellMessageAndWaitForChildrenNoSenderWithNullMessage_ThrowsArgumentNullException() { //arrange UnitTestFramework <DummyActor> sut = CreateUnitTestFramework(); //act Action act = () => sut.TellMessageAndWaitForChildren <object>( null, ExpectedChildCount); //assert act.Should().Throw <ArgumentNullException>(); }
public void TestProbeResolver_ThrownsWhenChildHasNotBeenResolved() { //arrange UnitTestFramework <ParentActor> sut = UnitTestFrameworkSettings .Empty .CreateFramework <ParentActor>(this, Props.Create(() => new ParentActor())); //act sut.TellMessageAndWaitForChildren(new CreateChild(Guid.NewGuid().ToString(), typeof(BlackHoleActor)), 1); Action act = () => sut.ResolvedType(Guid.NewGuid().ToString()); //assert act.ShouldThrow <ActorNotFoundException>(); }
public void TestProbeResolver_ResolvedTypesAreStored() { //arrange Type childType = typeof(BlackHoleActor); string childName = Guid.NewGuid().ToString(); UnitTestFramework <ParentActor> sut = UnitTestFrameworkSettings .Empty .CreateFramework <ParentActor>(this, Props.Create(() => new ParentActor())); //act sut.TellMessageAndWaitForChildren(new CreateChild(childName, childType), 1); //assert sut.ResolvedType(childName).Should().Be(childType); }
public void TestProbeResolver_TimesoutWhenWaitingForChildrenWithAnExpectedChildCountThatIsTooHigh() { //arrange const int initialChildCount = 2; const int moreChildCount = 5; Type childType = typeof(ReplyChildActor1); UnitTestFramework <ParentActor> sut = UnitTestFrameworkSettings .Empty .CreateFramework <ParentActor>(this, Props.Create(() => new ParentActor(childType, initialChildCount)), initialChildCount); //act Action act = () => sut.TellMessageAndWaitForChildren(new CreateChildren(childType, moreChildCount), moreChildCount + 1); //assert act.ShouldThrow <TimeoutException>(); }
public void UnitTestFramework_TellMessageAndWaitForChildren_InvokesTellWaiter() { //arrange UnitTestFramework <DummyActor> sut = CreateUnitTestFramework(); //act sut.TellMessageAndWaitForChildren(Message, ExpectedChildCount); //assert TellWaiterMock.Verify( teller => teller.TellMessage( ChildWaiter, this, SutActor, Message, ExpectedChildCount, null), Times.Once); }
public void TestProbeResolver_WaitsForChildrenCreatedWhenProcessingMessages() { //arrange const int initialChildCount = 2; const int additionalChildCount = 5; Type childType = typeof(ReplyChildActor1); Guid message = Guid.NewGuid(); UnitTestFramework <ParentActor> sut = UnitTestFrameworkSettings .Empty .RegisterHandler <ReplyChildActor1, Guid>(guid => guid) .CreateFramework <ParentActor>(this, Props.Create(() => new ParentActor(childType, initialChildCount)), initialChildCount); //act sut.TellMessageAndWaitForChildren(new CreateChildren(childType, additionalChildCount), additionalChildCount); //assert sut.Sut.Tell(new TellAllChildren(message)); ExpectMsgAllOf(Enumerable .Repeat(message, initialChildCount + additionalChildCount) .ToArray()); }