Exemplo n.º 1
0
        public void TestValidTemplateProperties4cs()
        {
            // fields
            string templateName = "ValidTemplateProperties4cs";
            string result       = null;

            // Create Action and set Properties
            TextTemplateAction action = new TextTemplateAction();

            MockColors mockColors = new MockColors();

            TypeDescriptor.GetProperties(action)["NameSpace"].SetValue(action, "TestNameSpace");
            TypeDescriptor.GetProperties(action)["ClassName"].SetValue(action, "TestClass");
            TypeDescriptor.GetProperties(action)["MockColors"].SetValue(action, mockColors);

            action.Template = GetTemplateFileName(templateName);
            sc.Add(action);

            // Execute
            try
            {
                action.Execute();
            }
            catch
            {
                throw;
            }

            result = action.Content;

            // Evaluate results
            string expected = GetExpectedContent(templateName);

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 2
0
        public void TestValidTemplateProperties3csEnum()
        {
            // fields
            string templateName = "ValidTemplateProperties3cs";
            string result       = null;

            // Create Action and set Properties
            TextTemplateAction action = new TextTemplateAction();

            List <string> colorNames = new List <string>();

            colorNames.Add("Red");
            colorNames.Add("Blue");
            colorNames.Add("Green");
            TypeDescriptor.GetProperties(action)["NameSpace"].SetValue(action, "TestNameSpace");
            TypeDescriptor.GetProperties(action)["ClassName"].SetValue(action, "TestClass");
            TypeDescriptor.GetProperties(action)["ColorNames"].SetValue(action, colorNames);

            action.Template = GetTemplateFileName(templateName);
            sc.Add(action);

            // Execute
            action.Execute();
            result = action.Content;

            // Evaluate results
            string expected = GetExpectedContent(templateName);

            Assert.AreEqual(expected, result);
        }
Exemplo n.º 3
0
        public void TestValidTemplateProperties2cs()
        {
            // fields
            string templateName = "ValidTemplateProperties2cs";
            string result       = null;

            // Create Action and set Properties
            TextTemplateAction action = new TextTemplateAction();

            TypeDescriptor.GetProperties(action)["NameSpace"].SetValue(action, "TestNameSpace");
            TypeDescriptor.GetProperties(action)["ClassName"].SetValue(action, "TestClass");
            TypeDescriptor.GetProperties(action)["Amount"].SetValue(action, (decimal)1003.75);

            action.Template = GetTemplateFileName(templateName);
            sc.Add(action);

            // Execute
            action.Execute();
            result = action.Content;

            // Evaluate results
            string expected = GetExpectedContent(templateName);

            Assert.AreEqual(expected, result);
        }
        // Methods
        public override void Execute()
        {
            ProjectItem item = DteHelperEx.FindItemByName(this.Project.ProjectItems, this.ItemName, recursive);

            if (item == null)
            {
                TextTemplateAction templateAction = new TextTemplateAction();
                templateAction.Template = this.Template;

                templateAction.Site = this.Site;
                templateAction.Execute();
                string templateContent = templateAction.Content;

                AddItemFromStringToProjectItemByNameAction addItemAction = new AddItemFromStringToProjectItemByNameAction();
                addItemAction.Content        = templateContent;
                addItemAction.Project        = this.Project;
                addItemAction.TargetFileName = this.ItemName;
                addItemAction.Site           = this.Site;
                addItemAction.Execute();

                item = addItemAction.ProjectItem;
            }

            this.ProjectItem = item;
        }
Exemplo n.º 5
0
        public void ThrowsIfTemplatePropertyNotExistsAsValue()
        {
            TextTemplateAction action = new TextTemplateAction();

            action.Template = GetTemplateFileName("ThrowsIfTemplatePropertyNotExistsAsValue");
            sc.Add(action);

            action.Execute();
        }
Exemplo n.º 6
0
        public void AddsPropertyForDynamicValues()
        {
            TextTemplateAction action = new TextTemplateAction();

            action.Template = GetTemplateFileName("AddsPropertyForDynamicValues");
            sc.Add(action);
            DateTime dt = DateTime.Now;

            TypeDescriptor.GetProperties(action)["DynamicValue"].SetValue(action, dt);
            action.Execute();

            Assert.AreEqual(dt.ToString(CultureInfo.InvariantCulture), action.Content);
        }
Exemplo n.º 7
0
        public void ExecuteWithWrongRootedTemplatePath()
        {
            // fields
            string templateName = "ValidTemplate1cs";

            // Create Action
            TextTemplateAction action = new TextTemplateAction();

            action.Template = "C:\\" + templateName + ".ipe";
            sc.Add(action);

            // Execute
            action.Execute();
        }
Exemplo n.º 8
0
        public void ExecuteWithNullTemplate()
        {
            // fields
            string templateName = null;

            // Create Action
            TextTemplateAction action = new TextTemplateAction();

            action.Template = templateName;
            sc.Add(action);

            // Execute
            action.Execute();
        }
Exemplo n.º 9
0
        public void ExecuteTemplateThatNotExist()
        {
            // fields
            string templateName = "TemplatThatNotExist";

            // Create Action
            TextTemplateAction action = new TextTemplateAction();

            action.Template = GetTemplateFileName(templateName);
            sc.Add(action);

            // Execute
            action.Execute();
        }
Exemplo n.º 10
0
        public void ExecuteInvalidTemplate1cs()
        {
            // fields
            string templateName = "InvalidTemplate1cs";

            // Create Action
            TextTemplateAction action = new TextTemplateAction();

            action.Template = GetTemplateFileName(templateName);
            sc.Add(action);

            // Execute
            action.Execute();
        }
Exemplo n.º 11
0
        public void ExecuteSimpleTemplateImportAssembly2cs()
        {
            // fields
            string templateName = "ValidTemplateImportAssembly2cs";

            // Create Action
            TextTemplateAction action = new TextTemplateAction();

            action.Template = GetTemplateFileName(templateName);
            sc.Add(action);

            // Execute
            action.Execute();
        }
Exemplo n.º 12
0
        public void ExecuteSimpleTemplate1csWithoutValueInfoService()
        {
            // fields
            string templateName = "ValidTemplate1cs";

            sc.RemoveService(typeof(IValueInfoService));

            // Create Action
            TextTemplateAction action = new TextTemplateAction();

            action.Template = GetTemplateFileName(templateName);
            sc.Add(action);

            // Execute
            action.Execute();
        }
Exemplo n.º 13
0
        public void ExecuteSimpleTemplateInclude1cs()
        {
            // fields
            string templateName = "ValidTemplateInclude1cs";

            // Create Action
            TextTemplateAction action = new TextTemplateAction();

            action.Template = GetTemplateFileName(templateName);
            sc.Add(action);

            // Execute
            action.Execute();
            string result = action.Content;

            // Evaluate results
            string expected = GetExpectedContent(templateName);

            Assert.AreEqual(expected, result);
        }