Ejemplo n.º 1
0
        public void does_not_bind_when_concrete_enumerable_type_cannot_be_found()
        {
            IEnumerableValueBinder valueBinder    = new IEnumerableValueBinder(new Configuration());
            ITypeAccessor          typeAccessor   = TypeAccessorFactory.Create(typeof(Test));
            IMember            member             = typeAccessor.GetMembers().First();
            object             source             = new { };
            Test               target             = new Test();
            ValueBinderContext valueBinderContext = CreateContext(source, target);

            valueBinder.Bind(typeAccessor, member, valueBinderContext);

            typeAccessor.GetValue(target, member.Name).MustBeNull();
        }
Ejemplo n.º 2
0
        public void binds_to_array()
        {
            Configuration          configuration = new Configuration();
            IEnumerableValueBinder valueBinder   = new IEnumerableValueBinder(new Configuration());
            ITypeAccessor          typeAccessor  = TypeAccessorFactory.Create(typeof(TestWithArray));
            IMember member = typeAccessor.GetMembers().First();
            object  source = new
            {
                Foo = "a-foo-value"
            };
            TestWithArray      target             = new TestWithArray();
            ValueBinderContext valueBinderContext = new ValueBinderContext(source, target, A.Fake <TargetConfiguration>(), new DefaultValueProvider(), new ObjectMapper(configuration));

            valueBinder.Bind(typeAccessor, member, valueBinderContext);

            target.Tests[0].Foo.MustEqual("a-foo-value");
        }
Ejemplo n.º 3
0
        public void CanBind_returns_false_when_string()
        {
            IEnumerableValueBinder valueBinder = new IEnumerableValueBinder(new Configuration());

            valueBinder.CanBind(typeof(string)).MustBeFalse();
        }
Ejemplo n.º 4
0
        public void CanBind_returns_true_ienumerable()
        {
            IEnumerableValueBinder valueBinder = new IEnumerableValueBinder(new Configuration());

            valueBinder.CanBind(typeof(IEnumerable <DateTime>)).MustBeTrue();
        }