public void V_Path_Test() { var b = Newtonsoft.Json.JsonConvert.SerializeObject(obj); var j = WFJson.Parse(b); Assert.AreEqual <int>(j.V <int>("b[1].b1"), 3); }
public void Constructor_New_Test() { WFJson j = null; j = new WFJson(); Assert.AreEqual(j.ToString(), "{}", "create a empty JsonObject fail"); }
public void Add_String_Test() { var j = WFJson.Parse("[]"); j.Add("a"); Assert.AreEqual(j.ToString(), "[\"a\"]"); }
public void Add_Object_Test() { var j = WFJson.Parse("[]"); j.Add(obj); Assert.AreEqual(j.ToString(), "[" + new WFJson(obj) + "]"); }
public void Add_Bool_Test() { var j = WFJson.Parse("[]"); j.Add(true); Assert.AreEqual(j.ToString(), "[true]"); }
public void Constructor_JObject_Test() { var jobj = new JObject(new JProperty("a", 1)); var j = new WFJson(jobj); Assert.AreEqual(j.ToString(), "{\"a\":1}", "create a JosnObject with JObject fail"); }
public void Add_Int_Test() { var j = WFJson.Parse("[]"); j.Add(1); Assert.AreEqual(j.ToString(), "[1]"); }
public void Constructor_JArray_Test() { var jArr = new JArray(1, 2); var j = new WFJson(jArr); Assert.AreEqual(j.ToString(), "[1,2]"); }
public void Indexer_String_Get_Test() { var b = Newtonsoft.Json.JsonConvert.SerializeObject(obj); var j = WFJson.Parse(b); Assert.AreEqual <int>(j["a"].V <int>(), 123); }
public void Constructor_String_Test() { string str = "123"; var j = new WFJson(str); Assert.AreEqual(j.V <string>(), str); }
public void Contains_Int_Test() { var j = WFJson.Parse("[1,2,3]"); Assert.IsTrue(j.Contains(1)); Assert.IsFalse(j.Contains(5)); }
public void Parse_Test() { var b = Newtonsoft.Json.JsonConvert.SerializeObject(obj); var j = WFJson.Parse(b); Assert.IsInstanceOfType(j, typeof(WFJson)); }
public void Add_DateTime_Test() { var j = WFJson.Parse("[]"); DateTime dt = DateTime.Now; j.Add(dt); Assert.AreEqual(j[0].V <DateTime>(), dt); }
public void StandardTest() { var rtv = InvokeWF("standard", new { a = 2, b = 3 }); var j = WFJson.Parse(rtv); //c=(a+b)*100 Assert.AreEqual(j.V <int>("c"), 500); }
public void IndexOf_Int_Test() { var j = WFJson.Parse("[]"); Assert.AreEqual(j.IndexOf(1), -1); j.Add(1); Assert.AreEqual(j.IndexOf(1), 0); }
public void Add_WFJson_Test() { var j = WFJson.Parse("[]"); var a = new WFJson("sd"); j.Add(a); Assert.AreEqual(j[0].ToString(), a.ToString()); }
public void IndexOf_WFJson_Test() { var j = WFJson.Parse("[]"); var a = new WFJson(1); Assert.AreEqual <int>(j.IndexOf(a), -1); j.Add(a); Assert.AreEqual <int>(j.IndexOf(a), 0); }
public void Contains_WFJson_Test() { var j = WFJson.Parse("[]"); var a = new WFJson(1); Assert.IsFalse(j.Contains(a)); j.Add(a); Assert.IsTrue(j.Contains(a)); }
public void Constructor_Class_Test() { MyClass my = new MyClass() { Name = "Name", Age = 23 }; var j = new WFJson(my); var rtv = j.V <MyClass>(); Assert.IsInstanceOfType(rtv, typeof(MyClass)); Assert.AreEqual(rtv.Name, my.Name); Assert.AreEqual(rtv.Age, my.Age); }
public void Indexer_Int_Set_Test() { var j = new WFJson { ["a.b[0].c"] = 2 }; Assert.IsNotNull(j[0]); //a Assert.IsNotNull(j[0][0]); //a.b Assert.IsNotNull(j[0][0][0]); //a.b[0] Assert.IsNotNull(j[0][0][0][0]); //a.b[0].c Assert.AreEqual(j[0][0][0][0].V <int>(), 2); }
public void Indexer_String_Set_Test() { var j = new WFJson { ["a.b[0].c"] = "a" }; Assert.IsNotNull(j["a"]); Assert.IsNotNull(j["a.b"]); Assert.IsNotNull(j["a.b[0]"]); Assert.IsNotNull(j["a.b[0].c"]); Assert.AreEqual(j["a.b[0].c"].V <string>(), "a"); }
public void GetEnumeratorTest() { var j = new WFJson(obj); foreach (var item in j) { Assert.IsNotNull(item); } foreach (var item in j["b"]) { Assert.IsNotNull(item); } }
public void Indexer_String_Get_Object_Test() { MyClass my = new MyClass() { Name = "Name", Age = 23 }; var j = WFJson.Parse("{a:null}"); j["a"] = new WFJson(my); var rtv = j["a"].V <MyClass>(); Assert.IsInstanceOfType(rtv, typeof(MyClass)); Assert.AreEqual(rtv.Name, my.Name); Assert.AreEqual(rtv.Age, my.Age); }