public void BasicScriptVariablesWithScriptTags()
        {
            var scriptVars = new ScriptVariables();

            scriptVars.Add("name", "Rick");
            scriptVars.Add("timestamp", DateTime.UtcNow);

            var code = scriptVars.ToString();

            Console.WriteLine(code);
            Assert.IsNotNull(code);
            Assert.IsTrue(code.Contains("new Date("));
        }
        public void ClientScriptVariablesWithItemsTest()
        {
            var scriptVars = new ScriptVariables("pageVars");
            scriptVars.Add("name", "Rick & Company");
            scriptVars.Add("date", DateTime.Now);
            scriptVars.Add("item", new Item() { Sku = "wwhelp", Description = "Help Builder  < test >", Price = 299M });

            scriptVars.UpdateMode = AllowUpdateTypes.ItemsOnly;

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

            Console.WriteLine(output);

            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("Help Builder"));
        }
        public void ClientScriptVariablesWithItemsTest()
        {
            var scriptVars = new ScriptVariables("pageVars");

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

            scriptVars.UpdateMode = AllowUpdateTypes.ItemsOnly;

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

            Console.WriteLine(output);

            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("Help Builder"));
        }
        /// <summary>
        /// Adds each of the stored collections of input objects
        /// to the main collection of input objects.
        /// </summary>
        private void AddScriptArgumentsToMainCollection()
        {
            if (ScriptTextVariables != null && ScriptTextVariables.Count > 0)
            {
                ScriptVariables.Add(new CollectionContainer()
                {
                    Collection = ScriptTextVariables
                });
            }

            if (ScriptUsernameVariables != null && ScriptUsernameVariables.Count > 0)
            {
                ScriptVariables.Add(new CollectionContainer()
                {
                    Collection = ScriptUsernameVariables
                });
            }

            if (ScriptPasswordVariables != null && ScriptPasswordVariables.Count > 0)
            {
                ScriptVariables.Add(new CollectionContainer()
                {
                    Collection = ScriptPasswordVariables
                });
            }

            if (ScriptMultiLineVariables != null && ScriptMultiLineVariables.Count > 0)
            {
                ScriptVariables.Add(new CollectionContainer()
                {
                    Collection = ScriptMultiLineVariables
                });
            }

            if (ScriptCheckboxVariables != null && ScriptCheckboxVariables.Count > 0)
            {
                ScriptVariables.Add(new CollectionContainer()
                {
                    Collection = ScriptCheckboxVariables
                });
            }

            if (ScriptRadiobuttonVariables != null && ScriptRadiobuttonVariables.Count > 0)
            {
                ScriptVariables.Add(new CollectionContainer()
                {
                    Collection = ScriptRadiobuttonVariables
                });
            }
        }
        public void ClientScriptVariablesDictionaryWithNumberedIndexesInitializationTest()
        {
            var scriptVars = new ScriptVariables("pageVars");
            scriptVars.Add("values",new Dictionary<int, object>
            {
                { 2, "Rick & Company" },
                { 4, DateTime.Now },
                { 6, new Item() { Sku = "wwhelp", Description = "Help Builder  < test >", Price = 299M }}
            });

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

            Console.WriteLine(output);
            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("Help Builder"));
        }
        public void ClientScriptVariablesDictionaryInitializationTest()
        {
            var scriptVars = new ScriptVariables("pageVars");
            scriptVars.Add( new Dictionary<string,object>()
            {
                { "name", "Rick & Company" },
                { "date", DateTime.Now },
                { "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"));
        }
        public void ReturnNestedVariableTest()
        {
            var scriptVars = new ScriptVariables("app.names");

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

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

            Console.WriteLine(output);
            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("Westwind"));
        }
        public void ClientScriptVariablesDictionaryWithNumberedIndexesInitializationTest()
        {
            var scriptVars = new ScriptVariables("pageVars");

            scriptVars.Add("values", new Dictionary <int, object>
            {
                { 2, "Rick & Company" },
                { 4, DateTime.Now },
                { 6, new Item()
                  {
                      Sku = "wwhelp", Description = "Help Builder  < test >", Price = 299M
                  } }
            });

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

            Console.WriteLine(output);
            Assert.IsNotNull(output);
            Assert.IsTrue(output.Contains("Help Builder"));
        }
        public void ClientScriptVariablesDictionaryInitializationTest()
        {
            var scriptVars = new ScriptVariables("pageVars");

            scriptVars.Add(new Dictionary <string, object>()
            {
                { "name", "Rick & Company" },
                { "date", DateTime.Now },
                { "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"));
        }
Beispiel #10
0
        private void uiBtnOK_Click(object sender, EventArgs e)
        {
            //remove all variables
            ScriptVariables.Clear();

            //loop each variable and add
            for (int i = 0; i < _userVariableParentNode.Nodes.Count; i++)
            {
                //get name and value
                var variableName  = _userVariableParentNode.Nodes[i].Text.Replace("{", "").Replace("}", "");
                var variableValue = _userVariableParentNode.Nodes[i].Nodes[0].Text.Replace(_leadingValue, "").Replace(_emptyValue, "");

                //add to list
                ScriptVariables.Add(new ScriptVariable()
                {
                    VariableName = variableName, VariableValue = variableValue
                });
            }

            //return success result
            DialogResult = DialogResult.OK;
        }
Beispiel #11
0
        private void ResetVariables()
        {
            //remove all variables
            ScriptVariables.Clear();

            //loop each variable and add
            for (int i = 0; i < _userVariableParentNode.Nodes.Count; i++)
            {
                //get name and value
                var variableName  = _userVariableParentNode.Nodes[i].Text;
                var variableValue = _userVariableParentNode.Nodes[i].Nodes[0].Text.Replace(_leadingValue, "").Replace(_emptyValue, "");
                var variableType  = (Type)_userVariableParentNode.Nodes[i].Nodes[1].Tag;

                //add to list
                ScriptVariables.Add(new ScriptVariable()
                {
                    VariableName  = variableName,
                    VariableValue = variableValue,
                    VariableType  = variableType
                });
            }
        }
        public void ReturnNestedVariableTest()
        {
            var scriptVars = new ScriptVariables("app.names");
            scriptVars.Add("values", new 
            {
                name =  "Rick",
                company = "Westwind",
                entered = DateTime.UtcNow
            });            

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

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