Exemplo n.º 1
0
        public async Task 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, new BindingDelegateInvoker());

            var(result, _) = await invoker.InvokeBindingAsync(stepTransformationBinding, contextManagerStub.Object, new object[] { "xyz" }, new Mock <ITestTracer>().Object);

            Assert.NotNull(result);
            result.GetType().Should().Be <string>();
            result.Should().Be("prefix xyz");
        }
Exemplo n.º 2
0
        public async Task 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, new BindingDelegateInvoker());

            var(result, _) = await invoker.InvokeBindingAsync(stepTransformationBinding, contextManagerStub.Object, new object[] { new Table("h1") }, new Mock <ITestTracer>().Object);

            Assert.NotNull(result);

            result.GetType().Should().Be <Table>();
            ((Table)result).Header.Should().BeEquivalentTo(new string[] { "transformed column", "h1" });
        }
Exemplo n.º 3
0
        public async Task UserConverterShouldConvertStringToUser()
        {
            UserCreator stepTransformationInstance = new UserCreator();
            var         transformMethod            = stepTransformationInstance.GetType().GetMethod("Create");
            var         stepTransformationBinding  = CreateStepTransformationBinding(@"user (\w+)", transformMethod);

            stepTransformationBinding.Regex.IsMatch("user xyz").Should().BeTrue();

            var invoker = new BindingInvoker(ConfigurationLoader.GetDefault(), new Mock <IErrorProvider>().Object, new BindingDelegateInvoker());

            var(result, _) = await invoker.InvokeBindingAsync(stepTransformationBinding, contextManagerStub.Object, new object[] { "xyz" }, new Mock <ITestTracer>().Object);

            Assert.NotNull(result);
            result.Should().BeOfType <User>();
            ((User)result).Name.Should().Be("xyz");
        }