Esempio n. 1
0
        public void FromChanges_WithDependenciesChanges()
        {
            var catalogs        = IProjectCatalogSnapshotFactory.Create();
            var targetFramework = new TargetFramework("tfm1");
            var dependenciesByTargetFramework = CreateDependenciesByTargetFramework(catalogs, targetFramework);

            var previousSnapshot = new DependenciesSnapshot(
                activeTargetFramework: targetFramework,
                dependenciesByTargetFramework);

            var targetChanges = new DependenciesChangesBuilder();
            var model         = new TestDependencyModel
            {
                ProviderType = "Xxx",
                Id           = "dependency1"
            };

            targetChanges.Added(model);

            var snapshot = DependenciesSnapshot.FromChanges(
                previousSnapshot,
                targetFramework,
                targetChanges.TryBuildChanges() !,
                catalogs,
                targetFrameworks: ImmutableArray.Create(targetFramework),
                activeTargetFramework: targetFramework,
                ImmutableArray <IDependenciesSnapshotFilter> .Empty);

            Assert.NotSame(previousSnapshot, snapshot);
            Assert.Same(targetFramework, snapshot.ActiveTargetFramework);
            Assert.NotSame(previousSnapshot.DependenciesByTargetFramework, snapshot.DependenciesByTargetFramework);

            var(actualTfm, targetedSnapshot) = Assert.Single(snapshot.DependenciesByTargetFramework);
            Assert.Same(targetFramework, actualTfm);
            var dependency = Assert.Single(targetedSnapshot.Dependencies);

            Assert.Equal("dependency1", dependency.Id);
            Assert.Equal("Xxx", dependency.ProviderType);
        }
        public void FromChanges_NoChanges()
        {
            var catalogs         = IProjectCatalogSnapshotFactory.Create();
            var targetFramework  = new TargetFramework("tfm1");
            var targetFrameworks = ImmutableArray <TargetFramework> .Empty.Add(targetFramework);

            var dependenciesByTargetFramework = CreateDependenciesByTargetFramework(catalogs, targetFramework);

            var previousSnapshot = new DependenciesSnapshot(
                activeTargetFramework: targetFramework,
                dependenciesByTargetFramework);

            var snapshot = DependenciesSnapshot.FromChanges(
                previousSnapshot,
                targetFramework,
                changes: null,
                catalogs,
                targetFrameworks,
                activeTargetFramework: targetFramework,
                ImmutableArray <IDependenciesSnapshotFilter> .Empty);

            Assert.Same(previousSnapshot, snapshot);
        }