Example #1
0
        public void TestUnknownGet()
        {
            JSONObject doc = GetTestObject();

            decimal number = (decimal)JSONValueFactory.GetOrSet(doc, "number2", typeof(JSONNumber));

            Assert.AreEqual(0m, number);

            try
            {
                JSONValueFactory.GetOrSet(doc, "number2", typeof(JSONString));
                Assert.Fail("Exception expected");
            }
            catch (Exception)
            {
                // expected
            }

            try
            {
                JSONValueFactory.GetOrSet(doc, "number3", typeof(NoGoodConstructor));
            }
            catch (Exception)
            {
                // expected
            }
        }
Example #2
0
        public void TestKnownGet()
        {
            JSONObject doc = GetTestObject();

            decimal number = (decimal)JSONValueFactory.GetOrSet(doc, "number", typeof(JSONNumber));

            Assert.AreEqual(123m, number);

            string str = (string)JSONValueFactory.GetOrSet(doc, "string", typeof(JSONString));

            Assert.AreEqual("Hello, World!", str);

            try
            {
                JSONValueFactory.GetOrSet(doc, "string", typeof(JSONNumber));
                Assert.Fail("Exception expected");
            }
            catch (Exception)
            {
                // expected
            }
        }
Example #3
0
 public decimal GetDecimal()
 {
     return((decimal)JSONValueFactory.GetOrSet(this, "decimal", typeof(decimal)));
 }
Example #4
0
 public String GetString()
 {
     return((String)JSONValueFactory.GetOrSet(this, "string", typeof(JSONString)));
 }