public void DeclarationsGetDisplayText() { Declarations declarations = CreateDeclarations(); // Check that it is possible to add and get back a single string. AddMethod(declarations, "Test1"); Assert.IsTrue("Test1" == declarations.GetDisplayText(0)); // Check that GetDisplayText can find the strings on a list that is more // than one element long. AddMethod(declarations, "Test2"); Assert.IsTrue("Test2" == declarations.GetDisplayText(1)); Assert.IsTrue("Test1" == declarations.GetDisplayText(0)); }
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)); } }