public void PartialClasses_ClassIsNotPartial_ReturnsClass()
        {
            CreateClass("public class MyClass {}");

            global::EnvDTE.CodeElements partialClasses = codeClass.PartialClasses;

            CodeClass firstClass = partialClasses.FirstCodeClass2OrDefault();

            Assert.AreEqual(1, partialClasses.Count);
            Assert.AreEqual(codeClass, firstClass);
        }
Exemple #2
0
        public void CodeElements_OneClassWithNoNamespaceInProject_ReturnsOneCodeClassItem()
        {
            CreateCodeModel();
            AddClassToProjectContent(String.Empty, "TestClass");

            global::EnvDTE.CodeElements codeElements = codeModel.CodeElements;
            CodeClass2 codeClass = codeElements.FirstCodeClass2OrDefault();

            Assert.AreEqual(1, codeElements.Count);
            Assert.AreEqual("TestClass", codeClass.FullName);
        }
        public void Members_NamespaceHasOneClass_ReturnsOneClass()
        {
            CreateProjectContent();
            AddClassToProjectContent("Tests", "Tests.MyClass");
            CreateCodeNamespace("Tests");

            global::EnvDTE.CodeElements members = codeNamespace.Members;
            CodeClass2 codeClass = members.FirstCodeClass2OrDefault();

            Assert.AreEqual(1, members.Count);
            Assert.AreEqual("Tests.MyClass", codeClass.FullName);
        }
        public void BaseTypes_ClassBaseTypeIsSystemObject_ReturnsSystemObject()
        {
            CreateClass("public class MyClass {}");

            global::EnvDTE.CodeElements codeElements = codeClass.Bases;

            CodeClass2 baseClass = codeElements.FirstCodeClass2OrDefault();

            Assert.AreEqual(1, codeElements.Count);
            Assert.AreEqual("System.Object", baseClass.FullName);
            Assert.AreEqual("Object", baseClass.Name);
        }
        public void PartialClasses_ClassIsNotPartial_ReturnsClass()
        {
            CreateProjectContent();
            CreatePublicClass("MyNamespace.MyClass");
            CreateClass();

            global::EnvDTE.CodeElements partialClasses = codeClass.PartialClasses;
            CodeClass firstClass = partialClasses.FirstCodeClass2OrDefault();

            Assert.AreEqual(1, partialClasses.Count);
            Assert.AreEqual(codeClass, firstClass);
        }
        public void Members_NamespaceHasOneClass_ReturnsOneClass()
        {
            string code =
                "namespace Tests {\r\n" +
                "    public class MyClass {}\r\n" +
                "}";

            CreateCodeNamespace(code, "Tests");

            global::EnvDTE.CodeElements members = codeNamespace.Members;
            CodeClass2 codeClass = members.FirstCodeClass2OrDefault();

            Assert.AreEqual(1, members.Count);
            Assert.AreEqual("Tests.MyClass", codeClass.FullName);
        }