Пример #1
0
        public void ShouldNotThrowWithNullValuesNoPrefix()
        {
            collection[null] = null;

            var deserializer = new NameValueDeserializer();

            deserializer.Deserialize(collection, typeof(Customer));
        }
Пример #2
0
        public void NoRequestForPropertyShouldNotInstantiatePropertyNoPrefix()
        {
            collection["Id"]           = "20";
            collection["Phone.Number"] = "800-555-1212";

            var deserializer = new NameValueDeserializer();
            var emp          = deserializer.Deserialize <Employee>(collection, "emp");

            Assert.IsNotNull(emp, "Employee should not be null.");
            Assert.IsNotNull(emp.Phone, "Employee phone should not be null.");
            Assert.IsNull(emp.BatPhone, "Employee OtherPhones should be null because it was not in request parameters.");
        }
Пример #3
0
 internal static object Deserialize(this NameValueDeserializer nvd, NameValueCollection collection, Type targetType)
 {
     return(nvd.Deserialize(collection, null, targetType));
 }
Пример #4
0
 internal static T Deserialize <T>(this NameValueDeserializer nvd, NameValueCollection collection) where T : new()
 {
     return((T)nvd.Deserialize(collection, null, typeof(T)));
 }
Пример #5
0
 public void Setup()
 {
     collection = new NameValueCollection();
     nvd        = new NameValueDeserializer();
 }
        public void ShouldNotThrowWithNullValuesNoPrefix()
        {
            collection[null] = null;

            var deserializer = new NameValueDeserializer();

            deserializer.Deserialize(collection, typeof(Customer));
        }
 public void Setup()
 {
     collection = new NameValueCollection();
     nvd = new NameValueDeserializer();
 }
        public void NoRequestForPropertyShouldNotInstantiatePropertyNoPrefix()
        {
            collection["Id"] = "20";
            collection["Phone.Number"] = "800-555-1212";

            var deserializer = new NameValueDeserializer();
            var emp = deserializer.Deserialize<Employee>(collection, "emp");

            Assert.IsNotNull(emp, "Employee should not be null.");
            Assert.IsNotNull(emp.Phone, "Employee phone should not be null.");
            Assert.IsNull(emp.BatPhone, "Employee OtherPhones should be null because it was not in request parameters.");
        }