public void GrouppedByTargetTreeViewProvider_WhenEmptySnapshot_ShouldJustUpdateDependencyRootNode() { // Arrange var treeServices = new MockIDependenciesTreeServices(); var treeViewModelFactory = IMockDependenciesViewModelFactory.Implement(getDependenciesRootIcon: KnownMonikers.AboutBox); var project = UnconfiguredProjectFactory.Create(); var commonServices = IUnconfiguredProjectCommonServicesFactory.Create(project: project); var dependenciesRoot = new TestProjectTree { Caption = "MyDependencies", FilePath = "" }; var targets = new Dictionary <ITargetFramework, ITargetedDependenciesSnapshot>(); var snapshot = IDependenciesSnapshotFactory.Implement(targets: targets, hasUnresolvedDependency: false); // Act var provider = new GroupedByTargetTreeViewProvider(treeServices, treeViewModelFactory, commonServices); var resultTree = provider.BuildTree(dependenciesRoot, snapshot); // Assert var expectedFlatHierarchy = @"Caption=MyDependencies, FilePath=, IconHash=325248080, ExpandedIconHash=325248080, Rule=, IsProjectItem=False, CustomTag= "; Assert.Equal(expectedFlatHierarchy, ((TestProjectTree)resultTree).FlatHierarchy); Assert.Equal(KnownMonikers.AboutBox.ToProjectSystemType(), resultTree.Icon); Assert.Equal(KnownMonikers.AboutBox.ToProjectSystemType(), resultTree.ExpandedIcon); }
public void UnsupportedProjectsSnapshotFilter_WhenProjectSnapshotFoundAndNoUnresolvedDependencies_ShouldDoNothing() { // Arrange var targetFramework = ITargetFrameworkFactory.Implement(moniker: "tfm1"); var targetedSnapshot = ITargetedDependenciesSnapshotFactory.Implement(hasUnresolvedDependency: false); var targets = new Dictionary <ITargetFramework, ITargetedDependenciesSnapshot> { { targetFramework, targetedSnapshot } }; var snapshot = IDependenciesSnapshotFactory.Implement(targets: targets); var snapshotProvider = IDependenciesSnapshotProviderFactory.Implement(currentSnapshot: snapshot); var aggregateSnapshotProvider = IAggregateDependenciesSnapshotProviderFactory.Implement(getSnapshotProvider: snapshotProvider); var targetFrameworkProvider = ITargetFrameworkProviderFactory.Implement(getNearestFramework: targetFramework); var dependency = IDependencyFactory.Implement( topLevel: true, resolved: true, flags: DependencyTreeFlags.ProjectNodeFlags.Union(DependencyTreeFlags.ResolvedFlags), fullPath: @"c:\myproject1\project.csproj", targetFramework: targetFramework ); var filter = new UnsupportedProjectsSnapshotFilter(aggregateSnapshotProvider, targetFrameworkProvider); var resultDependency = filter.BeforeAdd( null, null, dependency.Object, null, null, null, out bool filterAnyChanges); dependency.VerifyAll(); }
public void UnsupportedProjectsSnapshotFilter_WhenProjectSnapshotFoundAndHasUnresolvedDependencies_ShouldMakeUnresolved() { // Arrange var targetFramework = ITargetFrameworkFactory.Implement(moniker: "tfm1"); var targetedSnapshot = ITargetedDependenciesSnapshotFactory.Implement(hasUnresolvedDependency: true); var targets = new Dictionary <ITargetFramework, ITargetedDependenciesSnapshot> { { targetFramework, targetedSnapshot } }; var snapshot = IDependenciesSnapshotFactory.Implement(targets: targets); var snapshotProvider = IDependenciesSnapshotProviderFactory.Implement(currentSnapshot: snapshot); var aggregateSnapshotProvider = IAggregateDependenciesSnapshotProviderFactory.Implement(getSnapshotProvider: snapshotProvider); var targetFrameworkProvider = ITargetFrameworkProviderFactory.Implement(getNearestFramework: targetFramework); var dependency = IDependencyFactory.Implement( topLevel: true, resolved: true, flags: DependencyTreeFlags.ProjectNodeFlags.Union(DependencyTreeFlags.ResolvedFlags), originalItemSpec: @"c:\myproject2\project.csproj", snapshot: targetedSnapshot, setPropertiesResolved: false, setPropertiesFlags: DependencyTreeFlags.ProjectNodeFlags.Union(DependencyTreeFlags.UnresolvedFlags)); var filter = new UnsupportedProjectsSnapshotFilter(aggregateSnapshotProvider, targetFrameworkProvider); var resultDependency = filter.BeforeAdd( projectPath: null, targetFramework: null, dependency: dependency.Object, worldBuilder: null, topLevelBuilder: null); dependency.VerifyAll(); }
public void BeforeAddOrUpdate_WhenProjectSnapshotFoundAndHasUnresolvedDependencies_ShouldMakeUnresolved() { const string projectPath = @"c:\project\project.csproj"; var targetFramework = ITargetFrameworkFactory.Implement(moniker: "tfm1"); var targetedSnapshot = ITargetedDependenciesSnapshotFactory.Implement(hasUnresolvedDependency: true); var targets = new Dictionary <ITargetFramework, ITargetedDependenciesSnapshot> { { targetFramework, targetedSnapshot } }; var snapshot = IDependenciesSnapshotFactory.Implement(targets: targets); var snapshotProvider = IDependenciesSnapshotProviderFactory.Implement(currentSnapshot: snapshot); var aggregateSnapshotProvider = new Mock <IAggregateDependenciesSnapshotProvider>(MockBehavior.Strict); aggregateSnapshotProvider.Setup(x => x.GetSnapshotProvider(projectPath)).Returns(snapshotProvider); var targetFrameworkProvider = ITargetFrameworkProviderFactory.Implement(getNearestFramework: targetFramework); var dependency = new TestDependency { Id = "dependency1", TopLevel = true, Resolved = true, Flags = DependencyTreeFlags.ProjectNodeFlags.Union(DependencyTreeFlags.ResolvedFlags), TargetFramework = targetFramework, FullPath = projectPath }; var worldBuilder = ImmutableDictionary <string, IDependency> .Empty.ToBuilder(); var context = new AddDependencyContext(worldBuilder); var filter = new UnsupportedProjectsSnapshotFilter(aggregateSnapshotProvider.Object, targetFrameworkProvider); filter.BeforeAddOrUpdate( null, null, dependency, null, null, context); // Accepts unresolved version var acceptedDependency = context.GetResult(filter); acceptedDependency.AssertEqualTo( dependency.ToUnresolved(ProjectReference.SchemaName)); // No other changes made Assert.False(context.Changed); aggregateSnapshotProvider.VerifyAll(); }
private IDependenciesSnapshot GetSnapshot(Dictionary <ITargetFramework, List <IDependency> > testData) { var catalogs = IProjectCatalogSnapshotFactory.Create(); var targets = new Dictionary <ITargetFramework, ITargetedDependenciesSnapshot>(); foreach (var kvp in testData) { var targetedSnapshot = ITargetedDependenciesSnapshotFactory.Implement( catalogs: catalogs, topLevelDependencies: kvp.Value, checkForUnresolvedDependencies: false, targetFramework: kvp.Key); targets.Add(kvp.Key, targetedSnapshot); } return(IDependenciesSnapshotFactory.Implement( targets: targets, hasUnresolvedDependency: false, activeTarget: testData.First().Key)); }