public void Clone_WhenIsDefaultVersionVaries_ReturnsEqualClone(bool expectedResult) { var packageSpec = new PackageSpec(); packageSpec.IsDefaultVersion = expectedResult; Assert.Equal(expectedResult, packageSpec.IsDefaultVersion); PackageSpec clone = packageSpec.Clone(); Assert.Equal(expectedResult, packageSpec.IsDefaultVersion); Assert.Equal(expectedResult, clone.IsDefaultVersion); Assert.True(packageSpec.Equals(clone)); }
public void AddProject_DoesNotClone(bool cpvmEnabled) { // Arrange var dependencyFoo = new LibraryDependency() { LibraryRange = new LibraryRange("foo", versionRange: cpvmEnabled ? null : VersionRange.Parse("1.0.0"), LibraryDependencyTarget.Package), }; var centralVersions = cpvmEnabled ? new List <CentralPackageVersion>() { new CentralPackageVersion("foo", VersionRange.Parse("1.0.0")) } : new List <CentralPackageVersion>(); var tfi = CreateTargetFrameworkInformation( new List <LibraryDependency>() { dependencyFoo }, centralVersions); var packageSpec = new PackageSpec(new List <TargetFrameworkInformation>() { tfi }); packageSpec.RestoreMetadata = new ProjectRestoreMetadata() { ProjectUniqueName = "a", CentralPackageVersionsEnabled = cpvmEnabled }; var dgSpec = new DependencyGraphSpec(); dgSpec.AddRestore("a"); dgSpec.AddProject(packageSpec); // Act var packageSpecFromDGSpec = dgSpec.GetProjectSpec("a"); // Assert Assert.True(packageSpec.Equals(packageSpecFromDGSpec)); }
public void CreateFromClosure_WhenReadOnlyIsFalse_ReturnsClonedClosure() { var expectedResult = new PackageSpec() { RestoreMetadata = new ProjectRestoreMetadata() }; IReadOnlyList <PackageSpec> closure = new[] { expectedResult }; var dgSpec = new DependencyGraphSpec(isReadOnly: false); DependencyGraphSpec newDgSpec = dgSpec.CreateFromClosure(PackageSpecName, closure); Assert.Collection( newDgSpec.Restore, actualResult => Assert.Equal(PackageSpecName, actualResult)); Assert.Collection( newDgSpec.Projects, actualResult => { Assert.True(expectedResult.Equals(actualResult)); Assert.NotSame(expectedResult, actualResult); }); }