public void TestGetoptionsWithSinglePropertyOverWrite() { const string propertyFileName = "SharpDevelopProperties.xml"; var expected = FormattingOptionsFactory.CreateSharpDevelop(); foreach (var propertyInfo in GetCSharpFormattingOptionsProperties()) { var loaded = CSharpFormattingProperties.GetOptions(Path.Combine(TestFolder, propertyFileName)); // Save the original property value to a one setting temp property file var tempFileName = CreateTempPropertyFileWithSingleProperty(propertyInfo, loaded); try { CheckOptions(expected, loaded, 0); ChangeAllProperties(loaded); CheckOptions(expected, loaded, PropertyCount); loaded = CSharpFormattingProperties.GetOptions(tempFileName, loaded); } finally { File.Delete(tempFileName); } // Check we got back the original property var matchingPropertyNames = GetMatchingPropertyNames(expected, loaded); Assert.AreEqual(1, matchingPropertyNames.Count, matchingPropertyNames.ToString()); Assert.AreEqual(propertyInfo.Name, matchingPropertyNames.FirstOrDefault()); } }
public void TestDefault() { var actual = CSharpFormattingProperties.GetOptions(); var expected = CSharpFormattingProperties.CreateOrcompOptions(); CheckOptions(expected, actual, 0); }
private string CreateTempPropertyFileWithSingleProperty(PropertyInfo propertyInfo, CSharpFormattingOptions options) { var result = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); var properties = new CSharpFormattingProperties(); properties.Set(propertyInfo.Name, propertyInfo.GetValue(options, new object[0])); properties.Save(result); return(result); }
public void TestLoadFullFromSimpleXml() { var actual = CSharpFormattingProperties.GetOptions(Path.Combine(TestFolder, "Simple.xml")); var expected = FormattingOptionsFactory.CreateSharpDevelop(); CheckOptions(expected, actual, 0); expected = FormattingOptionsFactory.CreateEmpty(); CheckOptions(expected, actual, 82); }
public void TestAllIsOverWriting() { var actual = CSharpFormattingProperties.GetOptions(Path.Combine(TestFolder, "SimpleComplement.xml")); var expected = FormattingOptionsFactory.CreateSharpDevelop(); var x = GetMatchingPropertyNames(expected, actual); CheckOptions(expected, actual, PropertyCount); expected = CSharpFormattingProperties.GetOptions(Path.Combine(TestFolder, "Simple.xml")); CheckOptions(expected, actual, PropertyCount); }
public ReformatRule(string optionsFilePath, IncludeExcludeCollection sourceFileFilters, IFileSystemHelper fileSystemHelper, string fileNamePattern = "*.cs", bool isBackupEnabled = true) : base(sourceFileFilters, fileSystemHelper, fileNamePattern, isBackupEnabled) { _options = CSharpFormattingProperties.GetOptions(optionsFilePath); }