Пример #1
0
        public void TFromChanges_AddingToEmpty()
        {
            const string projectPath     = @"c:\somefolder\someproject\a.csproj";
            var          targetFramework = ITargetFrameworkFactory.Implement("tfm1");

            var catalogs         = IProjectCatalogSnapshotFactory.Create();
            var previousSnapshot = TargetedDependenciesSnapshot.CreateEmpty(projectPath, targetFramework, catalogs);

            var resolvedTop = IDependencyModelFactory.FromJson(@"
                {
                    ""ProviderType"": ""Xxx"",
                    ""Id"": ""dependency1"",
                    ""Name"": ""Dependency1"",
                    ""Caption"": ""Dependency1"",
                    ""Resolved"": ""true"",
                    ""TopLevel"": ""true""
                }",
                                                               icon: KnownMonikers.Uninstall,
                                                               expandedIcon: KnownMonikers.Uninstall);

            var unresolved = IDependencyModelFactory.FromJson(@"
                {
                    ""ProviderType"": ""Xxx"",
                    ""Id"": ""dependency2"",
                    ""Name"": ""Dependency2"",
                    ""Caption"": ""Dependency2"",
                    ""Resolved"": ""false"",
                    ""TopLevel"": ""false""
                }",
                                                              icon: KnownMonikers.Uninstall,
                                                              expandedIcon: KnownMonikers.Uninstall);

            var changes = new DependenciesChanges();

            changes.IncludeAddedChange(resolvedTop);
            changes.IncludeAddedChange(unresolved);

            const string updatedProjectPath = "updatedProjectPath";

            var snapshot = TargetedDependenciesSnapshot.FromChanges(
                updatedProjectPath,
                previousSnapshot,
                changes,
                catalogs,
                Array.Empty <IDependenciesSnapshotFilter>(),
                new Dictionary <string, IProjectDependenciesSubTreeProvider>(),
                null);

            Assert.NotSame(previousSnapshot, snapshot);
            Assert.Same(updatedProjectPath, snapshot.ProjectPath);
            Assert.Same(catalogs, snapshot.Catalogs);
            Assert.True(snapshot.HasUnresolvedDependency);
            AssertEx.CollectionLength(snapshot.DependenciesWorld, 2);
            AssertEx.CollectionLength(snapshot.TopLevelDependencies, 1);
            Assert.True(resolvedTop.Matches(snapshot.TopLevelDependencies.Single(), targetFramework));
            Assert.True(resolvedTop.Matches(snapshot.DependenciesWorld["tfm1\\Xxx\\dependency1"], targetFramework));
            Assert.True(unresolved.Matches(snapshot.DependenciesWorld["tfm1\\Xxx\\dependency2"], targetFramework));
        }
Пример #2
0
        public void TCreateEmpty()
        {
            const string projectPath     = @"c:\somefolder\someproject\a.csproj";
            var          targetFramework = ITargetFrameworkFactory.Implement("tfm1");
            var          catalogs        = IProjectCatalogSnapshotFactory.Create();

            var snapshot = TargetedDependenciesSnapshot.CreateEmpty(projectPath, targetFramework, catalogs);

            Assert.Same(projectPath, snapshot.ProjectPath);
            Assert.Same(catalogs, snapshot.Catalogs);
            Assert.Same(targetFramework, snapshot.TargetFramework);
            Assert.False(snapshot.HasUnresolvedDependency);
            Assert.Empty(snapshot.DependenciesWorld);
            Assert.Empty(snapshot.TopLevelDependencies);
            Assert.False(snapshot.CheckForUnresolvedDependencies("foo"));
            Assert.Empty(snapshot.GetDependencyChildren(new TestDependency()));
        }
Пример #3
0
        public void TFromChanges_Empty()
        {
            const string projectPath      = @"c:\somefolder\someproject\a.csproj";
            var          targetFramework  = ITargetFrameworkFactory.Implement("tfm1");
            var          catalogs         = IProjectCatalogSnapshotFactory.Create();
            var          previousSnapshot = TargetedDependenciesSnapshot.CreateEmpty(projectPath, targetFramework, catalogs);

            var changes = new DependenciesChanges();

            var snapshot = TargetedDependenciesSnapshot.FromChanges(
                projectPath,
                previousSnapshot,
                changes,
                catalogs,
                Array.Empty <IDependenciesSnapshotFilter>(),
                new Dictionary <string, IProjectDependenciesSubTreeProvider>(),
                null);

            Assert.Same(previousSnapshot, snapshot);
        }