Пример #1
0
 protected CompositeStep Given_are_settings_with_the_modification_KEY_VALUE(string key, string value)
 {
     return(CompositeStep.DefineNew()
            .AddSteps(_ => Given_are_the_standard_settings(),
                      _ => When_I_change_the_setting_to_the_value(key, value))
            .Build());
 }
Пример #2
0
 protected CompositeStep Given_are_settings_with_the_cleared_setting_KEY(string key)
 {
     return(CompositeStep.DefineNew()
            .AddSteps(_ => Given_are_the_standard_settings(),
                      _ => When_I_clear_the_setting(key))
            .Build());
 }
Пример #3
0
        public async Task It_should_allow_to_add_steps_to_composite()
        {
            var stepOne   = "Step one";
            var stepTwo   = "Step two";
            var stepThree = "Step three";
            var expected  = new[] { stepOne, stepTwo, stepThree };

            var context   = new MyContext();
            var composite = CompositeStep.DefineNew()
                            .WithContext(context)
                            .AddStep(stepOne, ctx => ctx.Executed.Add(stepOne))
                            .AddStep(stepTwo, ctx => ctx.Executed.Add(stepTwo))
                            .AddAsyncStep(stepThree, async ctx =>
            {
                await Task.Yield();
                ctx.Executed.Add(stepThree);
            })
                            .Build();

            var steps = composite.SubSteps.ToArray();

            Assert.That(steps.Select(x => x.RawName).ToArray(), Is.EqualTo(expected));

            foreach (var step in steps)
            {
                await step.StepInvocation.Invoke(context, null);
            }

            Assert.That(context.Executed, Is.EqualTo(expected));
        }
Пример #4
0
 protected CompositeStep Given_is_a_new_project_NAME(string name)
 {
     return(CompositeStep.DefineNew()
            .AddSteps(_ => When_I_create_a_new_project_with_name(name),
                      _ => Then_the_project_NAME_was_created(name))
            .Build());
 }
Пример #5
0
 protected CompositeStep Given_is_a_connected_client_with_wrong_handshake()
 {
     return(CompositeStep.DefineNew()
            .AddSteps(_ => Given_is_a_started_server(),
                      _ => When_I_connect_with_a_wrong_handshake())
            .Build());
 }
Пример #6
0
 private CompositeStep Then_it_should_divide_numbers()
 {
     return(CompositeStep.DefineNew().AddSteps(
                _ => Then_dividing_X_by_Y_should_give_RESULT(6, 3, 2),
                _ => Then_multiplying_X_by_Y_should_give_RESULT(5, 2, 2))
            .Build());
 }
Пример #7
0
 protected CompositeStep When_the_progress_is_started_and_reported_for_the_command(Progress progress, params string[] command)
 {
     return(CompositeStep.DefineNew()
            .AddSteps(_ => When_a_new_progress_with_the_maximum_is_started_for_the_command(progress.ProgressMaximum, command),
                      _ => When_the_progress_is_reported_for_the_command(progress, command))
            .Build());
 }
Пример #8
0
 private async Task <CompositeStep> Async_step_group()
 {
     return(CompositeStep.DefineNew()
            .AddAsyncSteps(
                Step_one_async,
                Step_two_async)
            .Build());
 }
Пример #9
0
 protected CompositeStep Given_is_a_started_server_with_heartbeat_enabled_and_valid_handshake()
 {
     return(CompositeStep.DefineNew()
            .AddSteps(_ => Given_is_a_started_server_with_heartbeat_enabled(),
                      _ => When_I_connect_with_a_valid_handshake(),
                      _ => Then_the_the_client_received_a_successful_handshake_reply())
            .Build());
 }
Пример #10
0
 /// <summary>
 /// This one, on the other hand uses basic syntax and uses synchronous sub-steps.
 /// </summary>
 private async Task <CompositeStep> When_customer_pays_for_products_in_basket()
 {
     return(CompositeStep.DefineNew()
            .AddSteps(
                When_customer_requests_to_pay,
                Then_payment_should_be_successful)
            .Build());
 }
