public void ParametersForProjectItemWithoutTemplateAreEmpty()
 {
     File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
     this.projectItem.SetItemAttribute(ItemMetadata.Generator, TemplatedFileGenerator.Name);
     var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
     Assert.AreEqual(0, target.GetProperties().Count);
 }
        public void ParametersObjectConvertsToEmptyStringToPreventDisplayOfTypeNameInPropertiesWindow()
        {
            var           target    = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
            TypeConverter converter = TypeDescriptor.GetConverter(target);

            Assert.AreEqual(string.Empty, converter.ConvertToInvariantString(target));
        }
 public void ParametersDefinedInInputFileAreRecognized()
 {
     this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator");
     File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
     var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
     Assert.AreEqual("TestParameter", target.GetProperties().Cast<PropertyDescriptor>().Single().Name);
 }
        public void ParametersForProjectItemWithoutCustomToolAreEmpty()
        {
            File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
            var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);

            Assert.AreEqual(0, target.GetProperties().Count);
        }
Exemplo n.º 5
0
 public CustomToolParameterTest()
 {
     this.dte = new FakeDte();
     this.solution = new FakeSolution(this.dte);
     this.project = new FakeProject(this.solution);
     this.projectItem = new FakeProjectItem(this.project);
     this.parent = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
 }
        public void CustomToolComparisonIsCaseInsensitive()
        {
            this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator".ToUpperInvariant());
            File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
            var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);

            Assert.AreEqual("TestParameter", target.GetProperties().Cast <PropertyDescriptor>().Single().Name);
        }
        public void ParametersForProjectItemWithoutTemplateAreEmpty()
        {
            File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
            this.projectItem.SetItemAttribute(ItemMetadata.Generator, TemplatedFileGenerator.Name);
            var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);

            Assert.AreEqual(0, target.GetProperties().Count);
        }
        public void ParametersDefinedInInputFileAreRecognized()
        {
            this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator");
            File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
            var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);

            Assert.AreEqual("TestParameter", target.GetProperties().Cast <PropertyDescriptor>().Single().Name);
        }
        public void ParametersDefinedOutsideOfMscorlibAreRecognized()
        {
            this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator");
            File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.ComponentModel.EditorBrowsableState\" #>");
            var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);

            Assert.AreEqual(typeof(EditorBrowsableState), target.GetProperties().Cast <PropertyDescriptor>().Single().PropertyType);
        }
Exemplo n.º 10
0
 public CustomToolParameterTest()
 {
     this.dte         = new FakeDte();
     this.solution    = new FakeSolution(this.dte);
     this.project     = new FakeProject(this.solution);
     this.projectItem = new FakeProjectItem(this.project);
     this.parent      = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
 }
Exemplo n.º 11
0
 public void ParametersDefinedInIncludedFilesAreRecognized()
 {
     this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator");
     string includeFile = Path.Combine(Path.GetDirectoryName(this.projectItem.TestFile.FullName), Path.GetRandomFileName());
     File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ include file=\"" + includeFile + "\" #>");
     File.WriteAllText(includeFile, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
     var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
     Assert.AreEqual("TestParameter", target.GetProperties().Cast<PropertyDescriptor>().Single().Name);
 }
Exemplo n.º 12
0
        public void ParametersDefinedInAssociatedTemplateAreRecognized()
        {
            string templateFile = Path.Combine(Path.GetDirectoryName(this.projectItem.TestFile.FullName), Path.GetRandomFileName());

            File.WriteAllText(templateFile, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
            this.projectItem.SetItemAttribute(ItemMetadata.Generator, TemplatedFileGenerator.Name);
            this.projectItem.SetItemAttribute(ItemMetadata.Template, templateFile);
            var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);

            Assert.AreEqual("TestParameter", target.GetProperties().Cast <PropertyDescriptor>().Single().Name);
        }
