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 } }
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 } }
public decimal GetDecimal() { return((decimal)JSONValueFactory.GetOrSet(this, "decimal", typeof(decimal))); }
public String GetString() { return((String)JSONValueFactory.GetOrSet(this, "string", typeof(JSONString))); }