public void BeforeAddOrUpdate_WhenDependencyNotRecognized_ShouldDoNothing() { var acceptable = new TestDependency { Id = "dependency1", TopLevel = true, Resolved = true, Flags = DependencyTreeFlags.ProjectNodeFlags }; AssertNoChange(new TestDependency { ClonePropertiesFrom = acceptable, TopLevel = false }); AssertNoChange(new TestDependency { ClonePropertiesFrom = acceptable, Resolved = false }); AssertNoChange(new TestDependency { ClonePropertiesFrom = acceptable, Flags = ProjectTreeFlags.Empty }); AssertNoChange(new TestDependency { ClonePropertiesFrom = acceptable, Flags = DependencyTreeFlags.ProjectNodeFlags.Union(DependencyTreeFlags.SharedProjectFlags) }); return; void AssertNoChange(IDependency dependency) { var aggregateSnapshotProvider = IAggregateDependenciesSnapshotProviderFactory.Create(); var worldBuilder = new[] { dependency }.ToImmutableDictionary(d => d.Id).ToBuilder(); var context = new AddDependencyContext(worldBuilder); var filter = new UnsupportedProjectsSnapshotFilter(aggregateSnapshotProvider); filter.BeforeAddOrUpdate( null, dependency, null, null, context); // Accepts unchanged dependency Assert.Same(dependency, context.GetResult(filter)); // No other changes made Assert.False(context.Changed); } }
static void AssertNoChange(IDependency dependency) { var aggregateSnapshotProvider = IAggregateDependenciesSnapshotProviderFactory.Create(); var worldBuilder = new[] { dependency }.ToImmutableDictionary(d => d.Id).ToBuilder(); var context = new AddDependencyContext(worldBuilder); var filter = new UnresolvedProjectReferenceSnapshotFilter(aggregateSnapshotProvider); filter.BeforeAddOrUpdate( null !, dependency, null !, null, context); // Accepts unchanged dependency Assert.Same(dependency, context.GetResult(filter)); // No other changes made Assert.False(context.Changed); }
public void UnsupportedProjectsSnapshotFilter_WhenDependencyNotRecognized_ShouldDoNothing() { var aggregateSnapshotProvider = IAggregateDependenciesSnapshotProviderFactory.Create(); var targetFrameworkProvider = ITargetFrameworkProviderFactory.Create(); var dependency = IDependencyFactory.Implement( id: "mydependency1", topLevel: false); var topLevelDependency = IDependencyFactory.Implement( id: "mydependency2", topLevel: true, resolved: false); var topLevelResolvedDependency = IDependencyFactory.Implement( id: "mydependency3", topLevel: true, resolved: true, flags: ProjectTreeFlags.Empty); var topLevelResolvedSharedProjectDependency = IDependencyFactory.Implement( id: "mydependency4", topLevel: true, resolved: true, flags: DependencyTreeFlags.ProjectNodeFlags.Union(DependencyTreeFlags.SharedProjectFlags)); var worldBuilder = new Dictionary <string, IDependency>() { { dependency.Object.Id, dependency.Object }, { topLevelDependency.Object.Id, topLevelDependency.Object }, { topLevelResolvedDependency.Object.Id, topLevelResolvedDependency.Object }, { topLevelResolvedSharedProjectDependency.Object.Id, topLevelResolvedSharedProjectDependency.Object }, }.ToImmutableDictionary().ToBuilder(); var filter = new UnsupportedProjectsSnapshotFilter(aggregateSnapshotProvider, targetFrameworkProvider); var resultDependency = filter.BeforeAdd( null, null, dependency.Object, worldBuilder, null, null, out bool filterAnyChanges); resultDependency = filter.BeforeAdd( null, null, topLevelDependency.Object, worldBuilder, null, null, out bool filterAnyChanges2); resultDependency = filter.BeforeAdd( null, null, topLevelResolvedDependency.Object, worldBuilder, null, null, out bool filterAnyChanges3); resultDependency = filter.BeforeAdd( null, null, topLevelResolvedSharedProjectDependency.Object, worldBuilder, null, null, out bool filterAnyChanges4); dependency.VerifyAll(); topLevelDependency.VerifyAll(); }