public void TestAllFieldsGoBackToNull() { var dict = new System.Collections.Generic.Dictionary <string, object>(); dict.Add("NullableInt", 1); dict.Add("NullableBoolean", true); dict.Add("NullableDouble", (double)10); dict.Add("NullableByte", (byte)1); dict.Add("NullableShort", (short)1); dict.Add("NullableLong", (long)1); dict.Add("NullableSingle", (Single)1); dict.Add("NullableDecimal", (byte)1); dict.Add("NullableChar", (char)';'); dict.Add("NullableGuid", Guid.NewGuid()); dict.Add("NullableDateTime", DateTime.Now); bool passed = true; var obj = new NullableTestClass(); foreach (System.Collections.Generic.KeyValuePair <string, object> item in dict) { TestSetOfValue(item.Key, item.Value, obj); if (!TestSetOfValue(item.Key, null, obj)) { passed = false; } } Assert.IsTrue(passed); }
public void TestBooleanForNull() { var obj = new NullableTestClass(); obj.NullableBoolean = true; Assert.IsTrue(TestSetOfValue("NullableBoolean", null)); }
public void TestDoubleForNull() { var obj = new NullableTestClass(); obj.NullableDouble = 1; Assert.IsTrue(TestSetOfValue("NullableDouble", null)); }
public void TestIntForNull() { var obj = new NullableTestClass(); obj.NullableInt = 4; Assert.IsTrue(TestSetOfValue("NullableInt", null)); }
public static bool TestSetOfValue(string property, object value, NullableTestClass obj = null) { obj = obj ?? new NullableTestClass(); var setMethod = Compiler.SetMethod(obj); var getMethod = Compiler.GetMethod(obj); setMethod(obj, property, value); var currentValue = getMethod(obj, property); if(currentValue == null && value == null) { return true; } return currentValue.ToString() == value.ToString(); }
public static bool TestSetOfValue(string property, object value, NullableTestClass obj = null) { obj = obj ?? new NullableTestClass(); var setMethod = Compiler.SetMethod(obj); var getMethod = Compiler.GetMethod(obj); setMethod(obj, property, value); var currentValue = getMethod(obj, property); if (currentValue == null && value == null) { return(true); } return(currentValue.ToString() == value.ToString()); }
public void TestAllFields() { var dict = new System.Collections.Generic.Dictionary<string, object>(); dict.Add("NullableInt", 1); dict.Add("NullableBoolean", true); dict.Add("NullableDouble", (double)10); dict.Add("NullableByte", (byte)1); dict.Add("NullableShort", (short)1); dict.Add("NullableLong", (long)1); dict.Add("NullableSingle", (Single)1); dict.Add("NullableDecimal", (byte)1); dict.Add("NullableChar", (char)';'); dict.Add("NullableGuid", Guid.NewGuid()); dict.Add("NullableDateTime", DateTime.Now); bool passed = true; var obj = new NullableTestClass(); foreach (System.Collections.Generic.KeyValuePair<string, object> item in dict) { if (!TestSetOfValue(item.Key, item.Value, obj)) { passed = false; } } Assert.IsTrue(passed); }
public void TestIntForNull() { var obj = new NullableTestClass(); obj.NullableInt = 4; Assert.IsTrue(TestSetOfValue("NullableInt", null)); }
public void TestDoubleForNull() { var obj = new NullableTestClass(); obj.NullableDouble = 1; Assert.IsTrue(TestSetOfValue("NullableDouble", null)); }
public void TestBooleanForNull() { var obj = new NullableTestClass(); obj.NullableBoolean = true; Assert.IsTrue(TestSetOfValue("NullableBoolean", null)); }