diff options
Diffstat (limited to 'src/internal')
-rw-r--r-- | src/internal/WixInternal.TestSupport/XunitExtensions/WixAssert.cs | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/internal/WixInternal.TestSupport/XunitExtensions/WixAssert.cs b/src/internal/WixInternal.TestSupport/XunitExtensions/WixAssert.cs index 66f831a1..083e34f5 100644 --- a/src/internal/WixInternal.TestSupport/XunitExtensions/WixAssert.cs +++ b/src/internal/WixInternal.TestSupport/XunitExtensions/WixAssert.cs | |||
@@ -4,6 +4,7 @@ namespace WixInternal.TestSupport | |||
4 | { | 4 | { |
5 | using System; | 5 | using System; |
6 | using System.Collections.Generic; | 6 | using System.Collections.Generic; |
7 | using System.IO; | ||
7 | using System.Linq; | 8 | using System.Linq; |
8 | using System.Text; | 9 | using System.Text; |
9 | using System.Xml.Linq; | 10 | using System.Xml.Linq; |
@@ -30,8 +31,8 @@ namespace WixInternal.TestSupport | |||
30 | 31 | ||
31 | public static void CompareXml(XContainer xExpected, XContainer xActual) | 32 | public static void CompareXml(XContainer xExpected, XContainer xActual) |
32 | { | 33 | { |
33 | 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}"))}"); | 34 | var expecteds = ComparableElements(xExpected); |
34 | 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}"))}"); | 35 | var actuals = ComparableElements(xActual); |
35 | 36 | ||
36 | CompareLineByLine(expecteds.OrderBy(s => s).ToArray(), actuals.OrderBy(s => s).ToArray()); | 37 | CompareLineByLine(expecteds.OrderBy(s => s).ToArray(), actuals.OrderBy(s => s).ToArray()); |
37 | } | 38 | } |
@@ -44,6 +45,22 @@ namespace WixInternal.TestSupport | |||
44 | CompareXml(expectedDoc, actualDoc); | 45 | CompareXml(expectedDoc, actualDoc); |
45 | } | 46 | } |
46 | 47 | ||
48 | private static IEnumerable<string> ComparableElements(XContainer container) | ||
49 | { | ||
50 | return container.Descendants().Select(x => $"{x.Name.LocalName}:{String.Join(",", x.Attributes().OrderBy(a => a.Name.LocalName).Select(a => $"{a.Name.LocalName}={ComparableAttribute(a)}"))}"); | ||
51 | } | ||
52 | |||
53 | private static string ComparableAttribute(XAttribute attribute) | ||
54 | { | ||
55 | switch (attribute.Name.LocalName) | ||
56 | { | ||
57 | case "SourceFile": | ||
58 | return "<SourceFile>"; | ||
59 | default: | ||
60 | return attribute.Value; | ||
61 | } | ||
62 | } | ||
63 | |||
47 | /// <summary> | 64 | /// <summary> |
48 | /// Dynamically skips the test. | 65 | /// Dynamically skips the test. |
49 | /// Requires that the test was marked with a fact attribute derived from <see cref="WixInternal.TestSupport.XunitExtensions.SkippableFactAttribute" /> | 66 | /// Requires that the test was marked with a fact attribute derived from <see cref="WixInternal.TestSupport.XunitExtensions.SkippableFactAttribute" /> |