From 784208bd46ce05025d8ccaef8542328350038d90 Mon Sep 17 00:00:00 2001 From: Rob Mensching Date: Thu, 4 Oct 2018 13:54:59 -0700 Subject: Simplify whitespace handling and fix some long standing bugs in it Fixes wixtoolset/issues#5883 --- src/test/WixToolsetTest.WixCop/ConverterFixture.cs | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) (limited to 'src/test') diff --git a/src/test/WixToolsetTest.WixCop/ConverterFixture.cs b/src/test/WixToolsetTest.WixCop/ConverterFixture.cs index 86931d5a..863a781a 100644 --- a/src/test/WixToolsetTest.WixCop/ConverterFixture.cs +++ b/src/test/WixToolsetTest.WixCop/ConverterFixture.cs @@ -94,8 +94,82 @@ namespace WixToolsetTest.WixCop var actual = UnformattedDocumentString(document); + Assert.Equal(expected, actual); Assert.Equal(4, errors); + } + + [Fact] + public void CanPreserveNewLines() + { + var parse = String.Join(Environment.NewLine, + "", + "", + " ", + "", + " ", + "", + " ", + ""); + + var expected = String.Join(Environment.NewLine, + "", + "", + " ", + "", + " ", + "", + " ", + ""); + + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); + + var messaging = new DummyMessaging(); + var converter = new Converter(messaging, 4, null, null); + + var conversions = converter.ConvertDocument(document); + + var actual = UnformattedDocumentString(document); + + Assert.Equal(expected, actual); + Assert.Equal(3, conversions); + } + + [Fact] + public void CanConvertWithNewLineAtEndOfFile() + { + var parse = String.Join(Environment.NewLine, + "", + "", + " ", + "", + " ", + "", + " ", + "", + ""); + + var expected = String.Join(Environment.NewLine, + "", + "", + " ", + "", + " ", + "", + " ", + "", + ""); + + var document = XDocument.Parse(parse, LoadOptions.PreserveWhitespace | LoadOptions.SetLineInfo); + + var messaging = new DummyMessaging(); + var converter = new Converter(messaging, 4, null, null); + + var conversions = converter.ConvertDocument(document); + + var actual = UnformattedDocumentString(document); + Assert.Equal(expected, actual); + Assert.Equal(3, conversions); } [Fact] -- cgit v1.2.3-55-g6feb