Пример #11
0
        protected CompositeStep Given_is_a_different_library_builder_location()
        {
            string newLocation = ScenarioContext.ChangeLibraryBuilderLocation();

            return(CompositeStep.DefineNew()
                   .AddSteps(_ => Given_are_the_standard_settings(),
                             _ => When_I_change_the_setting_to_the_value("LibraryBuilderLocation", newLocation))
                   .Build());
        }
Пример #12
0
 protected virtual Task <CompositeStep> Given_host_configuration_is_applied()
 {
     return(Task.FromResult(
                CompositeStep
                .DefineNew()
                .WithContext(Context)
                .AddAsyncSteps(context => context.Given_a_new_host())
                .Build()));
 }
Пример #13
0
 /// <summary>
 /// This step shows that it is possible to create a contextual step, where context will be shared between all the sub-steps,
 /// and then use extended syntax to call some asynchronous sub-steps.
 /// </summary>
 private async Task <CompositeStep> Then_customer_should_receive_order_email()
 {
     return(CompositeStep.DefineNew()
            .WithContext <MailBox>()
            .AddAsyncSteps(
                x => x.Then_customer_should_receive_invoice(),
                x => x.Then_customer_should_receive_order_confirmation())
            .Build());
 }
Пример #14
0
 private CompositeStep Then_it_should_add_numbers()
 {
     StepExecution.Current.Comment("It is possible to add MultiAssertAttribute on composite step");
     return(CompositeStep.DefineNew().AddSteps(
                _ => Then_adding_X_to_Y_should_give_RESULT(2, 3, 5),
                _ => Then_adding_X_to_Y_should_give_RESULT(2, -3, -1),
                _ => Then_adding_X_to_Y_should_give_RESULT(0, 1, 0))
            .Build());
 }
Пример #15
0
 private async Task <CompositeStep> Given_an_existing_customer()
 {
     return(CompositeStep.DefineNew()
            .AddAsyncSteps(
                _ => Given_a_valid_CreateCustomerRequest(),
                _ => When_I_request_customer_creation(),
                _ => Then_the_response_should_have_status_code(HttpStatusCode.Created))
            .Build());
 }
Пример #16
0
 private CompositeStep Then_it_should_multiply_numbers()
 {
     StepExecution.Current.Comment("This step does not have MultiAssertAttribute so will stop on first exception");
     return(CompositeStep.DefineNew().AddSteps(
                _ => Then_multiplying_X_by_Y_should_give_RESULT(2, 3, 6),
                _ => Then_multiplying_X_by_Y_should_give_RESULT(2, -3, -6),
                _ => Then_multiplying_X_by_Y_should_give_RESULT(1, 1, 1))
            .Build());
 }
Пример #17
0
 /// <summary>
 /// Here, the composite is made of asynchronous steps that are called with extended syntax.
 /// </summary>
 private async Task <CompositeStep> When_customer_adds_products_to_basket()
 {
     return(CompositeStep.DefineNew()
            .AddAsyncSteps(
                _ => Given_product_is_in_stock("wooden desk"),
                _ => When_customer_adds_product_to_the_basket("wooden desk"),
                _ => Then_the_product_addition_should_be_successful())
            .Build());
 }
Пример #18
0
 protected override Task <CompositeStep> Given_host_configuration_is_applied()
 {
     return(Task.FromResult(
                CompositeStep
                .DefineNew()
                .WithContext(Context)
                .AddAsyncSteps(
                    _ => _.Given_a_new_host_with_custom_ComponentContainer(new NinjectComponentContainer(new StandardKernel())))
                .Build()));
 }
        public void It_should_defer_step_parsing_to_execution()
        {
            CompositeStep group = null;

            Assert.DoesNotThrow(() => group = new TestableCompositeStepBuilder()
                                              .AddAsyncSteps(_ => null as Task)
                                              .Build());

            Assert.That(group.SubSteps.Any(s => !s.IsValid), Is.True);
        }
