Пример #1
0
        public void SetTypeForProperty_Success()
        {
            string file = @"C:\Users\ACER\Desktop\luanvan\started\TestBuildArchitecture\DataTest\SetTypeForProperty_Success_Dont_Inheritance.cs";

            workSpace.InitOrUpdateParserTreeOfFile(file, GetFileContent(file));
            workSpace.RunDefinedPhraseAllfile();
            workSpace.RunResolvePhraseAllFile();

            GetPropertyIdentityContext visitor = new GetPropertyIdentityContext();

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

            var symbol = visitor.IdentityContext.Symbol as FieldSymbol;

            Assert.AreEqual("int", symbol.GetSymbolType().GetName());
        }
Пример #2
0
        public void CreatePropertySymbol_For_Class_And_Struct_Success(string cSharpFilePath)
        {
            workSpace.InitOrUpdateParserTreeOfFile(cSharpFilePath, GetFileContent(cSharpFilePath));
            workSpace.RunDefinedPhraseAllfile();

            GetPropertyIdentityContext visitor = new GetPropertyIdentityContext();

            visitor.Visit(workSpace._parserRuleContextOfFile[cSharpFilePath]);
            var propertyIdentityContext = visitor.IdentityContext;

            //symbol and scope is setted for context
            Assert.IsInstanceOf(typeof(FieldSymbol), propertyIdentityContext.Symbol);
            var testName = TestContext.CurrentContext.Test.Name;

            if (testName == "PropertyInClass")
            {
                Assert.IsInstanceOf(typeof(ClassSymbol), propertyIdentityContext.Scope);
            }
            else
            {
                Assert.IsInstanceOf(typeof(StructSymbol), propertyIdentityContext.Scope);
            }

            //check property of property symbol
            var symbol = propertyIdentityContext.Symbol as FieldSymbol;

            Assert.AreEqual(propertyIdentityContext.GetText(), symbol.GetName());
            Assert.AreSame(propertyIdentityContext, symbol.DefNode);

            //find symbol in scope
            Assert.AreSame(symbol, propertyIdentityContext.Scope.Resolve(symbol.GetName()));
            if (testName == "PropertyInClass")
            {
                Assert.AreEqual("global.TestBuildArchitecture.DataTest.Test.Property", symbol.GetFullyQualifiedName("."));
            }
            else
            {
                Assert.AreEqual("global.TestBuildArchitecture.DataTest.StructTest.Property", symbol.GetFullyQualifiedName("."));
            }
        }