| 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.Converters |
| 4 | { |
| 5 | using System; |
| 6 | using System.Xml.Linq; |
| 7 | using WixInternal.TestSupport; |
| 8 | using WixToolset.Converters; |
| 9 | using WixToolsetTest.Converters.Mocks; |
| 10 | using Xunit; |
| 11 | |
| 12 | public class IncludeFixture : BaseConverterFixture |
| 13 | { |
| 14 | [Fact] |
| 15 | public void EnsureNamespace() |
| 16 | { |
| 17 | var parse = String.Join(Environment.NewLine, |
| 18 | "<Include>", |
| 19 | " <Fragment />", |
| 20 | "</Include>"); |
| 21 | |
| 22 | var expected = new[] |
| 23 | { |
| 24 | "<Include xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
| 25 | " <Fragment />", |
| 26 | "</Include>" |
| 27 | }; |
| 28 | |
| 29 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
| 30 | |
| 31 | var messaging = new MockMessaging(); |
| 32 | var converter = new WixConverter(messaging, 2, null, null); |
| 33 | |
| 34 | var errors = converter.ConvertDocument(document); |
| 35 | Assert.Equal(1, errors); |
| 36 | |
| 37 | var actualLines = UnformattedDocumentLines(document); |
| 38 | WixAssert.CompareLineByLine(expected, actualLines); |
| 39 | } |
| 40 | |
| 41 | [Fact] |
| 42 | public void FixNamespace() |
| 43 | { |
| 44 | var parse = String.Join(Environment.NewLine, |
| 45 | "<Include xmlns='http://schemas.microsoft.com/wix/2006/wi'>", |
| 46 | " <Fragment />", |
| 47 | "</Include>"); |
| 48 | |
| 49 | var expected = new[] |
| 50 | { |
| 51 | "<Include xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">", |
| 52 | " <Fragment />", |
| 53 | "</Include>" |
| 54 | }; |
| 55 | |
| 56 | var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); |
| 57 | |
| 58 | var messaging = new MockMessaging(); |
| 59 | var converter = new WixConverter(messaging, 2, null, null); |
| 60 | |
| 61 | var errors = converter.ConvertDocument(document); |
| 62 | Assert.Equal(1, errors); |
| 63 | |
| 64 | var actualLines = UnformattedDocumentLines(document); |
| 65 | WixAssert.CompareLineByLine(expected, actualLines); |
| 66 | } |
| 67 | } |
| 68 | } |