public void ShouldCallTheUserConverterToConvertTableWithTableAndMultilineArgAndParameter()
        {
            StepExecutionTestsBindingsForTableArgumentConvert bindingInstance;
            TestRunner testRunner = GetTestRunnerWithConverterStub(out bindingInstance);

            Table  table         = new Table("h1");
            string argumentValue = "argument";
            var    user          = new User();

            // return false unless its a User
            // must also stub CanConvert & Convert for the string argument as we've introduced a parameter
            StepArgumentTypeConverterStub.Stub(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter(table, typeof(User))).Return(true);
            StepArgumentTypeConverterStub.Stub(c => c.CanConvert(null, null, null)).IgnoreArguments().Return(false);
            StepArgumentTypeConverterStub.Stub(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter(table, typeof(User))).Return(user);

            var multiLineArg = "multi-line arg";

            bindingInstance.Expect(b => b.ParameterMultilineArgumentAndTable(argumentValue, multiLineArg, user));
            MockRepository.ReplayAll();

            testRunner.Given("sample step for argument convert with parameter, multiline argument and table: argument", multiLineArg, table);

            Assert.AreEqual(ScenarioExecutionStatus.OK, GetLastTestStatus());
            MockRepository.VerifyAll();
        }
Exemple #2
0
        public void ShouldCallTheOnlyThatCanConvertWithTable()
        {
            Table table = new Table("h1");

            // return false unless its a Double or table->table
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter("argument", typeof(double))).Returns(true);
            //StepArgumentTypeConverterStub.Setup(c => c.CanConvert(It.IsAny<object>(), It.IsAny<IBindingType>(), It.IsAny<CultureInfo>())).Returns(false);

            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter(table, typeof(Table))).Returns(table);
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter("argument", typeof(double))).Returns(1.23);


            var(testRunner, bindingMock) = GetTestRunnerWithConverterStub <StepExecutionTestsBindingsForArgumentConvert>();


            //bindingInstance.Expect(b => b.DoubleArgWithTable(1.23, table));

            //MockRepository.ReplayAll();

            testRunner.Given("sample step for argument convert with table: argument", null, table);


            GetLastTestStatus().Should().Be(ScenarioExecutionStatus.OK, ContextManagerStub.ScenarioContext.TestError?.ToString());
            bindingMock.Verify(x => x.DoubleArgWithTable(1.23, table));
        }
        public void ShouldCallTheUserConverterToConvertTableWithTableAndMultilineArgAndParameter()
        {
            var(testRunner, bindingMock) = GetTestRunnerWithConverterStub <StepExecutionTestsBindingsForTableArgumentConvert>();

            Table  table         = new Table("h1");
            string argumentValue = "argument";
            var    user          = new User();
            var    multiLineArg  = "multi-line arg";

            // return false unless its a User
            // must also stub CanConvert & Convert for the string argument as we've introduced a parameter
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter(table, typeof(User))).Returns(true);
            StepArgumentTypeConverterStub.Setup(c => c.CanConvert(It.IsAny <object>(), It.IsAny <IBindingType>(), It.IsAny <CultureInfo>())).Returns(false);
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter(table, typeof(User))).Returns(user);
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter(argumentValue, typeof(string))).Returns(argumentValue);
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter(multiLineArg, typeof(string))).Returns(multiLineArg);


            //bindingInstance.Expect(b => b.ParameterMultilineArgumentAndTable(argumentValue, multiLineArg, user));
            //MockRepository.ReplayAll();

            testRunner.Given("sample step for argument convert with parameter, multiline argument and table: argument", multiLineArg, table);

            GetLastTestStatus().Should().Be(ScenarioExecutionStatus.OK);
            bindingMock.Verify(x => x.ParameterMultilineArgumentAndTable(argumentValue, multiLineArg, user));
        }
