Skip to content

Commit

Permalink
Add test for formatting file in place (issue-8181)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedro-w committed May 5, 2024
1 parent 2b95a98 commit 81af891
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/wix/test/WixToolsetTest.Converters/FormatFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
namespace WixToolsetTest.Converters
{
using System;
using System.IO;
using System.Xml.Linq;
using WixToolset.Converters;
using WixToolset.Extensibility.Services;
using WixToolsetTest.Converters.Mocks;
using Xunit;

Expand Down Expand Up @@ -113,5 +115,32 @@ public void CanFormatWithNewLineAtEndOfFile()
Assert.Equal(expected, actual);
Assert.Equal(3, conversions);
}
[Fact]
public void CanSaveInPlace()
{
var parse = String.Join(Environment.NewLine,
"<?xml version='1.0' encoding='utf-8'?>",
"<Wix xmlns='http://wixtoolset.org/schemas/v4/wxs'>",
" <Fragment>",
" <Property Id='Prop'",
" Value='Val'>",
" </Property>",
" </Fragment>",
"</Wix>");

var expected = String.Join(Environment.NewLine,
"<Wix xmlns=\"http://wixtoolset.org/schemas/v4/wxs\">",
" <Fragment>",
" <Property Id=\"Prop\" Value=\"Val\" />",
" </Fragment>",
"</Wix>");
var tempFileName = Path.GetTempFileName();
File.WriteAllText(tempFileName, parse, System.Text.Encoding.UTF8);
var messaging = new MockMessaging();
var converter = new WixConverter(messaging, 4, null, null);
converter.FormatFile(tempFileName, true);
var actual = File.ReadAllText(tempFileName, System.Text.Encoding.UTF8);
Assert.Equal(expected, actual);
}
}
}

0 comments on commit 81af891

Please sign in to comment.