示例#1
0
        public void Synchronize_RemovesSubMember(string removed)
        {
            var memberDeclaration = CodeExplorerTestSetup.TestProjectOneDeclarations
                                    .Single(declaration => declaration.IdentifierName.Equals(removed)).ParentDeclaration;

            var declarations         = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(memberDeclaration.IdentifierName, out _).ToList();
            var subMemberDeclaration = declarations.Single(declaration => declaration.IdentifierName.Equals(removed));

            var updates = declarations.Except(new List <Declaration> {
                subMemberDeclaration
            }).ToList();

            var member = new CodeExplorerMemberViewModel(null, memberDeclaration, ref declarations);

            var expected = updates.Select(declaration => declaration.QualifiedName.ToString())
                           .OrderBy(_ => _)
                           .ToList();

            member.Synchronize(ref updates);

            var actual = member.GetAllChildDeclarations()
                         .Select(declaration => declaration.QualifiedName.ToString())
                         .OrderBy(_ => _);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
示例#2
0
        public void Synchronize_ClearsPassedDeclarationList_NoChanges(string name, DeclarationType type = DeclarationType.Member)
        {
            var declarations = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(name, out var memberDeclaration, type);
            var member       = new CodeExplorerMemberViewModel(null, memberDeclaration, ref declarations);

            var updates = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(name, out _, type);

            member.Synchronize(ref updates);

            Assert.AreEqual(0, updates.Count);
        }
示例#3
0
        public void Synchronize_DoesNotAlterDeclarationList_DifferentComponent(string name, string other, DeclarationType type = DeclarationType.Member)
        {
            var declarations = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(name, out var memberDeclaration, type);
            var member       = new CodeExplorerMemberViewModel(null, memberDeclaration, ref declarations);

            var updates = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(other, out _);

            member.Synchronize(ref updates);

            var expected = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(other, out _)
                           .Select(declaration => declaration.QualifiedName.ToString()).OrderBy(_ => _);
            var actual = updates.Select(declaration => declaration.QualifiedName.ToString()).OrderBy(_ => _);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }
示例#4
0
        public void Synchronize_SetsDeclarationNull_NoDeclarationsForComponent(string name, DeclarationType type = DeclarationType.Member)
        {
            var declarations = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(name, out var memberDeclaration, type);
            var member       = new CodeExplorerMemberViewModel(null, memberDeclaration, ref declarations);

            if (member.Declaration is null)
            {
                Assert.Inconclusive("Project declaration is null. Fix test setup and see why no other tests failed.");
            }

            var updates = new List <Declaration>();

            member.Synchronize(ref updates);

            Assert.IsNull(member.Declaration);
        }
示例#5
0
        public void Synchronize_PlacesAllTrackedDeclarations_NoChanges(string name, DeclarationType type = DeclarationType.Member)
        {
            var declarations = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(name, out var memberDeclaration, type);
            var member       = new CodeExplorerMemberViewModel(null, memberDeclaration, ref declarations);

            var updates = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(name, out _, type);

            member.Synchronize(ref updates);

            var expected = CodeExplorerTestSetup.TestProjectOneDeclarations.TestMemberDeclarations(name, out _, type)
                           .Select(declaration => declaration.QualifiedName.ToString()).OrderBy(_ => _);

            var actual = member.GetAllChildDeclarations()
                         .Select(declaration => declaration.QualifiedName.ToString())
                         .OrderBy(_ => _);

            Assert.IsTrue(expected.SequenceEqual(actual));
        }