public void Value_Editor_Can_Convert_Decimal_To_Decimal_Clr_Type() { DataValueEditor valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.Decimal); Attempt <object> result = valueEditor.TryConvertValueToCrlType(12.34d); Assert.IsTrue(result.Success); Assert.AreEqual(12.34d, result.Result); }
public void Value_Editor_Can_Convert_To_Decimal_Clr_Type_With_Empty_String() { var valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.Decimal); var result = valueEditor.TryConvertValueToCrlType(string.Empty); Assert.IsTrue(result.Success); Assert.IsNull(result.Result); }
public void Value_Editor_Can_Convert_To_Date_Clr_Type() { var valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.Date); var result = valueEditor.TryConvertValueToCrlType("2010-02-05"); Assert.IsTrue(result.Success); Assert.AreEqual(new DateTime(2010, 2, 5), result.Result); }
[TestCase("DATETIME", "", null)] // test empty string for date public void Value_Editor_Can_Convert_To_Clr_Type(string valueType, string val, object expected) { var valueEditor = MockedValueEditors.CreateDataValueEditor(valueType); var result = valueEditor.TryConvertValueToCrlType(val); Assert.IsTrue(result.Success); Assert.AreEqual(expected, result.Result); }
public void Value_Editor_Can_Convert_To_Decimal_Clr_Type_With_Other_Separator() { var valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.Decimal); var result = valueEditor.TryConvertValueToCrlType("12,34"); Assert.IsTrue(result.Success); Assert.AreEqual(12.34M, result.Result); }
public void Value_Editor_Can_Convert_To_Json_Object_For_Editor(string value, bool isOk) { var prop = new Property(1, new PropertyType(Mock.Of <IShortStringHelper>(), "test", ValueStorageType.Nvarchar)); prop.SetValue(value); var valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.String); var result = valueEditor.ToEditor(prop); Assert.AreEqual(isOk, !(result is string)); }
public void Value_Editor_Can_Serialize_Decimal_Value_With_Empty_String() { var valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.Decimal); var prop = new Property(1, new PropertyType(Mock.Of <IShortStringHelper>(), "test", ValueStorageType.Decimal)); prop.SetValue(string.Empty); var result = valueEditor.ToEditor(prop); Assert.AreEqual(string.Empty, result); }
[TestCase(ValueTypes.DateTime, "", "")] // test empty string for date public void Value_Editor_Can_Serialize_Value(string valueType, object val, string expected) { var prop = new Property(1, new PropertyType(Mock.Of <IShortStringHelper>(), "test", ValueStorageType.Nvarchar)); prop.SetValue(val); var valueEditor = MockedValueEditors.CreateDataValueEditor(valueType); var result = valueEditor.ToEditor(prop); Assert.AreEqual(expected, result); }
public void Value_Editor_Can_Serialize_Date_Value() { var now = DateTime.Now; var valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.Date); var prop = new Property(1, new PropertyType(Mock.Of <IShortStringHelper>(), "test", ValueStorageType.Date)); prop.SetValue(now); var result = valueEditor.ToEditor(prop); Assert.AreEqual(now.ToIsoString(), result); }
public void Value_Editor_Can_Serialize_Decimal_Value() { decimal value = 12.34M; DataValueEditor valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.Decimal); var prop = new Property(1, new PropertyType(Mock.Of <IShortStringHelper>(), "test", ValueStorageType.Decimal)); prop.SetValue(value); object result = valueEditor.ToEditor(prop); Assert.AreEqual("12.34", result); }