예제 #1
0
        public void CanUseBuilderForMemberToMember()
        {
            var builder = new EvaluatorBuilder();

            builder
            .WithActivator(new ReflectionActivator())
            .Map <Foo, Bar>(m => true)
            .FromExpression(m => m.Message)
            .ToExpression(m => m.Content);

            var evaluator = builder.Build();

            var output = evaluator.Evaluate <Foo, Bar>(new Foo {
                Message = "Hello, world!"
            });

            Assert.IsNotNull(output);
            Assert.IsTrue(output.Content.Equals("Hello, world!", System.StringComparison.OrdinalIgnoreCase));
        }
예제 #2
0
        public void CanHandleConversionMemberToMember()
        {
            var builder = new EvaluatorBuilder();

            builder.WithActivator(new ReflectionActivator())
            .Map <Foo, BarInt>(m => true)
            .FromExpression(m => m.Message)
            .ToExpression(m => m.MessageCode, t => { t.AddConverter(new StringToIntConverter()); });

            var evaluator = builder.Build();

            var output = evaluator.Evaluate <Foo, BarInt>(
                new Foo
            {
                Message = "500"
            }
                );

            Assert.IsNotNull(output);
            Assert.IsTrue(output.MessageCode == 500);
        }