Exemplo n.º 13
0
        public void ParameterWhoseTypeCannotBeResolvedIsPresentedAsReadOnlyPropertyWithErrorInDescription()
        {
            this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator");
            File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"NonexistentType\" #>");
            var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
            PropertyDescriptor property = target.GetProperties()[0];

            Assert.AreEqual("TestParameter", property.Name);
            Assert.IsTrue(property.IsReadOnly);
            var attribute = property.Attributes.OfType <System.ComponentModel.DescriptionAttribute>().Single();

            StringAssert.Contains(attribute.Description, "NonexistentType");
        }
Exemplo n.º 14
0
        public void ParametersDefinedInReferencedAssembliesAreRecognized()
        {
            this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator");
            const string TemplateContent =
                "<#@ assembly name=\"System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86\" #>" +
                "<#@ parameter name=\"TestParameter\" type=\"System.Data.OracleClient.OracleType\" #>";

            File.WriteAllText(this.projectItem.TestFile.FullName, TemplateContent);
            var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
            PropertyDescriptor parameter = target.GetProperties().Cast <PropertyDescriptor>().Single();

            StringAssert.Contains(parameter.PropertyType.Assembly.FullName, "System.Data.OracleClient");
        }
Exemplo n.º 15
0
 public void ParametersDefinedInReferencedAssembliesAreRecognized()
 {
     this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator");
     const string TemplateContent = 
         "<#@ assembly name=\"System.Data.OracleClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86\" #>" +
         "<#@ parameter name=\"TestParameter\" type=\"System.Data.OracleClient.OracleType\" #>";
     File.WriteAllText(this.projectItem.TestFile.FullName, TemplateContent);
     var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
     PropertyDescriptor parameter = target.GetProperties().Cast<PropertyDescriptor>().Single();
     StringAssert.Contains(parameter.PropertyType.Assembly.FullName, "System.Data.OracleClient");
 }
Exemplo n.º 16
0
 public void ParameterWhoseTypeCannotBeResolvedIsPresentedAsReadOnlyPropertyWithErrorInDescription()
 {
     this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator");
     File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"NonexistentType\" #>");
     var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
     PropertyDescriptor property = target.GetProperties()[0];
     Assert.AreEqual("TestParameter", property.Name);
     Assert.IsTrue(property.IsReadOnly);
     var attribute = property.Attributes.OfType<System.ComponentModel.DescriptionAttribute>().Single();
     StringAssert.Contains(attribute.Description, "NonexistentType");
 }
Exemplo n.º 17
0
 public void CustomToolComparisonIsCaseInsensitive()
 {
     this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator".ToUpperInvariant());
     File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
     var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
     Assert.AreEqual("TestParameter", target.GetProperties().Cast<PropertyDescriptor>().Single().Name);
 }
Exemplo n.º 18
0
 public void ParametersForProjectItemWithoutCustomToolAreEmpty()
 {
     File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.String\" #>");
     var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
     Assert.AreEqual(0, target.GetProperties().Count);
 }
Exemplo n.º 19
0
 public void ParametersDefinedOutsideOfMscorlibAreRecognized()
 {
     this.projectItem.SetItemAttribute(ItemMetadata.Generator, "TextTemplatingFileGenerator");
     File.WriteAllText(this.projectItem.TestFile.FullName, "<#@ parameter name=\"TestParameter\" type=\"System.ComponentModel.EditorBrowsableState\" #>");
     var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
     Assert.AreEqual(typeof(EditorBrowsableState), target.GetProperties().Cast<PropertyDescriptor>().Single().PropertyType);
 }
Exemplo n.º 20
0
 public void ParametersObjectConvertsToEmptyStringToPreventDisplayOfTypeNameInPropertiesWindow()
 {
     var target = new CustomToolParameters(this.dte, this.project, this.projectItem.Id);
     TypeConverter converter = TypeDescriptor.GetConverter(target);
     Assert.AreEqual(string.Empty, converter.ConvertToInvariantString(target));
 }