diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/WixBuildTools.TestSupport/WixAssert.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/WixBuildTools.TestSupport/WixAssert.cs b/src/WixBuildTools.TestSupport/WixAssert.cs index 32a98463..0882e26e 100644 --- a/src/WixBuildTools.TestSupport/WixAssert.cs +++ b/src/WixBuildTools.TestSupport/WixAssert.cs | |||
| @@ -3,6 +3,8 @@ | |||
| 3 | namespace WixBuildTools.TestSupport | 3 | namespace WixBuildTools.TestSupport |
| 4 | { | 4 | { |
| 5 | using System; | 5 | using System; |
| 6 | using System.Linq; | ||
| 7 | using System.Xml.Linq; | ||
| 6 | using Xunit; | 8 | using Xunit; |
| 7 | 9 | ||
| 8 | public class WixAssert : Assert | 10 | public class WixAssert : Assert |
| @@ -14,9 +16,26 @@ namespace WixBuildTools.TestSupport | |||
| 14 | Assert.True(actualLines.Length > i, $"{i}: expectedLines longer than actualLines"); | 16 | Assert.True(actualLines.Length > i, $"{i}: expectedLines longer than actualLines"); |
| 15 | Assert.Equal($"{i}: {expectedLines[i]}", $"{i}: {actualLines[i]}"); | 17 | Assert.Equal($"{i}: {expectedLines[i]}", $"{i}: {actualLines[i]}"); |
| 16 | } | 18 | } |
| 19 | |||
| 17 | Assert.True(expectedLines.Length == actualLines.Length, "actualLines longer than expectedLines"); | 20 | Assert.True(expectedLines.Length == actualLines.Length, "actualLines longer than expectedLines"); |
| 18 | } | 21 | } |
| 19 | 22 | ||
| 23 | public static void CompareXml(XContainer xExpected, XContainer xActual) | ||
| 24 | { | ||
| 25 | var actuals = xActual.Descendants().Select(x => $"{x.Name.LocalName}:{String.Join(",", x.Attributes().OrderBy(a => a.Name.LocalName).Select(a => $"{a.Name.LocalName}={a.Value}"))}"); | ||
| 26 | var expecteds = xExpected.Descendants().Select(x => $"{x.Name.LocalName}:{String.Join(",", x.Attributes().OrderBy(a => a.Name.LocalName).Select(a => $"{a.Name.LocalName}={a.Value}"))}"); | ||
| 27 | |||
| 28 | CompareLineByLine(expecteds.OrderBy(s => s).ToArray(), actuals.OrderBy(s => s).ToArray()); | ||
| 29 | } | ||
| 30 | |||
| 31 | public static void CompareXml(string expectedPath, string actualPath) | ||
| 32 | { | ||
| 33 | var expectedDoc = XDocument.Load(expectedPath, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo); | ||
| 34 | var actualDoc = XDocument.Load(actualPath, LoadOptions.PreserveWhitespace | LoadOptions.SetBaseUri | LoadOptions.SetLineInfo); | ||
| 35 | |||
| 36 | CompareXml(expectedDoc, actualDoc); | ||
| 37 | } | ||
| 38 | |||
| 20 | public static void Succeeded(int hr, string format, params object[] formatArgs) | 39 | public static void Succeeded(int hr, string format, params object[] formatArgs) |
| 21 | { | 40 | { |
| 22 | if (0 > hr) | 41 | if (0 > hr) |
