コード例 #1
0
        private static Declarations ExecuteGetDeclarations(string lineText, IScanner scanner, IServiceProvider site)
        {
            // Create the authoring scope.
            ParseRequest request = new ParseRequest(false);

            request.Reason = ParseReason.DisplayMemberList;
            AuthoringScope scope = ConsoleAuthoringScope.CreateScope(request);

            Assert.IsNotNull(scope);

            // Create a mock IConsoleText
            BaseMock mockConsoleText = MockFactories.ConsoleTextFactory.GetInstance();

            mockConsoleText.AddMethodReturnValues(
                string.Format("{0}.{1}", typeof(IConsoleText).FullName, "TextOfLine"),
                new object[] { lineText });
            ConsoleAuthoringScope.PythonConsole = mockConsoleText as IConsoleText;

            // Create a language service.
            TestLanguage language = new TestLanguage();

            // Set the scanner for this language.
            language.MockScanner           = scanner;
            ConsoleAuthoringScope.Language = language;

            // Set the site for the scope.
            ConsoleAuthoringScope.Site = site;

            // Create the view and token info to call the scope.
            IVsTextView view      = MockFactories.TextViewFactory.GetInstance() as IVsTextView;
            TokenInfo   tokenInfo = new TokenInfo();

            return(scope.GetDeclarations(view, 0, 0, tokenInfo, ParseReason.DisplayMemberList));
        }
コード例 #2
0
        public void GetDeclarationsNullView()
        {
            // Create the authoring scope.
            ParseRequest request = new ParseRequest(false);

            request.Reason = ParseReason.DisplayMemberList;
            AuthoringScope scope = ConsoleAuthoringScope.CreateScope(request);

            Assert.IsNotNull(scope);

            // Create a mock IConsoleText
            BaseMock mockConsoleText = MockFactories.ConsoleTextFactory.GetInstance();

            mockConsoleText.AddMethodReturnValues(
                string.Format("{0}.{1}", typeof(IConsoleText).FullName, "TextOfLine"),
                new object[] { "dte." });
            ConsoleAuthoringScope.PythonConsole = mockConsoleText as IConsoleText;

            // Creeate a TokenInfo
            TokenInfo tokenInfo = new TokenInfo();

            // Call GetDeclarations.
            bool exceptionThrown = false;

            try
            {
                scope.GetDeclarations(null, 0, 0, tokenInfo, ParseReason.DisplayMemberList);
            }
            catch (ArgumentNullException)
            {
                exceptionThrown = true;
            }
            catch (System.Reflection.TargetInvocationException e)
            {
                ArgumentNullException inner = e.InnerException as ArgumentNullException;
                if (null != inner)
                {
                    exceptionThrown = true;
                }
            }
            Assert.IsTrue(exceptionThrown);
        }
コード例 #3
0
        public void GetDeclarationsNullText()
        {
            // Create a mock IConsoleText that will return null on TextOfLine.
            IConsoleText consoleText = MockFactories.ConsoleTextFactory.GetInstance() as IConsoleText;

            ConsoleAuthoringScope.PythonConsole = consoleText;

            // Create the authoring scope.
            ParseRequest request = new ParseRequest(false);

            request.Reason = ParseReason.DisplayMemberList;
            AuthoringScope scope = ConsoleAuthoringScope.CreateScope(request);

            Assert.IsNotNull(scope);

            // Create object with not null value for the parameters.
            IVsTextView view      = MockFactories.TextViewFactory.GetInstance() as IVsTextView;
            TokenInfo   tokenInfo = new TokenInfo();

            // Call GetDeclarations.
            Declarations declarations = scope.GetDeclarations(view, 0, 0, tokenInfo, ParseReason.DisplayMemberList);

            Assert.IsTrue(0 == declarations.GetCount());
        }