Exemple #4
0
        public void ShouldRaiseAmbiguousIfMultipleCanConvert()
        {
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter("argument", typeof(double))).Returns(true);
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter("argument", typeof(int))).Returns(true);
            StepArgumentTypeConverterStub.Setup(c => c.CanConvert(It.IsAny <object>(), It.IsAny <IBindingType>(), It.IsAny <CultureInfo>())).Returns(false);

            var(testRunner, bindingMock) = GetTestRunnerWithConverterStub <StepExecutionTestsBindingsForArgumentConvert>();

            // return false unless its a Double or an Int

            //MockRepository.ReplayAll();

            testRunner.Given("sample step for argument convert: argument");


            GetLastTestStatus().Should().Be(ScenarioExecutionStatus.BindingError, ContextManagerStub.ScenarioContext.TestError?.ToString());
        }
        public void ShouldRaiseAmbiguousIfMultipleCanConvert()
        {
            StepExecutionTestsBindingsForArgumentConvert bindingInstance;
            TestRunner testRunner = GetTestRunnerWithConverterStub(out bindingInstance);

            // return false unless its a Double or an Int
            StepArgumentTypeConverterStub.Stub(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter("argument", typeof(double))).Return(true);
            StepArgumentTypeConverterStub.Stub(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter("argument", typeof(int))).Return(true);
            StepArgumentTypeConverterStub.Stub(c => c.CanConvert(null, null, null)).IgnoreArguments().Return(false);

            MockRepository.ReplayAll();

            testRunner.Given("sample step for argument convert: argument");


            Assert.AreEqual(TestStatus.BindingError, GetLastTestStatus());
            MockRepository.VerifyAll();
        }
        public void ShouldCallTheUserConverterToConvertTableWithTable()
        {
            var(testRunner, bindingMock) = GetTestRunnerWithConverterStub <StepExecutionTestsBindingsForTableArgumentConvert>();

            Table table = new Table("h1");
            var   user  = new User();

            // return false unless its a User
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter(table, typeof(User))).Returns(true);
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter(table, typeof(User))).Returns(user);

            //bindingInstance.Expect(b => b.SingleTable(user));
            //MockRepository.ReplayAll();

            testRunner.Given("sample step for argument convert with table", null, table);

            GetLastTestStatus().Should().Be(ScenarioExecutionStatus.OK);
            bindingMock.Verify(x => x.SingleTable(user));
        }
        public void ShouldCallTheOnlyThatCanConvert()
        {
            StepExecutionTestsBindingsForArgumentConvert bindingInstance;
            TestRunner testRunner = GetTestRunnerWithConverterStub(out bindingInstance);

            // return false unless its a Double
            StepArgumentTypeConverterStub.Stub(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter("argument", typeof(double))).Return(true);
            StepArgumentTypeConverterStub.Stub(c => c.CanConvert(null, null, null)).IgnoreArguments().Return(false);

            StepArgumentTypeConverterStub.Expect(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter("argument", typeof(double))).Return(1.23);
            bindingInstance.Expect(b => b.DoubleArg(1.23));

            MockRepository.ReplayAll();

            testRunner.Given("sample step for argument convert: argument");


            Assert.AreEqual(TestStatus.OK, GetLastTestStatus());
            MockRepository.VerifyAll();
        }
        public void ShouldCallTheUserConverterToConvertTableWithTable()
        {
            StepExecutionTestsBindingsForTableArgumentConvert bindingInstance;
            TestRunner testRunner = GetTestRunnerWithConverterStub(out bindingInstance);

            Table table = new Table("h1");
            var   user  = new User();

            // return false unless its a User
            StepArgumentTypeConverterStub.Stub(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter(table, typeof(User))).Return(true);
            StepArgumentTypeConverterStub.Stub(c => c.CanConvert(null, null, null)).IgnoreArguments().Return(false);
            StepArgumentTypeConverterStub.Stub(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter(table, typeof(User))).Return(user);

            bindingInstance.Expect(b => b.SingleTable(user));
            MockRepository.ReplayAll();

            testRunner.Given("sample step for argument convert with table", null, table);

            Assert.AreEqual(ScenarioExecutionStatus.OK, GetLastTestStatus());
            MockRepository.VerifyAll();
        }
Exemple #9
0
        public async Task ShouldCallTheOnlyThatCanConvert()
        {
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter("argument", typeof(double))).Returns(true);
            //StepArgumentTypeConverterStub.Setup(c => c.CanConvert(It.IsAny<object>(), It.IsAny<IBindingType>(), It.IsAny<CultureInfo>())).Returns(false);
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter("argument", typeof(double))).ReturnsAsync(1.23);

            var(testRunner, bindingMock) = GetTestRunnerWithConverterStub <StepExecutionTestsBindingsForArgumentConvert>();



            //bindingInstance.Expect(b => b.DoubleArg(1.23));

            //MockRepository.ReplayAll();

            await testRunner.GivenAsync("sample step for argument convert: argument");


            GetLastTestStatus().Should().Be(ScenarioExecutionStatus.OK, ContextManagerStub.ScenarioContext.TestError?.ToString());
            bindingMock.Verify(x => x.DoubleArg(1.23));
            //StepArgumentTypeConverterStub.Verify(c => c.Convert("argument", It.Is<IBindingType>(bt => bt.TypeEquals(typeof(double))), It.IsAny<CultureInfo>())).; LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter("argument", typeof(double))).Return(1.23);
        }
Exemple #10
0
        public async Task ShouldCallTheUserConverterToConvertTableWithTableAndMultilineArg()
        {
            var(testRunner, bindingMock) = GetTestRunnerWithConverterStub <StepExecutionTestsBindingsForTableArgumentConvert>();

            Table table        = new Table("h1");
            var   user         = new User();
            var   multiLineArg = "multi-line arg";

            // return false unless its a User
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetCanConvertMethodFilter(table, typeof(User))).Returns(true);
            StepArgumentTypeConverterStub.Setup(c => c.CanConvert(It.IsAny <object>(), It.IsAny <IBindingType>(), It.IsAny <CultureInfo>())).Returns(false);
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter(multiLineArg, typeof(string))).ReturnsAsync(multiLineArg);
            StepArgumentTypeConverterStub.Setup(LegacyStepArgumentTypeConverterExtensions.GetConvertMethodFilter(table, typeof(User))).ReturnsAsync(user);



            //bindingInstance.Expect(b => b.MultilineArgumentAndTable(multiLineArg, user));
            //MockRepository.ReplayAll();

            await testRunner.GivenAsync("sample step for argument convert with multiline argument and table", multiLineArg, table);

            GetLastTestStatus().Should().Be(ScenarioExecutionStatus.OK);
            bindingMock.Verify(x => x.MultilineArgumentAndTable(multiLineArg, user));
        }