public void Name_ExpressionIsImportFollowedByName_MatchesNameAfterImport()
		{
			PythonImportExpression expression = new PythonImportExpression("import abc");
			PythonImportModuleResolveResult result = new PythonImportModuleResolveResult(expression);
			string expectedName = "abc";
			Assert.AreEqual(expectedName, result.Name);
		}
        public void NamePropertyMatchesTextPassedToConstructor()
        {
            PythonImportExpression          expression = new PythonImportExpression("import abc");
            PythonImportModuleResolveResult result     = new PythonImportModuleResolveResult(expression);

            Assert.AreEqual("abc", result.Name);
        }
        public void Name_ExpressionIsImportFollowedByName_MatchesNameAfterImport()
        {
            PythonImportExpression          expression = new PythonImportExpression("import abc");
            PythonImportModuleResolveResult result     = new PythonImportModuleResolveResult(expression);
            string expectedName = "abc";

            Assert.AreEqual(expectedName, result.Name);
        }
        public void GetCompletionDataReturnsStandardMathPythonModuleWhenImportNameIsEmptyString()
        {
            PythonImportExpression          expression = new PythonImportExpression(String.Empty);
            PythonImportModuleResolveResult result     = new PythonImportModuleResolveResult(expression);
            MockProjectContent projectContent          = new MockProjectContent();

            Assert.Contains("math", result.GetCompletionData(projectContent));
        }
		public void Init()
		{
			string code = "from datetime import";
			importExpression = new PythonImportExpression(code);
			resolveResult = new PythonImportModuleResolveResult(importExpression);
			
			projectContent = new MockProjectContent();
		}
        public void Init()
        {
            string code = "from math import cos";

            importExpression = new PythonImportExpression(code);
            resolveResult    = new PythonImportModuleResolveResult(importExpression);

            projectContent = new MockProjectContent();
        }
        public void ClonedPythonModuleResultReturnsSameCompletionItems()
        {
            PythonImportExpression          expression = new PythonImportExpression(String.Empty);
            PythonImportModuleResolveResult result     = new PythonImportModuleResolveResult(expression);
            ResolveResult      clonedResult            = result.Clone();
            MockProjectContent projectContent          = new MockProjectContent();

            Assert.Contains("math", clonedResult.GetCompletionData(projectContent));
        }
		public void Init()
		{
			string code = "from math import";
			importExpression = new PythonImportExpression(code);
			resolveResult = new PythonImportModuleResolveResult(importExpression);
			
			projectContent = new MockProjectContent();
			completionItems = resolveResult.GetCompletionData(projectContent);
		}
		public void GetCompletionData_WhenImportNameIsEmptyString_ReturnsStandardMathPythonModule()
		{
			PythonImportExpression expression = new PythonImportExpression(String.Empty);
			PythonImportModuleResolveResult result = new PythonImportModuleResolveResult(expression);
			MockProjectContent projectContent = new MockProjectContent();
			
			List<ICompletionEntry> completionItems = result.GetCompletionData(projectContent);
			NamespaceEntry mathNamespaceCompletionItem = new NamespaceEntry("math");
			Assert.Contains(mathNamespaceCompletionItem, completionItems);
		}
