From 6a678a0d05b6685a57ea3b580c333598e0b702ed Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 7 Apr 2016 21:32:19 -0700 Subject: [PATCH] Add unit test for duplicate system references --- .../TestMicrosoftCSharpReference/project.json | 2 +- .../TestMscorlibReference/project.json | 11 ++++++++++ .../TestSystemCoreReference/project.json | 11 ++++++++++ .../TestSystemReference/project.json | 11 ++++++++++ .../PackageDependencyProviderTests.cs | 22 ++++++++++++++----- 5 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 TestAssets/TestProjects/TestMscorlibReference/project.json create mode 100644 TestAssets/TestProjects/TestSystemCoreReference/project.json create mode 100644 TestAssets/TestProjects/TestSystemReference/project.json diff --git a/TestAssets/TestProjects/TestMicrosoftCSharpReference/project.json b/TestAssets/TestProjects/TestMicrosoftCSharpReference/project.json index 7cd6e10e5..ddff17b0a 100644 --- a/TestAssets/TestProjects/TestMicrosoftCSharpReference/project.json +++ b/TestAssets/TestProjects/TestMicrosoftCSharpReference/project.json @@ -8,7 +8,7 @@ "NETStandard.Library": "1.5.0-rc2-24008" } }, - "dnx451": { + "net451": { "dependencies": { "Microsoft.CSharp": "4.0.1-rc2-24008" } diff --git a/TestAssets/TestProjects/TestMscorlibReference/project.json b/TestAssets/TestProjects/TestMscorlibReference/project.json new file mode 100644 index 000000000..7c6958e2a --- /dev/null +++ b/TestAssets/TestProjects/TestMscorlibReference/project.json @@ -0,0 +1,11 @@ +{ + "version": "1.0.0-*", + "dependencies": {}, + "frameworks": { + "net451": { + "frameworkAssemblies": { + "mscorlib": "" + } + } + } +} \ No newline at end of file diff --git a/TestAssets/TestProjects/TestSystemCoreReference/project.json b/TestAssets/TestProjects/TestSystemCoreReference/project.json new file mode 100644 index 000000000..0f97ea62c --- /dev/null +++ b/TestAssets/TestProjects/TestSystemCoreReference/project.json @@ -0,0 +1,11 @@ +{ + "version": "1.0.0-*", + "dependencies": {}, + "frameworks": { + "net451": { + "frameworkAssemblies": { + "System": "" + } + } + } +} \ No newline at end of file diff --git a/TestAssets/TestProjects/TestSystemReference/project.json b/TestAssets/TestProjects/TestSystemReference/project.json new file mode 100644 index 000000000..2b3f5bcb7 --- /dev/null +++ b/TestAssets/TestProjects/TestSystemReference/project.json @@ -0,0 +1,11 @@ +{ + "version": "1.0.0-*", + "dependencies": {}, + "frameworks": { + "net451": { + "frameworkAssemblies": { + "System.Core": "" + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs b/test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs index 50d3aab3d..eba50a521 100644 --- a/test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs +++ b/test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs @@ -42,15 +42,25 @@ namespace Microsoft.DotNet.ProjectModel.Tests Assert.Empty(p2.RuntimeAssemblies); } - [Fact] - public void SingleMicrosoftCSharpReference() + [Theory] + [InlineDataAttribute("TestMscorlibReference", true)] + [InlineDataAttribute("TestMscorlibReference", false)] + [InlineDataAttribute("TestMicrosoftCSharpReference", true)] + [InlineDataAttribute("TestMicrosoftCSharpReference", false)] + [InlineDataAttribute("TestSystemReference", true)] + [InlineDataAttribute("TestSystemReference", false)] + [InlineDataAttribute("TestSystemCoreReference", true)] + [InlineDataAttribute("TestSystemCoreReference", false)] + public void TestDuplicateDefaultDesktopReferences(string sampleName, bool withLockFile) { - // https://github.com/dotnet/cli/issues/1602 - var instance = TestAssetsManager.CreateTestInstance("TestMicrosoftCSharpReference") - .WithLockFiles(); + var instance = TestAssetsManager.CreateTestInstance(sampleName); + if (withLockFile) + { + instance = instance.WithLockFiles(); + } var context = new ProjectContextBuilder().WithProjectDirectory(instance.TestRoot) - .WithTargetFramework("dnx451") + .WithTargetFramework("net451") .Build(); Assert.Equal(4, context.RootProject.Dependencies.Count());