public void NuGetDependenciesSubTreeProvider_DependenciesSnapshot_AddDependency() { var provider = new TestableNuGetDependenciesSubTreeProvider(); var snapshotJson = @" { ""NodesCache"": [ ], ""DependenciesWorld"": [ { ""ItemSpec"": ""tfm1/Package2/1.0.0"", ""Properties"": { ""Name"": ""Package2"", ""Version"": ""1.0.0"", ""Type"": ""Package"", ""Path"": ""SomePath"", ""Resolved"": ""true"", ""Dependencies"": ""Package3/2.0.0;NotExistentPackage/2.0.0;Assembly1/1.0.0;FrameworkAssembly1/4.0.0;SomeUnknown/1.0.0"" } }, { ""ItemSpec"": ""tfm1/Package3/2.0.0"", ""Properties"": { ""Name"": ""Package3"", ""Version"": ""2.0.0"", ""Type"": ""Package"", ""Path"": ""SomePath"", ""Resolved"": ""true"", ""Dependencies"": """" } }, { ""ItemSpec"": ""tfm1/Assembly1/1.0.0"", ""Properties"": { ""Name"": ""Assembly1"", ""Version"": ""1.0.0"", ""Type"": ""Assembly"", ""Path"": ""SomePath"", ""Resolved"": ""true"", ""Dependencies"": """" } }, { ""ItemSpec"": ""tfm1/FrameworkAssembly1/4.0.0"", ""Properties"": { ""Name"": ""FrameworkAssembly1"", ""Version"": ""4.0.0"", ""Type"": ""FrameworkAssembly"", ""Path"": ""SomePath"", ""Resolved"": ""true"", ""Dependencies"": """" } }, { ""ItemSpec"": ""tfm1/SomeUnknown/1.0.0"", ""Properties"": { ""Name"": ""SomeUnknown"", ""Version"": ""1.0.0"", ""Type"": ""Xxxx"", ""Path"": ""SomePath"", ""Resolved"": ""true"", ""Dependencies"": """" } } ] }"; provider.LoadSnapshotFromJson(snapshotJson); // Add a dependency var sampleDependencyProperties = new Dictionary <string, string> { { "Name", "Package2" }, { "Version", "3.0.0" } }.ToImmutableDictionary(); provider.AddDependencyToSnapshot("tfm1/Package4/1.0.0", sampleDependencyProperties); var currentSnapshotDependencies = provider.GetCurrentSnapshotDependenciesWorld(); Assert.True(currentSnapshotDependencies.Contains("tfm1/Package4/1.0.0")); // Add a target provider.AddDependencyToSnapshot("tfm1", sampleDependencyProperties); var currentSnapshotTargets = provider.GetCurrentSnapshotTargets(); Assert.True(currentSnapshotTargets.Contains("tfm1")); }