public void DeclarationsCountTest() { Declarations declarations = CreateDeclarations(); Assert.IsTrue(0 == declarations.GetCount()); AddMethod(declarations, "Test1"); Assert.IsTrue(1 == declarations.GetCount()); AddMethod(declarations, "Test2"); Assert.IsTrue(2 == declarations.GetCount()); }
public void OneTokenNoTrigger() { using (OleServiceProvider provider = new OleServiceProvider()) { ResetScopeState(); // Create a mock engine provider. BaseMock mockEngineProvider = MockFactories.EngineProviderFactory.GetInstance(); // Create a mock engine. BaseMock mockEngine = MockFactories.EngineFactory.GetInstance(); // Set this engine as the one returned from the GetSharedEngine of the engine provider. mockEngineProvider.AddMethodReturnValues( string.Format("{0}.{1}", typeof(IPythonEngineProvider), "GetSharedEngine"), new object[] { (IEngine)mockEngine }); // Add the engine provider to the list of the services. provider.AddService(typeof(IPythonEngineProvider), mockEngineProvider, false); // Create the scanner for this test. BaseMock scannerMock = MockFactories.ScannerFactory.GetInstance(); scannerMock["Iteration"] = 0; TokenInfo token = new TokenInfo(); token.StartIndex = 0; token.EndIndex = 3; token.Trigger = TokenTriggers.None; scannerMock["Tokens"] = new TokenInfo[] { token }; scannerMock.AddMethodCallback( string.Format("{0}.{1}", typeof(IScanner).FullName, "ScanTokenAndProvideInfoAboutIt"), new EventHandler <CallbackArgs>(StandardScannerCallback)); Declarations declarations = ExecuteGetDeclarations("dte.", scannerMock as IScanner, provider); Assert.IsTrue(0 == declarations.GetCount()); Assert.IsTrue(0 == mockEngine.TotalCallsAllFunctions()); } }
public void GetDeclarationsTwoResults() { using (OleServiceProvider provider = new OleServiceProvider()) { ResetScopeState(); // Create a mock engine provider. BaseMock mockEngineProvider = MockFactories.EngineProviderFactory.GetInstance(); // Create a mock engine. BaseMock mockEngine = MockFactories.EngineFactory.GetInstance(); string evaluateMethodName = string.Format("{0}.{1}", typeof(IEngine).FullName, "Evaluate"); mockEngine.AddMethodCallback( evaluateMethodName, new EventHandler <CallbackArgs>(EvaluateCallback)); // Set this engine as the one returned from the GetSharedEngine of the engine provider. mockEngineProvider.AddMethodReturnValues( string.Format("{0}.{1}", typeof(IPythonEngineProvider), "GetSharedEngine"), new object[] { (IEngine)mockEngine }); // Add the engine provider to the list of the services. provider.AddService(typeof(IPythonEngineProvider), mockEngineProvider, false); // Create the scanner for this test. BaseMock scannerMock = MockFactories.ScannerFactory.GetInstance(); scannerMock["Iteration"] = 0; TokenInfo[] tokens = new TokenInfo[2]; tokens[0] = new TokenInfo(); tokens[0].StartIndex = 0; tokens[0].EndIndex = 7; tokens[0].Trigger = TokenTriggers.None; tokens[1] = new TokenInfo(); tokens[1].StartIndex = 8; tokens[1].EndIndex = 8; tokens[1].Trigger = TokenTriggers.MemberSelect; scannerMock["Tokens"] = tokens; scannerMock.AddMethodCallback( string.Format("{0}.{1}", typeof(IScanner).FullName, "ScanTokenAndProvideInfoAboutIt"), new EventHandler <CallbackArgs>(StandardScannerCallback)); Declarations declarations = ExecuteGetDeclarations("variable.", scannerMock as IScanner, provider); Assert.IsTrue(2 == declarations.GetCount()); Assert.IsTrue(1 == mockEngine.FunctionCalls(evaluateMethodName)); Assert.IsTrue("Method 1" == declarations.GetDisplayText(0)); Assert.IsTrue("Method 2" == declarations.GetDisplayText(1)); } }
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()); }
public virtual void Init( IVsTextView textView, Declarations decls, bool completeWord ){ Close(); this.textView = textView; this.decls = decls; this.completeWord = completeWord; //check if we have members long count = decls.GetCount(); if (count <= 0) return ; //initialise and refresh UpdateCompletionFlags flags = UpdateCompletionFlags.UCS_NAMESCHANGED; if (this.completeWord) flags |= UpdateCompletionFlags.UCS_COMPLETEWORD; textView.UpdateCompletionStatus(this, (uint)flags); this.displayed = true; }