Ejemplo n.º 1
0
        public void DependencyResolverAdder_Add_LatestFactoryIsUsed()
        {
            //arrange
            DependencyResolverAdder sut = CreateDependencyResolverAdder();

            foreach (int _ in TestHelper.GenerateMany(TestHelper.GenerateNumber))
            {
                sut.Add(this, type => new Mock <ActorBase>().Object);
            }

            //act
            sut.Add(this, ActorFactory);

            //assert
            TestActorRef <ActorBase> result = ActorOfAsTestActorRef <ActorBase>(Sys.DI().Props <DummyActor>());

            result.UnderlyingActor.Should().BeSameAs(ReturnedActor);
        }
Ejemplo n.º 2
0
        public void DependencyResolverAdder_AddWithNullTestKitBaseAndActorFactory_ThrowsArgumentNullException()
        {
            //arrange
            DependencyResolverAdder sut = CreateDependencyResolverAdder();

            //act
            Action act = () => sut.Add(null, null);

            //assert
            act.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 3
0
        public void DependencyResolverAdder_AddWithNullTestKitBase_ThrowsArgumentNullException()
        {
            //arrange
            DependencyResolverAdder sut = CreateDependencyResolverAdder();

            //act
            Action act = () => sut.Add(null, type => new BlackHoleActor());

            //assert
            act.Should().Throw <ArgumentNullException>();
        }
Ejemplo n.º 4
0
        public void DependencyResolverAdder_Add_LatestFactoryIsUsed()
        {
            //arrange
            DependencyResolverAdder sut    = CreateDependencyResolverAdder();
            List <DummyActor>       actors = TestUtils.CreateMany <DummyActor>();

            foreach (DummyActor actor in actors.Take(actors.Count))
            {
                sut.Add(this, type => actor);
            }
            DummyActor expected = new DummyActor();

            //act
            sut.Add(this, type => expected);

            //assert
            TestActorRef <ActorBase> result = ActorOfAsTestActorRef <ActorBase>(Sys.DI().Props <DummyActor>());

            result.UnderlyingActor.Should().BeSameAs(expected);
        }
Ejemplo n.º 5
0
        public void DependencyResolverAdder_Add_FactoryIsGivenCorrectType()
        {
            //arrange
            DependencyResolverAdder sut = CreateDependencyResolverAdder();

            //act
            sut.Add(this, ActorFactory);

            //assert
            ActorOfAsTestActorRef <ActorBase>(Sys.DI().Props <DummyActor>());
            TypeGivenToFactory.Should().Be <DummyActor>();
        }
Ejemplo n.º 6
0
        public void DependencyResolverAdder_Add_ResultOfFactoryIsUsedToCreateActors()
        {
            //arrange
            DependencyResolverAdder sut = CreateDependencyResolverAdder();

            //act
            sut.Add(this, ActorFactory);

            //assert
            TestActorRef <ActorBase> result = ActorOfAsTestActorRef <ActorBase>(Sys.DI().Props <ActorBase>());

            result.UnderlyingActor.Should().BeSameAs(ReturnedActor);
        }
Ejemplo n.º 7
0
        public void DependencyResolverAdder_Add_FactoryIsGivenCorrectType()
        {
            //arrange
            DependencyResolverAdder sut = CreateDependencyResolverAdder();
            DummyActor actor            = new DummyActor();
            Type       actual           = null;

            //act
            sut.Add(this, type =>
            {
                actual = type;
                return(actor);
            });

            //assert
            ActorOfAsTestActorRef <ActorBase>(Sys.DI().Props <DummyActor>());
            actual.Should().Be <DummyActor>();
        }