aboutsummaryrefslogtreecommitdiff
path: root/src/test/wixcop/WixCopFixture.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/wixcop/WixCopFixture.cs')
-rw-r--r--src/test/wixcop/WixCopFixture.cs59
1 files changed, 57 insertions, 2 deletions
diff --git a/src/test/wixcop/WixCopFixture.cs b/src/test/wixcop/WixCopFixture.cs
index d11865f1..1fa49be9 100644
--- a/src/test/wixcop/WixCopFixture.cs
+++ b/src/test/wixcop/WixCopFixture.cs
@@ -15,7 +15,7 @@ namespace WixCopTests
15{ 15{
16 public class WixCopFixture 16 public class WixCopFixture
17 { 17 {
18 [Fact(Skip = "Problematic at the moment.")] 18 [Fact]
19 public void CanConvertSingleFile() 19 public void CanConvertSingleFile()
20 { 20 {
21 const string beforeFileName = "SingleFile.wxs"; 21 const string beforeFileName = "SingleFile.wxs";
@@ -38,7 +38,53 @@ namespace WixCopTests
38 }; 38 };
39 39
40 var result = runner.Execute(out var messages); 40 var result = runner.Execute(out var messages);
41 41
42 Assert.Equal(2, result);
43
44 var actualLines = File.ReadAllLines(targetFile);
45 var expectedLines = File.ReadAllLines(Path.Combine(folder, afterFileName));
46 Assert.Equal(expectedLines, actualLines);
47
48 var runner2 = new WixCopRunner
49 {
50 FixErrors = true,
51 SearchPatterns =
52 {
53 targetFile,
54 },
55 };
56
57 var result2 = runner2.Execute(out var messages2);
58
59 Assert.Equal(0, result2);
60 }
61 }
62
63 [Fact]
64 public void RetainsPreprocessorInstructions()
65 {
66 const string beforeFileName = "Preprocessor.wxs";
67 const string afterFileName = "ConvertedPreprocessor.wxs";
68 var folder = TestData.Get(@"TestData\Preprocessor");
69
70 using (var fs = new DisposableFileSystem())
71 {
72 var baseFolder = fs.GetFolder(true);
73 var targetFile = Path.Combine(baseFolder, beforeFileName);
74 File.Copy(Path.Combine(folder, beforeFileName), Path.Combine(baseFolder, beforeFileName));
75
76 var runner = new WixCopRunner
77 {
78 FixErrors = true,
79 SettingFile1 = Path.Combine(folder, "wixcop.settings.xml"),
80 SearchPatterns =
81 {
82 targetFile,
83 },
84 };
85
86 var result = runner.Execute(out var messages);
87
42 Assert.Equal(2, result); 88 Assert.Equal(2, result);
43 89
44 var actualLines = File.ReadAllLines(targetFile); 90 var actualLines = File.ReadAllLines(targetFile);
@@ -48,6 +94,7 @@ namespace WixCopTests
48 var runner2 = new WixCopRunner 94 var runner2 = new WixCopRunner
49 { 95 {
50 FixErrors = true, 96 FixErrors = true,
97 SettingFile1 = Path.Combine(folder, "wixcop.settings.xml"),
51 SearchPatterns = 98 SearchPatterns =
52 { 99 {
53 targetFile, 100 targetFile,
@@ -66,14 +113,22 @@ namespace WixCopTests
66 113
67 public List<string> SearchPatterns { get; } = new List<string>(); 114 public List<string> SearchPatterns { get; } = new List<string>();
68 115
116 public string SettingFile1 { get; set; }
117
69 public int Execute(out List<string> messages) 118 public int Execute(out List<string> messages)
70 { 119 {
71 var argList = new List<string>(); 120 var argList = new List<string>();
121
72 if (this.FixErrors) 122 if (this.FixErrors)
73 { 123 {
74 argList.Add("-f"); 124 argList.Add("-f");
75 } 125 }
76 126
127 if (!String.IsNullOrEmpty(this.SettingFile1))
128 {
129 argList.Add($"-set1{this.SettingFile1}");
130 }
131
77 foreach (string searchPattern in this.SearchPatterns) 132 foreach (string searchPattern in this.SearchPatterns)
78 { 133 {
79 argList.Add(searchPattern); 134 argList.Add(searchPattern);