public async Task SetThreadUICultureToMatchFeatureCulture()
        {
            var scenarioStep = new GivenStep("Scenario step", DataTable.Empty, null);
            var testFeature  = new Feature("Feature", null,
                                           Background.Empty,
                                           new[]
            {
                new Scenario(
                    "Scenario",
                    new[] { scenarioStep },
                    1,
                    Enumerable.Empty <Tag>())
            },
                                           Enumerable.Empty <ScenarioOutline>(),
                                           Enumerable.Empty <Rule>(),
                                           new[] {
                new Tag("culture(nb-NO)")
            });

            var testData = new DiscoveredTestData(testAssembly, testFeature, null, testFeature.Scenarios.First());

            string capturedCultureName     = null;
            var    mockScenarioStepMapping = new Mock <IStepBinding>();

            mockStepBinder
            .Setup(m => m.GetBindingFor(scenarioStep, testAssembly))
            .Returns(mockScenarioStepMapping.Object)
            .Callback(() => capturedCultureName = CultureInfo.CurrentUICulture.Name);

            var testResult = await stepsExecutor.Execute(testCase, testData, testRunContext, mockLogger.Object);

            Assert.AreEqual("nb-NO", capturedCultureName);
        }
        public void IdentifyStepsNotMarkedAsMustNotEventuallyFail()
        {
            var step    = new GivenStep("a plain text match", null, null);
            var method  = typeof(StepBindingStaticSamples).GetMethod("GivenAPlainTextMatch");
            var binding = new StepBinding(step, method, Array.Empty <object>());

            Assert.IsFalse(binding.IsMarkedMustNotEventuallyFail);
        }
示例#3
0
        private async Task <TestResultMessage[]> PerformEventuallyConsistentScenarioTest(MethodInfo givenMethod, MethodInfo whenMethod, MethodInfo thenMethod)
        {
            var givenStep   = new GivenStep("Given", DataTable.Empty, null);
            var whenStep    = new WhenStep("When", DataTable.Empty, null);
            var thenStep    = new ThenStep("Then", DataTable.Empty, null);
            var testFeature = new Feature(
                "Feature",
                null,
                Background.Empty,
                new[]
            {
                new Scenario(
                    "Scenario",
                    new IStep[] { givenStep, whenStep, thenStep },
                    1,
                    new List <Tag> {
                    new Tag("eventuallyConsistent(retryInterval=00:00:01;within=00:00:05)")
                })
            },
                Enumerable.Empty <ScenarioOutline>(),
                Enumerable.Empty <Rule>(),
                Enumerable.Empty <Tag>());

            var testData         = new DiscoveredTestData(testAssembly, testFeature, null, testFeature.Scenarios.First());
            var givenStepBinding = new StepBinding(givenStep, givenMethod, Array.Empty <object>());
            var whenStepBinding  = new StepBinding(whenStep, whenMethod, Array.Empty <object>());
            var thenStepBinding  = new StepBinding(thenStep, thenMethod, Array.Empty <object>());

            mockStepBinder
            .Setup(m => m.GetBindingFor(givenStep, testAssembly))
            .Returns(givenStepBinding);

            mockStepBinder
            .Setup(m => m.GetBindingFor(whenStep, testAssembly))
            .Returns(whenStepBinding);

            mockStepBinder
            .Setup(m => m.GetBindingFor(thenStep, testAssembly))
            .Returns(thenStepBinding);

            var testResult = await stepsExecutor.Execute(testCase, testData, testRunContext, mockLogger.Object);

            return(testResult
                   .Messages
                   .Where(
                       message => message.Category == TestResultMessage.StandardOutCategory)
                   .ToArray());
        }
示例#4
0
        public async Task ExecuteFeatureBackgroundStepsThenScenarioSteps()
        {
            var backgroundStep = new GivenStep("Feature background step", DataTable.Empty, null);
            var scenarioStep   = new GivenStep("Scenario step", DataTable.Empty, null);

            var testFeature = new Feature("Feature", null,
                                          new Background(
                                              new[] { backgroundStep },
                                              0),
                                          new[]
            {
                new Scenario(
                    "Scenario",
                    new[] { scenarioStep },
                    1,
                    Enumerable.Empty <Tag>())
            },
                                          Enumerable.Empty <ScenarioOutline>(),
                                          Enumerable.Empty <Rule>(),
                                          Enumerable.Empty <Tag>());

            var testData = new DiscoveredTestData(testAssembly, testFeature, null, testFeature.Scenarios.First());

            var invocationOrder           = 0;
            var mockBackgroundStepMapping = new Mock <IStepBinding>();

            mockStepBinder
            .Setup(m => m.GetBindingFor(backgroundStep, testAssembly))
            .Returns(mockBackgroundStepMapping.Object)
            .Callback(() => Assert.AreEqual(0, invocationOrder++));

            var mockScenarioStepMapping = new Mock <IStepBinding>();

            mockStepBinder
            .Setup(m => m.GetBindingFor(scenarioStep, testAssembly))
            .Returns(mockScenarioStepMapping.Object)
            .Callback(() => Assert.AreEqual(1, invocationOrder++));

            var testResult = await stepsExecutor.Execute(testCase, testData, testRunContext, mockLogger.Object);

            mockBackgroundStepMapping.Verify(m => m.Execute(It.IsAny <IServiceProvider>(), It.IsAny <Collection <TestResultMessage> >()), Times.Once);
            mockScenarioStepMapping.Verify(m => m.Execute(It.IsAny <IServiceProvider>(), It.IsAny <Collection <TestResultMessage> >()), Times.Once);
        }
 protected static void I_have_a_given_condition()
 {
     given = new GivenStep(new Scenario(), dummy_step, StepPrefix.Given);
 }
 private IFixtureStepRunner RunnerOf(GivenStep step) => new GivenStepRunner(step);