dotnet-installer/test/Microsoft.DotNet.ProjectModel.Tests/PackageDependencyProviderTests.cs
David Fowler dec4a0627f Fix asset copy on publish when lock file instance is shared
- Don't mutate the library target when making a package description.

#1528
2016-02-23 02:34:56 -08:00

44 lines
1.6 KiB
C#

using System;
using System.IO;
using Microsoft.DotNet.ProjectModel.Graph;
using Microsoft.DotNet.ProjectModel.Resolution;
using NuGet.Frameworks;
using NuGet.Versioning;
using Xunit;
namespace Microsoft.DotNet.ProjectModel.Tests
{
public class PackageDependencyProviderTests
{
[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);
Assert.Empty(p2.CompileTimeAssemblies);
Assert.Empty(p2.RuntimeAssemblies);
}
}
}