Пример #20
0
        public void It_should_defer_step_parsing_to_execution()
        {
            CompositeStep group = null;

            Assert.DoesNotThrow(() => group = new TestableCompositeStepBuilder()
                                              .AddAsyncSteps(_ => null as Task)
                                              .Build());

            Assert.Throws <ArgumentException>(() => group.SubSteps.ToArray());
        }
Пример #21
0
 /// <summary>
 /// Finally, this composite uses basic syntax and synchronous steps.
 /// </summary>
 private async Task <CompositeStep> Given_customer_is_logged_in()
 {
     return(CompositeStep.DefineNew()
            .AddSteps(
                Given_the_user_is_about_to_login,
                Given_the_user_entered_valid_login,
                Given_the_user_entered_valid_password,
                When_the_user_clicks_login_button,
                Then_the_login_operation_should_be_successful)
            .Build());
 }
Пример #22
0
 protected override Task <CompositeStep> Given_host_configuration_is_applied()
 {
     return(Task.FromResult(
                CompositeStep
                .DefineNew()
                .WithContext(Context)
                .AddAsyncSteps(
                    _ => _.Given_a_new_host(),
                    _ => _.Given_EntityFrameworkCore_is_the_registered_repository())
                .Build()));
 }
Пример #23
0
 protected override Task <CompositeStep> Given_host_configuration_is_applied()
 {
     return(Task.FromResult(
                CompositeStep
                .DefineNew()
                .WithContext(Context)
                .AddAsyncSteps(
                    _ => _.Given_a_new_host(),
                    _ => _.Given_a_REstate_gRPC_Server_running(),
                    _ => _.Given_the_default_agent_is_gRPC_remote())
                .Build()));
 }
            public async void ThenTransmitMessageSucceeds()
            {
                // Arrange
                MessagingContext dummyMessage       = CreateDummyMessageWithAttachment();
                StepResult       expectedStepResult = StepResult.Success(dummyMessage);

                var compositeStep = new CompositeStep(CreateMockStepWith(expectedStepResult).Object);

                // Act
                StepResult actualStepResult = await compositeStep.ExecuteAsync(dummyMessage);

                // Assert
                Assert.Equal(expectedStepResult.MessagingContext, actualStepResult.MessagingContext);
            }
Пример #25
0
        private void AssertRegistration(Testable instance, CompositeStep step, bool shouldTakeOwnership)
        {
            var      container = new DependencyContainerConfiguration().DependencyContainer;
            Testable actual;

            using (var scope = container.BeginScope(step.SubStepsContext.ScopeConfigurator))
            {
                actual = (Testable)step.SubStepsContext.ContextResolver(scope);
                if (instance != null)
                {
                    Assert.That(actual, Is.SameAs(instance));
                }
            }
            Assert.That(actual.Disposed, Is.EqualTo(shouldTakeOwnership));
        }
            public async void ThenStepStopExecutionWithMarkedStepResult()
            {
                // Arrange
                MessagingContext expectedMessage     = CreateDummyMessageWithAttachment();
                StepResult       stopExecutionResult = StepResult.Success(expectedMessage).AndStopExecution();

                var spyStep       = new SpyStep();
                var compositeStep = new CompositeStep(CreateMockStepWith(stopExecutionResult).Object, spyStep);

                // Act
                StepResult actualResult = await compositeStep.ExecuteAsync(new EmptyMessagingContext());

                // Assert
                Assert.False(spyStep.IsCalled);
                Assert.Equal(expectedMessage, actualResult.MessagingContext);
            }
        private static object ResolveInstance(CompositeStep stepGroup)
        {
            var container = new DependencyContainerConfiguration().DependencyContainer.BeginScope(stepGroup.SubStepsContext.ScopeConfigurator);

            return(stepGroup.SubStepsContext.ContextResolver(container));
        }
Пример #28
0
 public ConditionalStep(Logic.Conditional ifConditional, CompositeStep thenStep, CompositeStep elseStep)
 {
     _if = ifConditional;
     _then = thenStep;
     _else = elseStep;
 }
Пример #29
0
 public Task(RadioModel model, CompositeStep step)
 {
     _model = model;
     _step  = step;
 }