예제 #1
0
        public void StepArgumentTransformationShouldConvertNumberToBankAccount()
        {
            var stepTransformationBinding = stepTransformations.Single(x => x.Method.Name == "CreateBankAccount");

            var      invoker = new BindingInvoker(new RuntimeConfiguration(), new Mock <IErrorProvider>().Object);
            TimeSpan duration;
            var      result = invoker.InvokeBinding(stepTransformationBinding, contextManagerStub.Object, new object[] { 1234 }, new Mock <ITestTracer>().Object, out duration);

            Assert.NotNull(result);
            Assert.That(result.GetType(), Is.EqualTo(typeof(BankAccount)));
            Assert.That(((BankAccount)result).AccountNumber, Is.EqualTo(1234));
        }
        public void TypeToTypeConverterShouldConvertTableToTable()
        {
            TypeToTypeConverter stepTransformationInstance = new TypeToTypeConverter();
            var transformMethod           = stepTransformationInstance.GetType().GetMethod("TableToTableConvert");
            var stepTransformationBinding = CreateStepTransformationBinding(@"", transformMethod);

            var      invoker = new BindingInvoker(ConfigurationLoader.GetDefault(), new Mock <IErrorProvider>().Object);
            TimeSpan duration;
            var      result = invoker.InvokeBinding(stepTransformationBinding, contextManagerStub.Object, new object[] { new Table("h1") }, new Mock <ITestTracer>().Object, out duration);

            Assert.NotNull(result);
            Assert.That(result.GetType(), Is.EqualTo(typeof(Table)));
            Assert.That(((Table)result).Header, Is.EqualTo(new string[] { "transformed column", "h1" }));
        }
        public void TypeToTypeConverterShouldConvertStringToString()
        {
            TypeToTypeConverter stepTransformationInstance = new TypeToTypeConverter();
            var transformMethod           = stepTransformationInstance.GetType().GetMethod("StringToStringConvert");
            var stepTransformationBinding = CreateStepTransformationBinding(@"", transformMethod);

            var      invoker = new BindingInvoker(ConfigurationLoader.GetDefault(), new Mock <IErrorProvider>().Object);
            TimeSpan duration;
            var      result = invoker.InvokeBinding(stepTransformationBinding, contextManagerStub.Object, new object[] { "xyz" }, new Mock <ITestTracer>().Object, out duration);

            Assert.NotNull(result);
            Assert.That(result.GetType(), Is.EqualTo(typeof(string)));
            Assert.That(((string)result), Is.EqualTo("prefix xyz"));
        }
예제 #4
0
        public void StepArgumentTransformationShouldConvertStringToUser()
        {
            var stepTransformationBinding = stepTransformations.Single(x => x.Method.Name == "CreateUser");

            Assert.True(stepTransformationBinding.Regex.IsMatch("user xyz"));

            var      invoker = new BindingInvoker(new RuntimeConfiguration(), new Mock <IErrorProvider>().Object);
            TimeSpan duration;
            var      result = invoker.InvokeBinding(stepTransformationBinding, contextManagerStub.Object, new object[] { "xyz" }, new Mock <ITestTracer>().Object, out duration);

            Assert.NotNull(result);
            Assert.That(result.GetType(), Is.EqualTo(typeof(User)));
            Assert.That(((User)result).Name, Is.EqualTo("xyz"));
        }
        public void UserConverterShouldConvertStringToUser()
        {
            UserCreator stepTransformationInstance = new UserCreator();
            var         transformMethod            = stepTransformationInstance.GetType().GetMethod("Create");
            var         stepTransformationBinding  = CreateStepTransformationBinding(@"user (\w+)", transformMethod);

            Assert.True(stepTransformationBinding.Regex.IsMatch("user xyz"));

            var      invoker = new BindingInvoker(ConfigurationLoader.GetDefault(), new Mock <IErrorProvider>().Object);
            TimeSpan duration;
            var      result = invoker.InvokeBinding(stepTransformationBinding, contextManagerStub.Object, new object[] { "xyz" }, new Mock <ITestTracer>().Object, out duration);

            Assert.NotNull(result);
            Assert.That(result.GetType(), Is.EqualTo(typeof(User)));
            Assert.That(((User)result).Name, Is.EqualTo("xyz"));
        }
예제 #6
0
        public void TypeToTypeConverterShouldConvertStringToStringUsingRegex()
        {
            TypeToTypeConverter stepTransformationInstance = new TypeToTypeConverter();
            var transformMethod           = stepTransformationInstance.GetType().GetMethod("StringToStringConvertRegex");
            var stepTransformationBinding = CreateStepTransformationBinding(@"string (\w+)", transformMethod);

            Assert.True(stepTransformationBinding.Regex.IsMatch("string xyz"));

            var      invoker = new BindingInvoker(ConfigurationLoader.GetDefault(), new Mock <IErrorProvider>().Object, new SynchronousBindingDelegateInvoker());
            TimeSpan duration;
            var      result = invoker.InvokeBinding(stepTransformationBinding, contextManagerStub.Object, new object[] { "xyz" }, new Mock <ITestTracer>().Object, out duration);

            Assert.NotNull(result);
            result.GetType().Should().Be <string>();
            result.Should().Be("prefix xyz");
        }