コード例 #1
0
        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);
        }
コード例 #2
0
        public void UnitTestFramework_ResolvedTestProbe_ReturnsCorrectProbe()
        {
            //arrange
            UnitTestFramework <DummyActor> sut = CreateUnitTestFramework();

            //act
            TestProbe result = sut.ResolvedTestProbe(ChildName);

            //assert
            result.Should().BeSameAs(ResolvedTestProbe);
        }
コード例 #3
0
        public void UnitTestFramework_ResolvedTestProbeWithNullChildName_ThrowsArgumentNullException()
        {
            //arrange
            UnitTestFramework <DummyActor> sut = CreateUnitTestFramework();

            //act
            Action act = () => sut.ResolvedTestProbe(null);

            //assert
            act.ShouldThrow <ArgumentNullException>();
        }
コード例 #4
0
        public void SutActor_Constructor_SendsChildCorrectMessage()
        {
            //act
            UnitTestFramework <SutActor> framework = UnitTestFrameworkSettings
                                                     .Empty
                                                     .CreateFramework <SutActor>(this, 2);

            //assert
            framework
            .ResolvedTestProbe("child-actor-1")
            .ExpectMsg("hello actor 1");
        }
コード例 #5
0
        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(EchoActor)), 1);
            Action act = () => sut.ResolvedTestProbe(Guid.NewGuid().ToString());

            //assert
            act.ShouldThrow <ActorNotFoundException>();
        }
コード例 #6
0
        public void TestProbeResolver_ResolvedTestProbesAreStored()
        {
            //arrange
            Type   childType = typeof(BlackHoleActor);
            string childName = Guid.NewGuid().ToString();
            Guid   message   = Guid.NewGuid();
            UnitTestFramework <ParentActor> sut = UnitTestFrameworkSettings
                                                  .Empty
                                                  .CreateFramework <ParentActor>(this, Props.Create(() => new ParentActor()));

            //act
            sut.TellMessageAndWaitForChildren(new CreateChild(childName, childType), 1);
            TestProbe result = sut.ResolvedTestProbe(childName);

            //assert
            sut.Sut.Tell(new TellChild(childName, message));
            result.ExpectMsg(message);
        }