public void JavaScriptVariablesWithItemsTest()
        {
            var scriptVars = new JsonVariables("pageVars");
            scriptVars.Add("name", "Rick & Company");
            scriptVars.Add("date", DateTime.Now);
            scriptVars.Add("item", new Item() { Sku = "wwhelp", Description = "Help Builder  < test >", Price = 299M });
            

            // output as a string
            string output = scriptVars.ToString(true);

            Console.WriteLine(output);

            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("Help Builder"));
        }
Example #2
0
        public void JavaScriptVariablesWithItemsTest()
        {
            var scriptVars = new JsonVariables("pageVars");

            scriptVars.Add("name", "Rick & Company");
            scriptVars.Add("date", DateTime.Now);
            scriptVars.Add("item", new Item()
            {
                Sku = "wwhelp", Description = "Help Builder  < test >", Price = 299M
            });


            // output as a string
            string output = scriptVars.ToString(true);

            Console.WriteLine(output);

            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("Help Builder"));
        }
Example #3
0
        public void ReturnNoVarTest()
        {
            var scriptVars = new JsonVariables("scriptVars");

            scriptVars.Add("values", new
            {
                name    = "Rick",
                company = "Westwind",
                entered = DateTime.UtcNow
            });

            // output as a string - no var statement
            string output = scriptVars.ToString(true);

            Console.WriteLine(output);
            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("Westwind"));

            // . in varname should prevent var statement from generating
            Assert.IsFalse(output.Contains("var"));
        }
Example #4
0
        public void ToPropertyDictionaryTest()
        {
            var dict = new Dictionary <string, object>
            {
                {
                    "name", "Rick"
                },
                {
                    "company", "West Wind"
                },
                {
                    "entered", DateTime.Now
                }
            };

            string output = JsonVariables.ToPropertyDictionaryString(dict);


            Console.WriteLine(output);
            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("West Wind"));
        }
        public void ReturnNoVarTest()
        {
            var scriptVars = new JsonVariables("scriptVars");
            scriptVars.Add("values", new
            {
                name = "Rick",
                company = "Westwind",
                entered = DateTime.UtcNow
            });

            // output as a string - no var statement
            string output = scriptVars.ToString(true);

            Console.WriteLine(output);
            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("Westwind"));

            // . in varname should prevent var statement from generating
            Assert.IsFalse(output.Contains("var"));
        }
Example #6
0
 public JsonStruct()
 {
     Vars = new JsonVariables();
 }