Exemple #1
0
        public void EnterClass_definition_Create_Class_Symbol_Success(string cSharpFilePath)
        {
            workSpace.InitOrUpdateParserTreeOfFile(cSharpFilePath, GetFileContent(cSharpFilePath));
            workSpace.RunDefinedPhraseAllfile();

            GetClass_definitionVisitor classDefinition = new GetClass_definitionVisitor();

            classDefinition.Visit(workSpace._parserRuleContextOfFile[cSharpFilePath]);

            var classIdentity = classDefinition.ClassIdentity;

            Assert.IsInstanceOf(typeof(IdentifierContext), classIdentity);

            //check exist symbol and scope
            Assert.IsInstanceOf(typeof(ClassSymbol), classIdentity.Symbol);
            Assert.IsInstanceOf(typeof(ClassSymbol), classIdentity.Scope);

            //check property of symbol
            var symbol = classIdentity.Symbol as ClassSymbol;

            Assert.AreEqual(classIdentity.GetText(), symbol.GetName());
            Assert.AreNotEqual(null, symbol.DefNode);
            Assert.AreEqual("global.TestBuildArchitecture.DataTest.Test", symbol.GetFullyQualifiedName("."));

            //check property of scope
            Assert.AreNotEqual(null, symbol.Resolve(symbol.GetName()));
        }
Exemple #2
0
        public void GetNamespaceName_IsTrue(string cSharpFilePath)
        {
            workSpace.InitOrUpdateParserTreeOfFile(cSharpFilePath, GetFileContent(cSharpFilePath));
            workSpace.RunSemeticAnalysis(cSharpFilePath);

            GetClass_definitionVisitor visitor = new GetClass_definitionVisitor();

            visitor.Visit(workSpace._parserRuleContextOfFile[cSharpFilePath]);

            var classContext  = visitor.ClassIdentity;
            var scope         = classContext.Scope;
            var namespaceName = scope.GetNamespaceName();

            if (TestContext.CurrentContext.Test.Name == "GetNamespaceName_IsTrue_1")
            {
                Assert.AreEqual("TestA.NameSpace", namespaceName);
            }
            else
            {
                Assert.AreEqual("TestA", namespaceName);
            }
        }