Пример #1
0
        public void CanMap1()
        {
            var from = new MapClass1
            {
                Prop1 = "Prop1",
                Prop2 = "Prop2",
                Prop3 = "Prop3"
            };

            from.Address.FirstName = "John";
            from.Address.LastName  = "Doe";
            from.Address.Age       = 24;

            var to = MiniMapper.Map <MapClass1, MapClass2>(from);

            Assert.AreEqual(from.Prop1, to.Prop1);
            Assert.AreEqual(from.Prop2, to.Prop2);
            Assert.AreEqual(from.Prop3, to.Prop3);

            var dict = to.Address;

            Assert.AreEqual(dict.Count, 3);
            Assert.AreEqual(dict["FirstName"], from.Address.FirstName);
            Assert.AreEqual(dict["LastName"], from.Address.LastName);
            Assert.AreEqual(dict["Age"], from.Address.Age);
        }
        public void CanMap1()
        {
            var from = new MapClass1
            {
                Prop1 = "Prop1",
                Prop2 = "Prop2",
                Prop3 = "Prop3",
                Prop4 = 99,
                Prop5 = new ConsoleKey[] { ConsoleKey.Backspace, ConsoleKey.Tab, ConsoleKey.Clear }
            };

            from.Address.FirstName = "John";
            from.Address.LastName  = "Doe";
            from.Address.Age       = 24;

            var to = MiniMapper.Map <MapClass1, MapClass2>(from);

            Assert.AreEqual(from.Prop1, to.Prop1);
            Assert.AreEqual(from.Prop2, to.Prop2);
            Assert.AreEqual(from.Prop3, to.Prop3);
            Assert.AreEqual(from.Prop4, to.Prop4);
            Assert.AreEqual(from.Prop5.Length, to.Prop5.Count);
            Assert.AreEqual((int)from.Prop5[0], to.Prop5[0]);
            Assert.AreEqual((int)from.Prop5[1], to.Prop5[1]);
            Assert.AreEqual((int)from.Prop5[2], to.Prop5[2]);

            var dict = to.Address;

            Assert.AreEqual(dict.Count, 3);
            Assert.AreEqual(dict["FirstName"], from.Address.FirstName);
            Assert.AreEqual(dict["LastName"], from.Address.LastName);
            Assert.AreEqual(dict["Age"], from.Address.Age);
        }