[TestCase("DATETIME", "", null)] // test empty string for date
        public void Value_Editor_Can_Convert_To_Clr_Type(string valueType, string val, object expected)
        {
            DataValueEditor valueEditor = MockedValueEditors.CreateDataValueEditor(valueType);

            Attempt <object> result = valueEditor.TryConvertValueToCrlType(val);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(expected, 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);

            DataValueEditor valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.String);

            object result = valueEditor.ToEditor(prop);

            Assert.AreEqual(isOk, !(result is string));
        }
        public void Value_Editor_Can_Serialize_Decimal_Value_With_Empty_String()
        {
            DataValueEditor valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.Decimal);

            var prop = new Property(1, new PropertyType(Mock.Of <IShortStringHelper>(), "test", ValueStorageType.Decimal));

            prop.SetValue(string.Empty);

            object 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);

            DataValueEditor valueEditor = MockedValueEditors.CreateDataValueEditor(valueType);

            object result = valueEditor.ToEditor(prop);

            Assert.AreEqual(expected, result);
        }
示例#5
0
        public void Value_Editor_Can_Convert_Decimal_To_Decimal_Clr_Type()
        {
            var valueEditor = new DataValueEditor
            {
                ValueType = ValueTypes.Decimal
            };

            var result = valueEditor.TryConvertValueToCrlType(12.34d);

            Assert.IsTrue(result.Success);
            Assert.AreEqual(12.34d, result.Result);
        }
        public void Value_Editor_Can_Serialize_Date_Value()
        {
            DateTime        now         = DateTime.Now;
            DataValueEditor valueEditor = MockedValueEditors.CreateDataValueEditor(ValueTypes.Date);

            var prop = new Property(1, new PropertyType(Mock.Of <IShortStringHelper>(), "test", ValueStorageType.Date));

            prop.SetValue(now);

            object 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);
        }