Beispiel #1
0
        public void ObjectMapper_Map_List_ReadonlyList()
        {
            var mapper = new ObjectMapper();

            var l1 = new VectorInfo();

            l1.ReadonlyVectors.Add(new Vector2()
            {
                X = 1, Y = 2
            });
            var l2 = mapper.Map(l1, new VectorInfo());

            Assert.AreEqual(1, l2.ReadonlyVectors[0].X);
        }
Beispiel #2
0
        public void ObjectMapConfig_Map_List_ReadonlyList()
        {
            var config = new ObjectMapConfig();

            var l1 = new VectorInfo();

            l1.ReadonlyVectors.Add(new Vector2()
            {
                X = 1, Y = 2
            });
            var l2 = config.Map(l1, new VectorInfo());

            Assert.AreEqual(1, l2.ReadonlyVectors[0].X);
        }
Beispiel #3
0
        public void ObjectMapper_Map_List_NullableValueTypeList()
        {
            var mapper = new ObjectMapper();

            var l1 = new VectorInfo();

            l1.Vectors.Add(new Vector2()
            {
                X = 1, Y = 2
            });
            var l2 = mapper.Map(l1, new VectorInfo1());

            Assert.AreEqual(1, l2.Vectors[0].Value.X);
        }
Beispiel #4
0
        public void ObjectMapper_Map_List_NullableValueTypeList_MappingRule()
        {
            var mapper = new ObjectMapper();

            mapper.CompilerConfig.PropertyMatchRule = (c1, p1, c2, p2) => p1.Name == p2.Name ||
                                                      (p1.Name == "Vectors" && p2.Name == "NullableVectors");

            var l1 = new VectorInfo();

            l1.Vectors.Add(new Vector2()
            {
                X = 1, Y = 2
            });
            var l2 = mapper.Map(l1, new VectorInfo());

            Assert.AreEqual(1, l2.NullableVectors[0].Value.X);
        }
Beispiel #5
0
        public void ObjectMapConfig_Map_List_NullableList()
        {
            var config = new ObjectMapConfig();

            config.PropertyMapRules.Clear();

            var rule = new PropertyNameMappingRule();

            rule.AddPropertyNameMap("Vectors", "NullableVectors");
            config.PropertyMapRules.Add(rule);

            var l1 = new VectorInfo();

            l1.Vectors.Add(new Vector2()
            {
                X = 1, Y = 2
            });
            var l2 = config.Map(l1, new VectorInfo());

            Assert.AreEqual(1, l2.NullableVectors[0].Value.X);
        }