Skip to content

Commit

Permalink
Verify NS.JSon is loaded appropriately in case of DisableAppDomain (#…
Browse files Browse the repository at this point in the history
…1740)

* reverting back app domain culture setup

* binding redirect for TW.Interfaces

* Run net451 test for Newtonsoft dependency
  • Loading branch information
mayankbansal018 committed Aug 21, 2018
1 parent ad34f47 commit 3cbab0b
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,25 @@ public class DisableAppdomainTests : AcceptanceTestBase
public void DisableAppdomainTest(RunnerInfo runnerInfo)
{
SetTestEnvironment(this.testEnvironment, runnerInfo);
RunTests(runnerInfo.RunnerFramework);

var diableAppdomainTest1 = testEnvironment.GetTestAsset("DisableAppdomainTest1.dll", "net451");
var diableAppdomainTest2 = testEnvironment.GetTestAsset("DisableAppdomainTest2.dll", "net451");

RunTests(runnerInfo.RunnerFramework, string.Format("{0}\" \"{1}", diableAppdomainTest1, diableAppdomainTest2), 2);
}

[TestMethod]
[NetFullTargetFrameworkDataSource]
public void NewtonSoftDependencyWithDisableAppdomainTest(RunnerInfo runnerInfo)
{
SetTestEnvironment(this.testEnvironment, runnerInfo);

var newtonSoftDependnecyTest = testEnvironment.GetTestAsset("NewtonSoftDependency.dll", "net451");

RunTests(runnerInfo.RunnerFramework, newtonSoftDependnecyTest, 1);
}

private void RunTests(string runnerFramework)
private void RunTests(string runnerFramework, string testAssembly, int passedTestCount)
{
if (runnerFramework.StartsWith("netcoreapp"))
{
Expand All @@ -36,13 +51,13 @@ private void RunTests(string runnerFramework)
var diableAppdomainTest1 = testEnvironment.GetTestAsset("DisableAppdomainTest1.dll", "net451");
var diableAppdomainTest2 = testEnvironment.GetTestAsset("DisableAppdomainTest2.dll", "net451");
var arguments = PrepareArguments(
string.Format("{0}\" \"{1}", diableAppdomainTest1, diableAppdomainTest2),
testAssembly,
string.Empty,
GetRunsettingsFilePath(runConfigurationDictionary),
this.FrameworkArgValue);

this.InvokeVsTest(arguments);
this.ValidateSummaryStatus(2, 0, 0);
this.ValidateSummaryStatus(passedTestCount, 0, 0);
}

private string GetRunsettingsFilePath(Dictionary<string, string> runConfigurationDictionary)
Expand Down
11 changes: 11 additions & 0 deletions test/TestAssets/NewtonSoftDependency/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
34 changes: 34 additions & 0 deletions test/TestAssets/NewtonSoftDependency/NewtonSoftDependency.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<!-- Package dependency versions -->
<PropertyGroup>
<TestPlatformRoot Condition="$(TestPlatformRoot) == ''">..\..\..\</TestPlatformRoot>
<TestProject>true</TestProject>
</PropertyGroup>
<!-- Imports Common TestAssets props. -->
<Import Project="..\..\..\scripts\build\TestAssets.props" />
<Import Project="..\..\..\scripts\build\TestPlatform.Dependencies.props" />
<PropertyGroup>
<AssemblyName>NewtonSoftDependency</AssemblyName>
<TargetFrameworks>net451</TargetFrameworks>
<OutputType Condition="$(NetCoreAppTargetFrameWork) == 'true' ">Exe</OutputType>
</PropertyGroup>


<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
<Reference Include="System" />
<Reference Include="System.Runtime" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="MSTest.TestAdapter" Version="$(MSTestAdapterVersion)" />
<PackageReference Include="MSTest.TestFramework" Version="$(MSTestAdapterVersion)" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
</ItemGroup>

<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
</Project>
26 changes: 26 additions & 0 deletions test/TestAssets/NewtonSoftDependency/UnitTest1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

namespace NewtonSoftDependency
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;

public class Account
{
public string Email { get; set; }
public bool Active { get; set; }
}

[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
string json = @"{'Email': 'john@example.com', 'Active': true}";

Account account = JsonConvert.DeserializeObject<Account>(json);

Assert.AreEqual("john@example.com", account.Email);
}
}
}
6 changes: 6 additions & 0 deletions test/TestAssets/TestAssets.sln/TestAssets.sln
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleManagedApp", "..\Con
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LegacySettingsUnitTestProject", "..\LegacySettingsUnitTestProject\LegacySettingsUnitTestProject.csproj", "{8C38E692-FBE3-41A4-A008-4CA79B203985}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NewtonSoftDependency", "..\NewtonSoftDependency\NewtonSoftDependency.csproj", "{79EDA259-5EA0-45F0-990A-F078427E198A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -129,6 +131,10 @@ Global
{8C38E692-FBE3-41A4-A008-4CA79B203985}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8C38E692-FBE3-41A4-A008-4CA79B203985}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8C38E692-FBE3-41A4-A008-4CA79B203985}.Release|Any CPU.Build.0 = Release|Any CPU
{79EDA259-5EA0-45F0-990A-F078427E198A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{79EDA259-5EA0-45F0-990A-F078427E198A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79EDA259-5EA0-45F0-990A-F078427E198A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79EDA259-5EA0-45F0-990A-F078427E198A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 3cbab0b

Please sign in to comment.