예제 #1
0
        public void TestCollectionGenericMethodMap()
        {
            var mapper = new ObjectMapper();
            var users  = new List <TestUserSrc>
            {
                new TestUserSrc {
                    Id = 1, Birthdate = new DateTime(2001, 1, 1), Name = "Test1"
                },
                new TestUserSrc {
                    Id = 2, Birthdate = new DateTime(2002, 2, 2), Name = "Test2"
                },
                new TestUserSrc {
                    Id = 3, Birthdate = new DateTime(2003, 3, 3), Name = "Test3"
                },
            };

            var strings = new List <string>
            {
                "Test_string_1",
                "Test_string_2",
                "Test_string_3"
            };

            var testCollectionSrc = new TestCollectionSrc
            {
                Users   = users,
                Strings = strings
            };

            var result = mapper.Map <TestCollectionDest>(testCollectionSrc);

            Assert.AreEqual(users, result.Users);
            Assert.AreEqual(strings, result.Strings);
        }
예제 #2
0
        public void TestCollectionMap()
        {
            var mapper = new ObjectMapper();
            var users  = new List <TestUserSrc>
            {
                new TestUserSrc {
                    Id = 1, Birthdate = new DateTime(2001, 1, 1), Name = "Test1"
                },
                new TestUserSrc {
                    Id = 2, Birthdate = new DateTime(2002, 2, 2), Name = "Test2"
                },
                new TestUserSrc {
                    Id = 3, Birthdate = new DateTime(2003, 3, 3), Name = "Test3"
                },
            };

            var strings = new List <string>
            {
                "Test_string_1",
                "Test_string_2",
                "Test_string_3"
            };

            var testCollectionSrc = new TestCollectionSrc
            {
                Users   = users,
                Strings = strings
            };

            var result = mapper.Map(testCollectionSrc, typeof(TestCollectionDest));

            Assert.IsInstanceOfType(result, typeof(TestCollectionDest));
            var instance = (TestCollectionDest)result;

            Assert.AreEqual(users, instance.Users);
            Assert.AreEqual(strings, instance.Strings);
        }