| 1 | // Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information. |
| 2 | |
| 3 | namespace WixToolsetTest.CoreIntegration |
| 4 | { |
| 5 | using System.Collections.Generic; |
| 6 | using WixInternal.TestSupport; |
| 7 | using WixInternal.Core.TestPackage; |
| 8 | using Xunit; |
| 9 | |
| 10 | public class TestXmlFixture |
| 11 | { |
| 12 | [Fact] |
| 13 | public void ChangesIgnoredAttributesToStarToHelpMakeTestsLessFragile() |
| 14 | { |
| 15 | var original = @"<Top One='f'> |
| 16 | <First Two='t'> |
| 17 | <Target One='a' Two='b' Three='c' /> |
| 18 | </First> |
| 19 | <Target One='z' Two='x' Three = 'y' /> |
| 20 | </Top>"; |
| 21 | var expected = "<Top One='f'><First Two='t'><Target One='*' Two='*' Three='c' /></First><Target One='*' Two='*' Three='y' /></Top>"; |
| 22 | var ignored = new Dictionary<string, List<string>> { { "Target", new List<string> { "One", "Two", "Missing" } } }; |
| 23 | WixAssert.StringEqual(expected, original.GetTestXml(ignored)); |
| 24 | } |
| 25 | |
| 26 | [Fact] |
| 27 | public void OutputsSingleQuotesSinceDoubleQuotesInCsharpLiteralStringsArePainful() |
| 28 | { |
| 29 | var original = "<Test Simple=\"\" EscapedDoubleQuote=\""\" SingleQuoteValue=\"'test'\" Alternating='\"' AlternatingEscaped='"' />"; |
| 30 | var expected = "<Test Simple='' EscapedDoubleQuote='\"' SingleQuoteValue=''test'' Alternating='\"' AlternatingEscaped='\"' />"; |
| 31 | WixAssert.StringEqual(expected, original.GetTestXml()); |
| 32 | } |
| 33 | |
| 34 | [Fact] |
| 35 | public void RemovesAllNamespacesToReduceTyping() |
| 36 | { |
| 37 | var original = "<Test xmlns='a'><Child xmlns:b='b'><Grandchild xmlns:c='c' /><Grandchild /></Child></Test>"; |
| 38 | var expected = "<Test><Child><Grandchild /><Grandchild /></Child></Test>"; |
| 39 | WixAssert.StringEqual(expected, original.GetTestXml()); |
| 40 | } |
| 41 | |
| 42 | [Fact] |
| 43 | public void RemovesUnnecessaryWhitespaceToAvoidLineEndingIssues() |
| 44 | { |
| 45 | var original = @"<Test> |
| 46 | <Child> |
| 47 | <Grandchild /> |
| 48 | <Grandchild /> |
| 49 | </Child> |
| 50 | </Test>"; |
| 51 | var expected = "<Test><Child><Grandchild /><Grandchild /></Child></Test>"; |
| 52 | WixAssert.StringEqual(expected, original.GetTestXml()); |
| 53 | } |
| 54 | |
| 55 | [Fact] |
| 56 | public void RemovesXmlDeclarationToReduceTyping() |
| 57 | { |
| 58 | var original = "<?xml version='1.0'?><Test />"; |
| 59 | var expected = "<Test />"; |
| 60 | WixAssert.StringEqual(expected, original.GetTestXml()); |
| 61 | } |
| 62 | } |
| 63 | } |