Exemple #1
0
        public void Map_MapperTarget_MapsCorrectly()
        {
            string expectedName = "Test Name";
            int expectedCode = 412;

            var a = new TestClassA {Code = expectedCode, Name = expectedName};
            var d = new TestClassD();

            var target = new AttributeMapper<TestClassA, TestClassD>();
            target.Map(a, d);

            Assert.AreEqual(expectedName, d.SomeOtherName);
            Assert.AreEqual(expectedCode, d.AnotherCode);

            Assert.AreEqual(expectedName, a.Name);
            Assert.AreEqual(expectedCode, a.Code);
        }
        public void Map_MapperTarget_MapsCorrectly()
        {
            string expectedName = "Test Name";
            int    expectedCode = 412;

            var a = new TestClassA {
                Code = expectedCode, Name = expectedName
            };
            var d = new TestClassD();

            var target = new AttributeMapper <TestClassA, TestClassD>();

            target.Map(a, d);

            Assert.AreEqual(expectedName, d.SomeOtherName);
            Assert.AreEqual(expectedCode, d.AnotherCode);

            Assert.AreEqual(expectedName, a.Name);
            Assert.AreEqual(expectedCode, a.Code);
        }
Exemple #3
0
        public void Map_MappedSource_SkipsMapping()
        {
            string expectedName = "Test Name";
            int expectedCode = 412;

            var a = new TestClassA();
            var d = new TestClassD {AnotherCode = expectedCode, SomeOtherName = expectedName};

            var target = new AttributeMapper<TestClassD, TestClassA>();
            target.Map(d, a);

            Assert.AreEqual(expectedName, d.SomeOtherName);
            Assert.AreEqual(expectedCode, d.AnotherCode);

            Assert.AreEqual(expectedName, a.Name);

            // since the mapping direction for AnotherCode is "TargetMemberName" only,
            // a.Code should be left with its default sourceValue.
            Assert.AreEqual(0, a.Code);
        }
        public void Map_MappedSource_SkipsMapping()
        {
            string expectedName = "Test Name";
            int    expectedCode = 412;

            var a = new TestClassA();
            var d = new TestClassD {
                AnotherCode = expectedCode, SomeOtherName = expectedName
            };

            var target = new AttributeMapper <TestClassD, TestClassA>();

            target.Map(d, a);

            Assert.AreEqual(expectedName, d.SomeOtherName);
            Assert.AreEqual(expectedCode, d.AnotherCode);

            Assert.AreEqual(expectedName, a.Name);

            // since the mapping direction for AnotherCode is "TargetMemberName" only,
            // a.Code should be left with its default sourceValue.
            Assert.AreEqual(0, a.Code);
        }