2016-02-26 18:54:17 +00:00
|
|
|
using System.Linq;
|
2016-02-23 10:34:27 +00:00
|
|
|
using Microsoft.DotNet.ProjectModel.Graph;
|
|
|
|
using Microsoft.DotNet.ProjectModel.Resolution;
|
2016-02-26 18:54:17 +00:00
|
|
|
using Microsoft.DotNet.TestFramework;
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
2016-02-23 10:34:27 +00:00
|
|
|
using NuGet.Frameworks;
|
|
|
|
using NuGet.Versioning;
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.ProjectModel.Tests
|
|
|
|
{
|
2016-02-26 18:54:17 +00:00
|
|
|
public class PackageDependencyProviderTests : TestBase
|
2016-02-23 10:34:27 +00:00
|
|
|
{
|
|
|
|
[Fact]
|
|
|
|
public void GetDescriptionShouldNotModifyTarget()
|
|
|
|
{
|
|
|
|
var provider = new PackageDependencyProvider("/foo/packages", new FrameworkReferenceResolver("/foo/references"));
|
|
|
|
var package = new LockFilePackageLibrary();
|
|
|
|
package.Name = "Something";
|
|
|
|
package.Version = NuGetVersion.Parse("1.0.0");
|
|
|
|
package.Files.Add("lib/dotnet/_._");
|
|
|
|
package.Files.Add("runtimes/any/native/Microsoft.CSharp.CurrentVersion.targets");
|
|
|
|
|
|
|
|
var target = new LockFileTargetLibrary();
|
|
|
|
target.Name = "Something";
|
|
|
|
target.Version = package.Version;
|
|
|
|
|
|
|
|
target.RuntimeAssemblies.Add("lib/dotnet/_._");
|
|
|
|
target.CompileTimeAssemblies.Add("lib/dotnet/_._");
|
|
|
|
target.NativeLibraries.Add("runtimes/any/native/Microsoft.CSharp.CurrentVersion.targets");
|
|
|
|
|
|
|
|
var p1 = provider.GetDescription(NuGetFramework.Parse("dnxcore50"), package, target);
|
|
|
|
var p2 = provider.GetDescription(NuGetFramework.Parse("dnxcore50"), package, target);
|
|
|
|
|
|
|
|
Assert.True(p1.Compatible);
|
|
|
|
Assert.True(p2.Compatible);
|
|
|
|
|
|
|
|
Assert.Empty(p1.CompileTimeAssemblies);
|
|
|
|
Assert.Empty(p1.RuntimeAssemblies);
|
2016-02-26 18:54:17 +00:00
|
|
|
|
2016-02-23 10:34:27 +00:00
|
|
|
Assert.Empty(p2.CompileTimeAssemblies);
|
|
|
|
Assert.Empty(p2.RuntimeAssemblies);
|
|
|
|
}
|
2016-02-26 18:54:17 +00:00
|
|
|
|
|
|
|
[Fact]
|
|
|
|
public void SingleMicrosoftCSharpReference()
|
|
|
|
{
|
|
|
|
// https://github.com/dotnet/cli/issues/1602
|
|
|
|
var instance = TestAssetsManager.CreateTestInstance("TestMicrosoftCSharpReference")
|
|
|
|
.WithLockFiles();
|
|
|
|
|
|
|
|
var context = new ProjectContextBuilder().WithProjectDirectory(instance.TestRoot)
|
|
|
|
.WithTargetFramework("dnx451")
|
|
|
|
.Build();
|
|
|
|
|
|
|
|
Assert.Equal(4, context.RootProject.Dependencies.Count());
|
|
|
|
}
|
2016-02-23 10:34:27 +00:00
|
|
|
}
|
|
|
|
}
|