public void CanConvertSingleFile() { const string beforeFileName = "SingleFile.wxs"; const string afterFileName = "ConvertedSingleFile.wxs"; var folder = TestData.Get(@"TestData\SingleFile"); using (var fs = new DisposableFileSystem()) { var baseFolder = fs.GetFolder(true); var targetFile = Path.Combine(baseFolder, beforeFileName); File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName)); var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 4); var errors = converter.ConvertFile(targetFile, true); Assert.Equal(9, errors); var expected = File.ReadAllText(Path.Combine(folder, afterFileName)).Replace("\r\n", "\n"); var actual = File.ReadAllText(targetFile).Replace("\r\n", "\n"); Assert.Equal(expected, actual); EnsureFixed(targetFile); } }
private static void EnsureFixed(string targetFile) { var messaging2 = new MockMessaging(); var converter2 = new WixConverter(messaging2, 4); var errors2 = converter2.ConvertFile(targetFile, true); Assert.Equal(0, errors2); }
public void CanDetectReadOnlyOutputFile() { const string beforeFileName = "SingleFile.wxs"; var folder = TestData.Get(@"TestData\SingleFile"); using (var fs = new DisposableFileSystem()) { var baseFolder = fs.GetFolder(true); var targetFile = Path.Combine(baseFolder, beforeFileName); File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName)); var info = new FileInfo(targetFile); info.IsReadOnly = true; var messaging = new MockMessaging(); var converter = new WixConverter(messaging, 4); var errors = converter.ConvertFile(targetFile, true); Assert.Single(messaging.Messages.Where(m => m.Id == 5 /*WixConverter.ConverterTestType.UnauthorizedAccessException*/)); } }
public override Task <int> ExecuteAsync(CancellationToken cancellationToken) { if (this.ShowHelp) { DisplayHelp(); return(Task.FromResult(-1)); } this.ParseSettings(SettingsFileDefault); var converter = new WixConverter(this.Messaging, this.IndentationAmount, this.ErrorsAsWarnings, this.IgnoreErrors); var errors = base.Inspect(Inspector, cancellationToken); return(Task.FromResult(errors)); int Inspector(string file, bool fix) { return(converter.ConvertFile(file, fix)); } }