public void ConcreteResolver_CreateSutWithNoProps_ReturnsCreatedActor()
        {
            //arrange
            ConcreteResolver sut = CreateConcreteResolver(ImmutableDictionary <Type, Func <ActorBase> > .Empty);

            //act
            TestActorRef <BlackHoleActor> result = sut.CreateSut <BlackHoleActor>(ExpectedChildrenCount);

            //assert
            result.Should().BeSameAs(CreatedActorNoProps);
        }
        public void ConcreteResolver_CreateSutWithNullProps_ThrowsArgumentNullException()
        {
            //arrange
            ConcreteResolver sut = CreateConcreteResolver(ImmutableDictionary <Type, Func <ActorBase> > .Empty);

            //act
            Action act = () => sut.CreateSut <BlackHoleActor>(null, ExpectedChildrenCount);

            //assert
            act.ShouldThrow <ArgumentNullException>();
        }
        public void ConcreteResolver_TimesOutWhenChildrenCountIsTooHigh()
        {
            //arrange
            const int        childCount = 5;
            ConcreteResolver sut        = ConcreteResolverSettings
                                          .Empty
                                          .Register <EmptyChildActor>()
                                          .CreateResolver(this);

            //act
            Action act = () => sut.CreateSut <ParentActor>(Props.Create(() => new ParentActor(childCount)), childCount + 1);

            //assert
            act.ShouldThrow <TimeoutException>();
        }
        public void ConcreteResolver_TimesOutWithChildThatIsNotRegistered()
        {
            //arrange
            const int        childCount = 5;
            ConcreteResolver sut        = ConcreteResolverSettings
                                          .Empty
                                          .Register <EmptyChildActor>()
                                          .CreateResolver(this);

            //act
            Action act = () => sut.CreateSut <ParentActor>(Props.Create(() => new ParentActor(childCount)), childCount);

            //assert
            act.ShouldThrow <TimeoutException>(); //Invalid operation exception is swallowed by Akka
        }
        public void ConcreteResolver_CreatesChildrenWithoutDependancies()
        {
            //arrange
            const int        childCount = 5;
            ConcreteResolver sut        = ConcreteResolverSettings
                                          .Empty
                                          .Register <EmptyChildActor>()
                                          .Register <ChildActor>()
                                          .CreateResolver(this);

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

            //assert
            actor.Tell(new object());
            ExpectMsgAllOf(Enumerable.Repeat(ChildActor.Token, childCount).ToArray());
        }
Esempio n. 6
0
        public void ConcreteResolver_TimesoutWhenWaitingForChildrenWithAnExpectedChildCountThatIsTooHigh()
        {
            //arrange
            const int        initialChildCount = 2;
            const int        moreChildCount    = 5;
            ConcreteResolver sut = ConcreteResolverSettings
                                   .Empty
                                   .Register <EmptyChildActor>()
                                   .Register <ChildActor>()
                                   .CreateResolver(this);
            TestActorRef <ParentActor> actor = sut.CreateSut <ParentActor>(Props.Create(() => new ParentActor(initialChildCount)), initialChildCount);

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

            //assert
            act.ShouldThrow <TimeoutException>();
        }
Esempio n. 7
0
        public void ConcreteResolver_WaitsForChildrenCreatedWhenProcessingMessages()
        {
            //arrange
            const int        initialChildCount = 2;
            const int        moreChildCount    = 5;
            ConcreteResolver sut = ConcreteResolverSettings
                                   .Empty
                                   .Register <EmptyChildActor>()
                                   .Register <ChildActor>()
                                   .CreateResolver(this);
            TestActorRef <ParentActor> actor = sut.CreateSut <ParentActor>(Props.Create(() => new ParentActor(initialChildCount)), initialChildCount);

            //act
            sut.TellMessage(actor, moreChildCount, moreChildCount);

            //assert
            actor.Tell(new object());
            ExpectMsgAllOf(Enumerable.Repeat(ChildActor.Token, initialChildCount + moreChildCount).ToArray());
        }
        public void ConcreteResolver_CreatesChildrenWithDependancies()
        {
            //arrange
            const int          childCount             = 5;
            Mock <IDependancy> dependancyMock         = new Mock <IDependancy>();
            IDependancy        dependancyMockInstance = dependancyMock.Object;
            ConcreteResolver   sut = ConcreteResolverSettings
                                     .Empty
                                     .Register <EmptyChildActor>()
                                     .Register(() => new ChildActor(dependancyMockInstance))
                                     .CreateResolver(this);

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

            //assert
            actor.Tell(new object());
            AwaitAssert(() =>
                        dependancyMock.Verify(
                            dependancy => dependancy.SetResut(ChildActor.Token),
                            Times.Exactly(childCount)));
        }