예제 #1
0
        public void Map_type_should_return_a_null_element_for_null_dynamic_object_enumerable_element()
        {
            var dynamicObjects = new DynamicObject[]
            {
                new DynamicObject(new CustomClass()),
                null,
                new DynamicObject(new CustomClass()),
            };

            var result = new DynamicObjectMapper().Map(dynamicObjects, typeof(CustomClass)).Cast <object>();

            result.ShouldNotBeNull();
            result.Count().ShouldBe(3);
            result.ElementAt(0).ShouldNotBeNull();
            result.ElementAt(1).ShouldBeNull();
            result.ElementAt(2).ShouldNotBeNull();
        }
예제 #2
0
        public void Map_should_be_null_for_null_object_enumerable()
        {
            var objects = new object[]
            {
                new CustomClass(),
                null,
                new CustomClass(),
            };

            var result = new DynamicObjectMapper().MapCollection(objects);

            result.ShouldNotBeNull();
            result.Count().ShouldBe(3);
            result.ElementAt(0).ShouldBeOfType <DynamicObject>();
            result.ElementAt(1).ShouldBeNull();
            result.ElementAt(2).ShouldBeOfType <DynamicObject>();
        }