Beispiel #1
0
        public void UnitTestFramework_ResolvedSupervisorStratergyWithChildNameCreatedWithoutSupervisoryStratergy_OnlyCallsSupervisoryStratergyGetterOnce()
        {
            //arrange
            UnitTestFramework <DummyActor> sut = CreateUnitTestFramework();

            sut.ResolvedSupervisorStrategy(ChildNameWithoutSupervisor);

            //act
            sut.ResolvedSupervisorStrategy(ChildNameWithoutSupervisor);

            //assert
            SutSupervisorStrategyGetterMock.Verify(
                getter => getter.Get(It.IsAny <ActorBase>()),
                Times.Once);
        }
Beispiel #2
0
        public void UnitTestFramework_ResolvedSupervisorStratergyWithNullChildName_ThrowsArgumentNullException()
        {
            //arrange
            UnitTestFramework <DummyActor> sut = CreateUnitTestFramework();

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

            //assert
            act.Should().Throw <ArgumentNullException>();
        }
Beispiel #3
0
        public void UnitTestFramework_ResolvedSupervisorStratergyWithChildNameCreatedWithoutSupervisoryStratergy_ReturnsSutSupervisoryStratergy()
        {
            //arrange
            UnitTestFramework <DummyActor> sut = CreateUnitTestFramework();

            //act
            SupervisorStrategy result = sut.ResolvedSupervisorStrategy(ChildNameWithoutSupervisor);

            //assert
            result.Should().BeSameAs(SutSupervisorStrategy);
        }
Beispiel #4
0
        public void SutActor_Constructor_CreatesChild1WithOneForOneStrategy()
        {
            //act
            UnitTestFramework <SutActor> framework = UnitTestFrameworkSettings
                                                     .Empty
                                                     .CreateFramework <SutActor>(this, 2);

            //assert
            framework.ResolvedSupervisorStrategy("child-1")
            .Should().BeOfType <OneForOneStrategy>();
        }
Beispiel #5
0
        public void SutActor_Constructor_CreatesChild1WithCorrectDecider()
        {
            //act
            UnitTestFramework <SutActor> framework = UnitTestFrameworkSettings
                                                     .Empty
                                                     .CreateFramework <SutActor>(this, 2);

            //assert
            framework.ResolvedSupervisorStrategy("child-1")
            .As <OneForOneStrategy>().Decider.Decide(new Exception())
            .Should().Be(Directive.Stop);
        }
Beispiel #6
0
        public void SutActor_Constructor_CreatesChild1WithCorrectTimeout()
        {
            //act
            UnitTestFramework <SutActor> framework = UnitTestFrameworkSettings
                                                     .Empty
                                                     .CreateFramework <SutActor>(this, 2);

            //assert
            framework.ResolvedSupervisorStrategy("child-1")
            .As <OneForOneStrategy>().WithinTimeRangeMilliseconds
            .Should().Be(1000);
        }
Beispiel #7
0
        public void SutActor_Constructor_CreatesChild1WithCorrectMaxNumberOfRetries()
        {
            //act
            UnitTestFramework <SutActor> framework = UnitTestFrameworkSettings
                                                     .Empty
                                                     .CreateFramework <SutActor>(this, 2);

            //assert
            framework.ResolvedSupervisorStrategy("child-1")
            .As <OneForOneStrategy>().MaxNumberOfRetries
            .Should().Be(1);
        }
        public void UnitTestFramework_ResolvedSupervisorStrategiesAreStored()
        {
            //arrange
            SupervisorStrategy parentSupervisorStrategy = new AllForOneStrategy(exception => Directive.Restart);
            SupervisorStrategy childSupervisorStrategy  = new OneForOneStrategy(exception => Directive.Restart);
            UnitTestFramework <ParentActorWithSupervisorStratery> sut = UnitTestFrameworkSettings
                                                                        .Empty
                                                                        .CreateFramework <ParentActorWithSupervisorStratery>(this,
                                                                                                                             Props.Create(() =>
                                                                                                                                          new ParentActorWithSupervisorStratery(parentSupervisorStrategy, childSupervisorStrategy)), 2);

            //act
            SupervisorStrategy result = sut.ResolvedSupervisorStrategy("ChildWithParentSupervisorStrategy");

            //assert
            result.Should().BeSameAs(parentSupervisorStrategy);
        }
        public void UnitTestFramework_ThrownsWhenChildHasNotBeenResolved()
        {
            //arrange
            SupervisorStrategy parentSupervisorStrategy = new AllForOneStrategy(exception => Directive.Restart);
            SupervisorStrategy childSupervisorStrategy  = new OneForOneStrategy(exception => Directive.Restart);

            UnitTestFramework <ParentActorWithSupervisorStratery> sut = UnitTestFrameworkSettings
                                                                        .Empty
                                                                        .CreateFramework <ParentActorWithSupervisorStratery>(this,
                                                                                                                             Props.Create(() =>
                                                                                                                                          new ParentActorWithSupervisorStratery(parentSupervisorStrategy, childSupervisorStrategy)), 2);

            //act
            Action act = () => sut.ResolvedSupervisorStrategy(Guid.NewGuid().ToString());

            //assert
            act.ShouldThrow <ActorNotFoundException>();
        }
        public void UnitTestFramework_TheParentsSupervisorStrategyIsReturnedWhenTheChildDoesNotHaveOneSetInItsProps()
        {
            //arrange
            SupervisorStrategy parentSupervisorStrategy = new AllForOneStrategy(exception => Directive.Restart);
            SupervisorStrategy childSupervisorStrategy  = new OneForOneStrategy(exception => Directive.Restart);

            UnitTestFramework <ParentActorWithSupervisorStratery> sut = UnitTestFrameworkSettings
                                                                        .Empty
                                                                        .CreateFramework <ParentActorWithSupervisorStratery>(
                this,
                Props.Create(() => new ParentActorWithSupervisorStratery(parentSupervisorStrategy, childSupervisorStrategy)),
                2);

            //act
            SupervisorStrategy result = sut.ResolvedSupervisorStrategy("ChildWithChildSupervisorStrategy");

            //assert
            result.Should().BeSameAs(childSupervisorStrategy);
        }