@joebigelow / wix / commits / 4946477e

Add test for formatting file in place (issue-8181)

Peter Hull committed May 5, 2024 at 19:42 UTC 4946477e98000db6769facea5c1cab8f50386b94
1 file changed +29
src/wix/test/WixToolsetTest.Converters/FormatFixture.cs
+29
@@ -3,8 +3,10 @@
3 namespace WixToolsetTest.Converters
4 {
5 using System;
6 + using System.IO;
7 using System.Xml.Linq;
8 using WixToolset.Converters;
9 + using WixToolset.Extensibility.Services;
10 using WixToolsetTest.Converters.Mocks;
11 using Xunit;
12
@@ -113,5 +115,32 @@ namespace WixToolsetTest.Converters
115 Assert.Equal(expected, actual);
116 Assert.Equal(3, conversions);
117 }
118 + [Fact]
119 + public void CanSaveInPlace()
120 + {
121 + var parse = String.Join(Environment.NewLine,
122 + "<?xml version='1.0' encoding='utf-8'?>",
123 + "<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>",
124 + " <Fragment>",
125 + " <Property Id='Prop'",
126 + " Value='Val'>",
127 + " </Property>",
128 + " </Fragment>",
129 + "</Wix>");
130 +
131 + var expected = String.Join(Environment.NewLine,
132 + "<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
133 + " <Fragment>",
134 + " <Property Id=\"Prop\" Value=\"Val\" />",
135 + " </Fragment>",
136 + "</Wix>");
137 + var tempFileName = Path.GetTempFileName();
138 + File.WriteAllText(tempFileName, parse, System.Text.Encoding.UTF8);
139 + var messaging = new MockMessaging();
140 + var converter = new WixConverter(messaging, 4, null, null);
141 + converter.FormatFile(tempFileName, true);
142 + var actual = File.ReadAllText(tempFileName, System.Text.Encoding.UTF8);
143 + Assert.Equal(expected, actual);
144 + }
145 }
146 }