示例#10
0
        public void Init()
        {
            string code = "from math import";

            importExpression = new PythonImportExpression(code);
            resolveResult    = new PythonImportModuleResolveResult(importExpression);

            projectContent  = new MockProjectContent();
            completionItems = resolveResult.GetCompletionData(projectContent);
        }
		public void GetCompletionData_ClonedPythonModuleResult_ReturnsSameCompletionItems()
		{
			PythonImportExpression expression = new PythonImportExpression(String.Empty);
			PythonImportModuleResolveResult result = new PythonImportModuleResolveResult(expression);
			ResolveResult clonedResult = result.Clone();
			MockProjectContent projectContent = new MockProjectContent();
			
			List<ICompletionEntry> completionItems = clonedResult.GetCompletionData(projectContent);
			NamespaceEntry mathNamespaceCompletionItem = new NamespaceEntry("math");
			Assert.Contains(mathNamespaceCompletionItem, completionItems);
		}
        public void GetCompletionData_WhenImportNameIsEmptyString_ReturnsStandardMathPythonModule()
        {
            PythonImportExpression          expression = new PythonImportExpression(String.Empty);
            PythonImportModuleResolveResult result     = new PythonImportModuleResolveResult(expression);
            MockProjectContent projectContent          = new MockProjectContent();

            List <ICompletionEntry> completionItems             = result.GetCompletionData(projectContent);
            NamespaceEntry          mathNamespaceCompletionItem = new NamespaceEntry("math");

            Assert.Contains(mathNamespaceCompletionItem, completionItems);
        }
        public void GetCompletionData_ClonedPythonModuleResult_ReturnsSameCompletionItems()
        {
            PythonImportExpression          expression = new PythonImportExpression(String.Empty);
            PythonImportModuleResolveResult result     = new PythonImportModuleResolveResult(expression);
            ResolveResult      clonedResult            = result.Clone();
            MockProjectContent projectContent          = new MockProjectContent();

            List <ICompletionEntry> completionItems             = clonedResult.GetCompletionData(projectContent);
            NamespaceEntry          mathNamespaceCompletionItem = new NamespaceEntry("math");

            Assert.Contains(mathNamespaceCompletionItem, completionItems);
        }
		public void Init()
		{
			string code = "from System import Console";
			importExpression = new PythonImportExpression(code);
			resolveResult = new PythonImportModuleResolveResult(importExpression);
			
			projectContent = new MockProjectContent();
			DefaultCompilationUnit unit = new DefaultCompilationUnit(projectContent);
			DefaultClass c = new DefaultClass(unit, "Test");
			List<ICompletionEntry> namespaceItems = new List<ICompletionEntry>();
			namespaceItems.Add(c);
			projectContent.AddExistingNamespaceContents("System", namespaceItems);
		}
		public void SetUpFixture()
		{
			resolver = new PythonResolver();
			
			mockProjectContent = new MockProjectContent();
			DefaultCompilationUnit cu = new DefaultCompilationUnit(mockProjectContent);
			cu.FileName = @"C:\Projects\Test\test.py";
			ParseInformation parseInfo = new ParseInformation(cu);
					
			string python = "from System";
			PythonExpressionFinder finder = new PythonExpressionFinder();
			ExpressionResult expressionResult = finder.FindExpression(python, python.Length);
			resolveResult = resolver.Resolve(expressionResult, parseInfo, python) as PythonImportModuleResolveResult;
		}
        public void Init()
        {
            string code = "from System import Console";

            importExpression = new PythonImportExpression(code);
            resolveResult    = new PythonImportModuleResolveResult(importExpression);

            projectContent = new MockProjectContent();
            DefaultCompilationUnit  unit           = new DefaultCompilationUnit(projectContent);
            DefaultClass            c              = new DefaultClass(unit, "Test");
            List <ICompletionEntry> namespaceItems = new List <ICompletionEntry>();

            namespaceItems.Add(c);
            projectContent.AddExistingNamespaceContents("System", namespaceItems);
        }
示例#17
0
        public void SetUpFixture()
        {
            resolver = new PythonResolver();

            mockProjectContent = new MockProjectContent();
            DefaultCompilationUnit cu = new DefaultCompilationUnit(mockProjectContent);

            cu.FileName = @"C:\Projects\Test\test.py";
            ParseInformation parseInfo = new ParseInformation(cu);

            string python = "from System";
            PythonExpressionFinder finder           = new PythonExpressionFinder();
            ExpressionResult       expressionResult = finder.FindExpression(python, python.Length);

            resolveResult = resolver.Resolve(expressionResult, parseInfo, python) as PythonImportModuleResolveResult;
        }
        public void NamespaceName()
        {
            PythonImportModuleResolveResult importResolveResult = (PythonImportModuleResolveResult)resolveResult;

            Assert.AreEqual("System", importResolveResult.Name);
        }