public override void Given()
        {
            var mockAction = Substitute.For <ICauseAnarchy, ICauseScheduledAnarchy>();

            mockAction.Name.Returns("testAction");

            _mockOrchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                                .OrchestratorWithoutScheduleNamed("testAction")
                                .WithIsActive(false)
                                .Build();

            _mockOrchestrator.AssociateSchedule(Arg.Any <Schedule>()).Returns(true);

            _schedule = new Schedule
            {
                Delay             = TimeSpan.FromDays(1),
                Interval          = TimeSpan.FromMilliseconds(2),
                IterationDuration = TimeSpan.FromMinutes(0),
                RepeatCount       = 4,
                TotalDuration     = TimeSpan.FromMinutes(1)
            };

            var factory = new CustomWebApplicationFactory(builder => builder.AddSingleton(_mockOrchestrator));

            _client = factory.CreateClient();
        }
Exemple #2
0
        public override void Given()
        {
            _passiveMockOrchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                                       .OrchestratorWithoutScheduleNamed("goingtodonothing")
                                       .WithAction(Get.CustomBuilderFor.MockAnarchyAction.WithCauseAnarchyType(CauseAnarchyType.Passive).Build())
                                       .ThatCanHandleRequestWith(async(context, next) =>
            {
                _passiveCalledAt = DateTime.Now;
                await Task.Delay(100);
            })
                                       .Build();

            _alterResponseMockOrchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                                             .OrchestratorWithoutScheduleNamed("teapot")
                                             .WithAction(Get.CustomBuilderFor.MockAnarchyAction.WithCauseAnarchyType(CauseAnarchyType.AlterResponse).Build())
                                             .ThatCanHandleRequestWith(async(context, next) =>
            {
                _alterResponseCalledAt      = DateTime.Now;
                context.Response.StatusCode = StatusCodes.Status418ImATeapot;
                await context.Response.WriteAsync("Im A Little Teapot Short and Stout...");
            })
                                             .Build();

            var factory = new CustomWebApplicationFactory(builder =>
            {
                builder.AddSingleton(_passiveMockOrchestrator);
                builder.AddSingleton(_alterResponseMockOrchestrator);
            });

            _client = factory.CreateClient();
        }
Exemple #3
0
        public override void Given()
        {
            _mockOrchestratorWithSchedule = Get.MotherFor.MockAnarchyActionOrchestrator
                                            .OrchestratorWithScheduleNamed("testAction1")
                                            .WithIsActive(false)
                                            .Build();

            _mockOrchestratorWithoutSchedule = Get.MotherFor.MockAnarchyActionOrchestrator
                                               .OrchestratorWithScheduleNamed("testAction2")
                                               .WithIsActive(false)
                                               .Build();

            _mockOrchestratorUnschedulable = Get.MotherFor.MockAnarchyActionOrchestrator
                                             .OrchestratorWithUnschedulableActionNamed("testAction3")
                                             .WithIsActive(false)
                                             .Build();

            var factory = new CustomWebApplicationFactory(builder =>
            {
                builder.AddSingleton(_mockOrchestratorWithSchedule);
                builder.AddSingleton(_mockOrchestratorWithoutSchedule);
                builder.AddSingleton(_mockOrchestratorUnschedulable);
            });

            _client = factory.CreateClient();
        }
Exemple #4
0
        public override void Given()
        {
            _mockOrchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                                .OrchestratorWithoutScheduleNamed("testAction")
                                .ThatCanHandleRequest()
                                .Build();

            var factory = new CustomWebApplicationFactory(builder => builder.AddSingleton(_mockOrchestrator));

            _client = factory.CreateClient();
        }
Exemple #5
0
        public override void Given()
        {
            _mockOrchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                                .OrchestratorWithoutScheduleNamed("goingtodonothing")
                                .WithAction(Get.CustomBuilderFor.MockAnarchyAction.WithCauseAnarchyType(CauseAnarchyType.Passive).Build())
                                .ThatCanHandleRequest()
                                .Build();

            var factory = new CustomWebApplicationFactory(builder => builder.AddSingleton(_mockOrchestrator));

            _client = factory.CreateClient();
        }
 private void StartIgnoringScheduleErrors(IActionOrchestrator orchestrator)
 {
     try
     {
         orchestrator.Start();
     }
     catch (ScheduleMissingException)
     {
         // Deliberately suppress this
         //TODO: Should we provide feedback in this instance or error here?
     }
 }
Exemple #7
0
        public override void Given()
        {
            _mockOrchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                                .OrchestratorWithoutScheduleNamed("teapot")
                                .WithAction(Get.CustomBuilderFor.MockAnarchyAction.WithCauseAnarchyType(CauseAnarchyType.AlterResponse).Build())
                                .ThatCanHandleRequestWith(async(context, next) =>
            {
                context.Response.StatusCode = StatusCodes.Status418ImATeapot;
                await context.Response.WriteAsync("Im A Little Teapot Short and Stout...");
            })
                                .Build();

            var factory = new CustomWebApplicationFactory(builder => builder.AddSingleton(_mockOrchestrator));

            _client = factory.CreateClient();
        }
        public override void Given()
        {
            _mockUnscheduledOrchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                                           .OrchestratorWithUnschedulableAction
                                           .Build();

            _mockScheduledOrchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                                         .OrchestratorWithScheduleNamed("test")
                                         .Build();

            var factory = new CustomWebApplicationFactory(builder =>
            {
                builder.AddSingleton(_mockUnscheduledOrchestrator);
                builder.AddSingleton(_mockScheduledOrchestrator);
            });

            _client = factory.CreateClient();
        }
        public override void Given()
        {
            _schedule = new Schedule
            {
                Delay             = TimeSpan.FromSeconds(1),
                Interval          = TimeSpan.FromSeconds(2),
                IterationDuration = TimeSpan.FromMinutes(1),
                RepeatCount       = 3,
                TotalDuration     = TimeSpan.FromDays(1)
            };

            _mockOrchestrator = Get.MotherFor.MockAnarchyActionOrchestrator
                                .OrchestratorWithScheduleNamed("testAction")
                                .WithIsActive(false)
                                .Build();

            _mockOrchestrator.ExecutionSchedule.Returns(_schedule).AndDoes(_ => _scheduleRetrieved = true);

            var factory = new CustomWebApplicationFactory(builder => builder.AddSingleton(_mockOrchestrator));

            _client = factory.CreateClient();
        }