Example #1
0
        public void Add_String_Test()
        {
            var j = WFJson.Parse("[]");

            j.Add("a");
            Assert.AreEqual(j.ToString(), "[\"a\"]");
        }
Example #2
0
        public void Contains_Int_Test()
        {
            var j = WFJson.Parse("[1,2,3]");

            Assert.IsTrue(j.Contains(1));
            Assert.IsFalse(j.Contains(5));
        }
Example #3
0
        public void Add_Object_Test()
        {
            var j = WFJson.Parse("[]");

            j.Add(obj);
            Assert.AreEqual(j.ToString(), "[" + new WFJson(obj) + "]");
        }
Example #4
0
        public void Add_Bool_Test()
        {
            var j = WFJson.Parse("[]");

            j.Add(true);
            Assert.AreEqual(j.ToString(), "[true]");
        }
Example #5
0
        public void Add_Int_Test()
        {
            var j = WFJson.Parse("[]");

            j.Add(1);
            Assert.AreEqual(j.ToString(), "[1]");
        }
Example #6
0
        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);
        }
Example #7
0
        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);
        }
Example #8
0
        public void Parse_Test()
        {
            var b = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
            var j = WFJson.Parse(b);

            Assert.IsInstanceOfType(j, typeof(WFJson));
        }
Example #9
0
        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);
        }
Example #10
0
        public void IndexOf_Int_Test()
        {
            var j = WFJson.Parse("[]");

            Assert.AreEqual(j.IndexOf(1), -1);
            j.Add(1);
            Assert.AreEqual(j.IndexOf(1), 0);
        }
Example #11
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());
        }
Example #12
0
        public void Add_DateTime_Test()
        {
            var      j  = WFJson.Parse("[]");
            DateTime dt = DateTime.Now;

            j.Add(dt);
            Assert.AreEqual(j[0].V <DateTime>(), dt);
        }
Example #13
0
        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);
        }
Example #14
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));
        }
Example #15
0
        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);
        }