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); }
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 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); }
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); }
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); }
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"); }
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"); }
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"); }
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"); }
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 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); }