public void WithReplacedPackageSpecs_WithASinglePackageSpec_Succeeds() { // Arrange var packageSpecA = new PackageSpec { Title = "A", RestoreMetadata = new ProjectRestoreMetadata() { ProjectUniqueName = "a", CentralPackageVersionsEnabled = false } }; var packageSpecB = new PackageSpec { Title = "B", RestoreMetadata = new ProjectRestoreMetadata() { ProjectUniqueName = "BBB" } }; var packageSpecC = new PackageSpec { Title = "C", RestoreMetadata = new ProjectRestoreMetadata() { ProjectUniqueName = "CCC" } }; var dgSpec = new DependencyGraphSpec(); dgSpec.AddProject(packageSpecA); dgSpec.AddProject(packageSpecB); dgSpec.AddProject(packageSpecC); dgSpec.AddRestore(packageSpecA.RestoreMetadata.ProjectUniqueName); dgSpec.AddRestore(packageSpecB.RestoreMetadata.ProjectUniqueName); dgSpec.AddRestore(packageSpecC.RestoreMetadata.ProjectUniqueName); // Create an updated packageSpecA var updatedPackageA = packageSpecA.Clone(); updatedPackageA.RestoreMetadata.ConfigFilePaths.Add("/samplePath"); var newNugetPackageSpecs = new List <PackageSpec>() { updatedPackageA }; // Preconditions dgSpec.Projects.Should().HaveCount(3); dgSpec.Restore.Should().HaveCount(3); // Act var dgSpecWithReplacedPackageA = dgSpec.WithPackageSpecs(newNugetPackageSpecs); // Assert dgSpecWithReplacedPackageA.Projects.Should().HaveCount(3); dgSpecWithReplacedPackageA.Restore.Should().HaveCount(1); var packageSpecInAFromDgSpec = dgSpecWithReplacedPackageA.Projects.Single(e => e.Title.Equals("A")); packageSpecInAFromDgSpec.Should().Be(updatedPackageA); dgSpecWithReplacedPackageA.Restore.Single().Should().Be(updatedPackageA.RestoreMetadata.ProjectUniqueName); }