public void CreateEmpty()
        {
            const string projectPath = @"c:\somefolder\someproject\a.csproj";

            var snapshot = DependenciesSnapshot.CreateEmpty(projectPath);

            Assert.Same(projectPath, snapshot.ProjectPath);
            Assert.Same(TargetFramework.Empty, snapshot.ActiveTargetFramework);
            Assert.Empty(snapshot.DependenciesByTargetFramework);
            Assert.False(snapshot.HasReachableVisibleUnresolvedDependency);
            Assert.Null(snapshot.FindDependency("foo"));
        }
        public void SetTargets_SameMembers_SameActive()
        {
            const string projectPath = @"c:\somefolder\someproject\a.csproj";

            ITargetFramework tfm1 = new TargetFramework("tfm1");
            ITargetFramework tfm2 = new TargetFramework("tfm2");

            var before = DependenciesSnapshot.CreateEmpty(projectPath)
                         .SetTargets(ImmutableArray.Create(tfm1, tfm2), tfm1);

            var after = before.SetTargets(ImmutableArray.Create(tfm1, tfm2), tfm1);

            Assert.Same(before, after);
        }
        public void SetTargets_FromEmpty()
        {
            const string projectPath = @"c:\somefolder\someproject\a.csproj";

            ITargetFramework tfm1 = new TargetFramework("tfm1");
            ITargetFramework tfm2 = new TargetFramework("tfm2");

            var snapshot = DependenciesSnapshot.CreateEmpty(projectPath)
                           .SetTargets(ImmutableArray.Create(tfm1, tfm2), tfm1);

            Assert.Same(tfm1, snapshot.ActiveTargetFramework);
            Assert.Equal(2, snapshot.DependenciesByTargetFramework.Count);
            Assert.True(snapshot.DependenciesByTargetFramework.ContainsKey(tfm1));
            Assert.True(snapshot.DependenciesByTargetFramework.ContainsKey(tfm2));
        }
Exemplo n.º 4
0
        public void SetTargets_SameMembers_DifferentActive()
        {
            const string projectPath = @"c:\somefolder\someproject\a.csproj";

            ITargetFramework tfm1 = new TargetFramework("tfm1");
            ITargetFramework tfm2 = new TargetFramework("tfm2");

            var before = DependenciesSnapshot.CreateEmpty(projectPath)
                         .SetTargets(new[] { tfm1, tfm2 }.ToImmutableArray(), tfm1);

            var after = before.SetTargets(new[] { tfm1, tfm2 }.ToImmutableArray(), tfm2);

            Assert.Same(tfm2, after.ActiveTargetFramework);
            Assert.Same(before.DependenciesByTargetFramework, after.DependenciesByTargetFramework);
        }
        public void SetTargets_DifferentMembers_DifferentActive()
        {
            const string projectPath = @"c:\somefolder\someproject\a.csproj";

            ITargetFramework tfm1 = new TargetFramework("tfm1");
            ITargetFramework tfm2 = new TargetFramework("tfm2");
            ITargetFramework tfm3 = new TargetFramework("tfm3");

            var before = DependenciesSnapshot.CreateEmpty(projectPath)
                         .SetTargets(ImmutableArray.Create(tfm1, tfm2), tfm1);

            var after = before.SetTargets(ImmutableArray.Create(tfm2, tfm3), tfm3);

            Assert.Same(tfm3, after.ActiveTargetFramework);
            Assert.Equal(2, after.DependenciesByTargetFramework.Count);
            Assert.True(after.DependenciesByTargetFramework.ContainsKey(tfm2));
            Assert.True(after.DependenciesByTargetFramework.ContainsKey(tfm3));
            Assert.Same(before.DependenciesByTargetFramework[tfm2], after.DependenciesByTargetFramework[tfm2]);
        }