public void TestProbeResolver_TellMessageFromSenderWithNullRecipientAndMessageAndSender_ThrowsArgumentNullException()
        {
            //arrange
            TestProbeResolver sut = CreateTestProbeResolver();

            //act
            Action act = () => sut.TellMessage <object>(null, null, null, ExpectedChildrenCount);

            //assert
            act.ShouldThrow <ArgumentNullException>();
        }
        public void TestProbeResolver_TellMessageSender_TellsChild()
        {
            //arrange
            TestProbeResolver sut = CreateTestProbeResolver();

            //act
            sut.TellMessage(Recipient, Message, Sender, ExpectedChildrenCount);

            //assert
            ChildTellerMock.Verify(
                teller => teller.TellMessage(ChildWaiterMock.Object, this, Recipient, Message, ExpectedChildrenCount, Sender),
                Times.Once);
        }
Пример #3
0
        public void TestProbeResolver_ThrownsWhenChildHasNotBeenResolved()
        {
            //arrange
            TestProbeResolver sut = TestProbeResolverSettings
                                    .Empty
                                    .CreateResolver(this);

            //act
            TestActorRef <ParentActor> actor = sut.CreateSut <ParentActor>(Props.Create(() => new ParentActor()), 0);

            sut.TellMessage(actor, new CreateChild(Guid.NewGuid().ToString(), typeof(EchoActor)), 1);
            Action act = () => sut.ResolvedTestProbe(actor, Guid.NewGuid().ToString());

            //assert
            act.ShouldThrow <ActorNotFoundException>();
        }
        public void TestProbeResolver_TimesoutWhenWaitingForChildrenWithAnExpectedChildCountThatIsTooHigh()
        {
            //arrange
            const int         initialChildCount = 2;
            const int         moreChildCount    = 5;
            Type              childType         = typeof(ReplyChildActor1);
            TestProbeResolver sut = TestProbeResolverSettings
                                    .Empty
                                    .CreateResolver(this);
            TestActorRef <ParentActor> actor = sut.CreateSut <ParentActor>(Props.Create(() => new ParentActor(childType, initialChildCount)), initialChildCount);

            //act
            Action act = () => sut.TellMessage(actor, new CreateChildren(childType, moreChildCount), moreChildCount + 1);

            //assert
            act.ShouldThrow <TimeoutException>();
        }
        public void TestProbeResolver_ResolvedTypesAreStored()
        {
            //arrange
            Type              childType = typeof(BlackHoleActor);
            string            childName = Guid.NewGuid().ToString();
            TestProbeResolver sut       = TestProbeResolverSettings
                                          .Empty
                                          .CreateResolver(this);

            //act
            TestActorRef <ParentActor> actor = sut.CreateSut <ParentActor>(Props.Create(() => new ParentActor()), 0);

            sut.TellMessage(actor, new CreateChild(childName, childType), 1);

            //assert
            sut.ResolvedType(actor, childName).Should().Be(childType);
        }
        public void TestProbeResolver_WaitsForChildrenCreatedWhenProcessingMessages()
        {
            //arrange
            const int         initialChildCount    = 2;
            const int         additionalChildCount = 5;
            Type              childType            = typeof(ReplyChildActor1);
            Guid              message = Guid.NewGuid();
            TestProbeResolver sut     = TestProbeResolverSettings
                                        .Empty
                                        .RegisterHandler <ReplyChildActor1, Guid>(guid => guid)
                                        .CreateResolver(this);
            TestActorRef <ParentActor> actor = sut.CreateSut <ParentActor>(Props.Create(() => new ParentActor(childType, initialChildCount)), initialChildCount);

            //act
            sut.TellMessage(actor, new CreateChildren(childType, additionalChildCount), additionalChildCount);

            //assert
            actor.Tell(new TellAllChildren(message));
            ExpectMsgAllOf(Enumerable
                           .Repeat(message, initialChildCount + additionalChildCount)
                           .ToArray());
        }