public CustomPropertyCells(VASS.CellValue value, CustomPropertyType type)
        {
            var type_int = CustomPropertyTypeToInt(type);

            this.Value = value;
            this.Type  = type_int;
        }
Beispiel #2
0
        public void CellValueLiteral_Creation()
        {
            // unitialized means it has no value
            VASS.CellValue c0;
            Assert.IsNull(c0.Value);
            Assert.IsFalse(c0.HasValue);

            var c1 = new VASS.CellValue("FOO");

            Assert.AreEqual("FOO", c1.Value);
            Assert.IsTrue(c1.HasValue);

            var c2 = new VASS.CellValue(123.45);

            Assert.AreEqual("123.45", c2.Value);
            Assert.IsTrue(c2.HasValue);

            var c3 = new VASS.CellValue(12345);

            Assert.AreEqual("12345", c3.Value);
            Assert.IsTrue(c3.HasValue);

            var c4 = new VASS.CellValue(true);

            Assert.AreEqual("TRUE", c4.Value);
            Assert.IsTrue(c4.HasValue);

            var c5 = new VASS.CellValue(false);

            Assert.AreEqual("FALSE", c5.Value);
            Assert.IsTrue(c5.HasValue);
        }
        public CustomPropertyCells(System.DateTime value)
        {
            var    current_culture = System.Globalization.CultureInfo.InvariantCulture;
            string formatted_dt    = value.ToString(current_culture);
            string formatted_value = string.Format("DATETIME(\"{0}\")", formatted_dt);

            this.Value = formatted_value;
            this.Type  = CustomPropertyTypeToInt(CustomPropertyType.Date);
        }
        public void EncodeValues()
        {
            // only quote the value when it is a string (no type specified or type equals zero)
            bool quote = (this.Type.Value == null || this.Type.Value == "0");

            this.Value  = VASS.CellValue.EncodeValue(this.Value.Value, quote);
            this.Label  = VASS.CellValue.EncodeValue(this.Label.Value);
            this.Format = VASS.CellValue.EncodeValue(this.Format.Value);
            this.Prompt = VASS.CellValue.EncodeValue(this.Prompt.Value);
        }
Beispiel #5
0
        public void CellValueLiteral_Equivalence()
        {
            // uninitialized CVTs are equal
            VASS.CellValue c0;
            VASS.CellValue c1;

            Assert.AreEqual(c0, c1);

            // initialized CVTs set to null are equal
            var c2 = new VASS.CellValue(null);
            var c3 = new VASS.CellValue(null);

            Assert.AreEqual(c2, c3);

            // initialized CVTs set to empty strings are equal
            var c4 = new VASS.CellValue(string.Empty);
            var c5 = new VASS.CellValue("");

            Assert.AreEqual(c4, c5);

            // initialized CVTs set to the same strings are equal (when the strings aren't interned)
            var c6 = new VASS.CellValue("FOO");
            var c7 = new VASS.CellValue(string.Copy("FOO")); // string.Copy avoids string interning

            Assert.AreEqual(c6, c7);

            // initialized CVTs to different values are not considered equal
            var c8 = new VASS.CellValue("FOO");
            var c9 = new VASS.CellValue("BAR");

            Assert.AreNotEqual(c8, c9);

            var c10 = new VASS.CellValue(null);
            var c11 = new VASS.CellValue("BAR");

            Assert.AreNotEqual(c10, c11);
        }
 public void EncodeValues()
 {
     this.Value  = VASS.CellValue.EncodeValue(this.Value.Value);
     this.Prompt = VASS.CellValue.EncodeValue(this.Prompt.Value);
 }
 public static CustomPropertyCells Create(VASS.CellValue value, CustomPropertyType type)
 {
     return(new CustomPropertyCells(value.Value, type));
 }
 public CustomPropertyCells(VASS.CellValue value)
 {
     this.Value = value;
     this.Type  = CustomPropertyTypeToInt(CustomPropertyType.String);
 }
 public CustomPropertyCells(bool value)
 {
     this.Value = value;
     this.Type  = CustomPropertyTypeToInt(CustomPropertyType.Boolean);
 }
 public CustomPropertyCells(double value)
 {
     this.Value = value;
     this.Type  = CustomPropertyTypeToInt(CustomPropertyType.Number);
 }