Пример #1
0
        public void MatchingOrchestrator(string anarchyType)
        {
            //arrange
            var orchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                               .OrchestratorWithScheduleNamed("testAnarchyType").Build();
            var sut = new AnarchyManagerNew(new [] { orchestrator });


            //act
            sut.UpdateAction(anarchyType, FakeUpdatePayload);

            //assert
            orchestrator.Received(1).UpdateAction(FakeUpdatePayload);
        }
Пример #2
0
        public void SelectsFirstMatchingOrchestrator(string firstActionName, string secondActionName, int firstCount, int secondCount)
        {
            //arrange
            var orchestrator1 = Get.MotherFor
                                .MockAnarchyActionOrchestrator
                                .OrchestratorWithScheduleNamed(firstActionName).Build();
            var orchestrator2 = Get.MotherFor
                                .MockAnarchyActionOrchestrator
                                .OrchestratorWithScheduleNamed(secondActionName).Build();
            var sut = new AnarchyManagerNew(new [] { orchestrator1, orchestrator2 });

            //act
            sut.UpdateAction("firstActionName", FakeUpdatePayload);

            //assert
            orchestrator1.Received(firstCount).UpdateAction(FakeUpdatePayload);
            orchestrator2.Received(secondCount).UpdateAction(FakeUpdatePayload);
        }
Пример #3
0
        public void NoMatchingOrchestrator(string anarchyType)
        {
            //arrange
            var schedule     = new Schedule();
            var orchestrator = Substitute.For <IActionOrchestrator>();
            var action       = Substitute.For <ICauseAnarchy>();

            action.Name.Returns("testAnarchyType");
            orchestrator.AnarchyAction.Returns(action);
            var sut = new AnarchyManagerNew(new [] { orchestrator });

            //act
            var exception = Assert.Catch(() => sut.UpdateAction(anarchyType, FakeUpdatePayload));

            //assert
            exception.Should().BeOfType <AnarchyActionNotFoundException>();
            orchestrator.Received(0).UpdateAction(Arg.Any <string>());
        }