Exemple #1
0
        public void Write_Values_Success()
        {
            var jsonEntityChannel = new JsonEntity("Channel", "1", Json);

            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("link"), "http://www.starwars.com", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("description"), "Star Wars blog.", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("title"), "Star Wars", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(jsonEntityChannel.GetCollection("item").Count == 0);

            jsonEntityChannel.SetProperty("link", "http://www.starwars.org");
            jsonEntityChannel.SetProperty("description", "Star Wars best blog.");
            jsonEntityChannel.SetProperty("title", "Star Wars is the best");

            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("link"), "http://www.starwars.org", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("description"), "Star Wars best blog.", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityChannel.GetProperty <string>("title"), "Star Wars is the best", StringComparison.OrdinalIgnoreCase));


            var jsonEntityAddress = jsonEntityChannel.GetEntity("address");

            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("line1"), "123 Main St", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("city"), "Los Angeles", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("state"), "CA", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("country"), "USA", StringComparison.OrdinalIgnoreCase));

            jsonEntityAddress.SetProperty("line1", "123 Strip St");
            jsonEntityAddress.SetProperty("city", "Las Vegas");
            jsonEntityAddress.SetProperty("state", "NV");

            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("line1"), "123 Strip St", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("city"), "Las Vegas", StringComparison.OrdinalIgnoreCase));
            Assert.IsTrue(string.Equals(jsonEntityAddress.GetProperty <string>("state"), "NV", StringComparison.OrdinalIgnoreCase));
        }
Exemple #2
0
        public void BlankEntity_AddProperty_Success()
        {
            var jsonEntity = new JsonEntity("Blank", "1", "{}");

            Assert.Throws <Exception>(() => jsonEntity.GetProperty <string>("code"));
            jsonEntity.SetProperty("code", "blank");
            Assert.IsTrue(string.Equals(jsonEntity.GetProperty <string>("code"), "blank", StringComparison.OrdinalIgnoreCase));
        }