Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Evangelink committed Dec 5, 2023
1 parent 5317f4f commit 88b95f3
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<NetStandardNetFrameworkHolder>net48</NetStandardNetFrameworkHolder>
<TargetFrameworks>net462;$(NetStandardNetFrameworkHolder);netcoreapp3.1;net6.0;$(WinUiMinimum)</TargetFrameworks>
<IsNetCoreApp Condition=" '$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == '$(WinUiMinimum)' ">true</IsNetCoreApp>
<UseAssemblyVersion14>true</UseAssemblyVersion14>
</PropertyGroup>

<!-- Properties specific to WinUI -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ namespace MSTestAdapter.PlatformServices.UnitTests.Utilities;

public class XmlUtilitiesTests : TestContainer
{
private readonly TestableXmlUtilities _testableXmlUtilities;

public XmlUtilitiesTests()
{
_testableXmlUtilities = new TestableXmlUtilities();
}
private readonly TestableXmlUtilities _testableXmlUtilities = new();

public void AddAssemblyRedirectionShouldAddRedirectionToAnEmptyXml()
{
Expand All @@ -35,8 +30,19 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAnEmptyXml()
assemblyName.Version.ToString());

// Assert.
var expectedXml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"MSTestAdapter.PlatformServices.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
var expectedXml = """
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MSTestAdapter.PlatformServices.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var doc = new XmlDocument();
doc.LoadXml(expectedXml);
byte[] expectedConfigBytes = null;
Expand Down Expand Up @@ -64,8 +70,19 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAnEmptyConfig()
assemblyName.Version.ToString());

// Assert.
var expectedXml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"MSTestAdapter.PlatformServices.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
var expectedXml = """
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MSTestAdapter.PlatformServices.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var doc = new XmlDocument();
doc.LoadXml(expectedXml);
byte[] expectedConfigBytes = null;
Expand Down Expand Up @@ -95,8 +112,19 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAConfigWithARuntimeSecti
assemblyName.Version.ToString());

// Assert.
var expectedXml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"MSTestAdapter.PlatformServices.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
var expectedXml = """
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MSTestAdapter.PlatformServices.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var doc = new XmlDocument();
#pragma warning disable CA3075 // Insecure DTD processing in XML
doc.LoadXml(expectedXml);
Expand All @@ -114,7 +142,19 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAConfigWithARuntimeSecti

public void AddAssemblyRedirectionShouldAddRedirectionToAConfigWithRedirections()
{
_testableXmlUtilities.ConfigXml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"Random.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
_testableXmlUtilities.ConfigXml = """
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Random.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var assemblyName = Assembly.GetExecutingAssembly().GetName();

var configBytes = _testableXmlUtilities.AddAssemblyRedirection(
Expand All @@ -124,8 +164,23 @@ public void AddAssemblyRedirectionShouldAddRedirectionToAConfigWithRedirections(
assemblyName.Version.ToString());

// Assert.
var expectedXml =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><configuration><runtime><assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\"><dependentAssembly><assemblyIdentity name=\"Random.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly><dependentAssembly><assemblyIdentity name=\"MSTestAdapter.PlatformServices.UnitTests\" publicKeyToken=\"b03f5f7f11d50a3a\" culture=\"neutral\" /><bindingRedirect oldVersion=\"99.99.99.99\" newVersion=\"14.0.0.0\" /></dependentAssembly></assemblyBinding></runtime></configuration>";
var expectedXml = """
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Random.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="MSTestAdapter.PlatformServices.UnitTests" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="99.99.99.99" newVersion="14.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
""";
var doc = new XmlDocument();
doc.LoadXml(expectedXml);
byte[] expectedConfigBytes = null;
Expand Down

0 comments on commit 88b95f3

Please sign in to comment.