コード例 #1
0
        public void TestTryAssignPropertiesReverse()
        {
            var testOutput = new TestDtoLikeType();

            var testInput = new Entity
            {
                Address = new Address {
                    City = "Bikini Bottom", Line1 = "123 Anchor Way", CountryCode = "US", Id = 41255
                },
                Name = new PersonName {
                    First = "Eugene", Last = "Krabs"
                },
                Gender  = Gender.Male,
                Contact = new Contact {
                    Email = "*****@*****.**"
                },
                Id = 0
            };
            var testResult = NfMapper.TryAssignProperties(testInput, testOutput);

            Console.WriteLine(testResult);

            foreach (var l in NfMapper.GetAssignPropertiesData())
            {
                Console.WriteLine(l);
            }
        }
コード例 #2
0
        public void TestTryAssignPropertiesWithNulls()
        {
            var testInput  = new TestDtoLikeType();
            var testOutput = new Entity();

            var testResult = NfMapper.TryAssignProperties(testInput, testOutput);

            Assert.AreNotEqual(0, testResult);
            Console.WriteLine(testResult);
            foreach (var l in NfMapper.GetAssignPropertiesData())
            {
                Console.WriteLine(l);
            }
        }
コード例 #3
0
        public void TestTryAssignProperties()
        {
            var testInput = new TestDtoLikeType
            {
                FirstName   = "Eugene",
                LastName    = "Krabs",
                Line1       = "123 Anchor Way",
                City        = "Bikini Bottom",
                CountryCode = "US",
                Gender      = Gender.Male,
                Email       = "*****@*****.**",
                EntityId    = 789456,
                AddressId   = "41255"
            };

            var testOutput = new Entity();
            var testResult = NfMapper.TryAssignValueTypeProperties(testInput, testOutput, null);

            Console.WriteLine(testResult);

            Assert.IsNotNull(testOutput.Gender);

            //test top-level properties are being copied over
            Assert.AreEqual(Gender.Male, testOutput.Gender);
            Assert.AreEqual(789456, testOutput.Id);

            //test child types are being both instantiated and having properties assigned
            Assert.IsNotNull(testOutput.Name);
            Assert.AreEqual("Eugene", testOutput.Name.First);
            Assert.AreEqual("Krabs", testOutput.Name.Last);

            Assert.IsNotNull(testOutput.Address);
            Assert.AreEqual("123 Anchor Way", testOutput.Address.Line1);
            Assert.AreEqual("Bikini Bottom", testOutput.Address.City);
            Assert.AreEqual("US", testOutput.Address.CountryCode);
            Assert.AreEqual(41255, testOutput.Address.Id);

            Assert.IsNotNull(testOutput.Contact);
            Assert.AreEqual("*****@*****.**", testOutput.Contact.Email);

            foreach (var l in NfMapper.GetAssignPropertiesData("\t"))
            {
                Console.WriteLine(l);
            }
        }