示例#1
0
        public void TestDefaultValueAccessors()
        {
            SimpleValue sv = new SimpleValue();

            Assert.IsNull(sv.Value);
            Assert.AreEqual(true, sv.GetBoolean(true));
            Assert.AreEqual(5, sv.GetInt(5));
            Assert.AreEqual(long.MaxValue, sv.GetLong(long.MaxValue));
            Assert.AreEqual("test", sv.GetString("test"));
            Assert.AreEqual(double.MaxValue, sv.GetDouble(double.MaxValue));
            Assert.AreEqual(decimal.MinValue, sv.GetDecimal(decimal.MinValue));
            Assert.AreEqual(Binary.NO_BINARY, sv.GetBinary(Binary.NO_BINARY));
            DateTime dt = DateTime.Now;

            Assert.AreEqual(dt, sv.GetDateTime(dt));

            sv.SetBoolean(false);
            Assert.AreNotEqual(true, sv.GetBoolean(true));
            sv.SetInt(100);
            Assert.AreNotEqual(5, sv.GetInt(5));
            sv.SetLong(100L);
            Assert.AreNotEqual((object)long.MaxValue, (object)sv.GetLong(long.MaxValue));
            sv.SetString("testing");
            Assert.AreNotEqual("test", sv.GetString("test"));
            sv.SetDouble(100D);
            Assert.AreNotEqual(double.MaxValue, sv.GetDouble(double.MaxValue));
            sv.SetDecimal(decimal.MinusOne);
            Assert.AreNotEqual(decimal.MinValue, sv.GetDecimal(decimal.MinValue));
            sv.SetBinary(new Binary(new byte[] { 3, 4, 5 }));
            Assert.AreNotEqual(Binary.NO_BINARY, sv.GetBinary(Binary.NO_BINARY));
            sv.SetDateTime(DateTime.Today);
            Assert.AreNotEqual(dt, sv.GetDateTime(dt));
        }
示例#2
0
        public void TestValue()
        {
            SimpleValue sv = new SimpleValue("true");

            Assert.AreEqual(true, sv.GetBoolean());
            Assert.AreEqual(true.ToString(), sv.GetString());
            Assert.AreEqual(0, sv.GetInt()); //after this, value is null
            Assert.IsNull(sv.Value);

            sv.SetInt(5);
            Assert.AreEqual(5, sv.GetInt());
            Assert.AreEqual(5L, sv.GetLong());
            Assert.AreEqual(5.0, sv.GetDouble());
            Assert.AreEqual(new decimal(5), sv.GetDecimal());
            Assert.AreEqual(DateTime.MinValue, sv.GetDateTime());
            Assert.IsNull(sv.Value);

            Assert.AreEqual(Binary.NO_BINARY, sv.GetBinary());
        }