Exemplo n.º 1
0
        public void ConvertWithNullableIntToNotNullableIntProperty()
        {
            CustomerNullableInt customer = new CustomerNullableInt
            {
                Address     = "Address1",
                City        = "City1",
                Name        = "Name1",
                State       = "State1",
                Telephone   = "Telephone1",
                TerritoryId = 0,
                ZipCode     = 12345
            };

            EntityConverter <CustomerNullableInt, ContactNotNullableInt> converter = new EntityConverter <CustomerNullableInt, ContactNotNullableInt>((cu, co) => co.Phone = cu.Telephone);
            ContactNotNullableInt contact = converter.Convert(customer);

            Assert.IsNotNull(contact);
        }
Exemplo n.º 2
0
        public void ConvertWithDefaultValueForToEntityProperty()
        {
            CustomerNullableInt customer = new CustomerNullableInt
            {
                Address     = "Address1",
                City        = "City1",
                Name        = "Name1",
                State       = null,
                Telephone   = "555-1212",
                TerritoryId = 0,
                ZipCode     = 12345
            };

            EntityConverter <CustomerNullableInt, ContactNullableInt> converter = new EntityConverter <CustomerNullableInt, ContactNullableInt>((cu, co) => co.Phone = cu.Telephone);
            ContactNullableInt contact = converter.Convert(customer);

            Assert.IsNotNull(contact);
            Assert.AreEqual("WA", contact.State);
        }