當前位置: 首頁>>代碼示例>>C#>>正文


C# GenericMockFactory.GetInstance方法代碼示例

本文整理匯總了C#中Microsoft.VsSDK.UnitTestLibrary.GenericMockFactory.GetInstance方法的典型用法代碼示例。如果您正苦於以下問題:C# GenericMockFactory.GetInstance方法的具體用法?C# GenericMockFactory.GetInstance怎麽用?C# GenericMockFactory.GetInstance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Microsoft.VsSDK.UnitTestLibrary.GenericMockFactory的用法示例。


在下文中一共展示了GenericMockFactory.GetInstance方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GetILocalRegistryInstance

 internal static BaseMock GetILocalRegistryInstance()
 {
     GenericMockFactory factory = new GenericMockFactory("ILocalRegistry", new Type[] { typeof(ILocalRegistry) });
     BaseMock mockObj = factory.GetInstance();
     string name = string.Format("{0}.{1}", typeof(ILocalRegistry).FullName, "CreateInstance");
     mockObj.AddMethodCallback(name, new EventHandler<CallbackArgs>(CreateInstanceCallBack));
     return mockObj;
 }
開發者ID:ZinkoSoft,項目名稱:NuSet,代碼行數:8,代碼來源:LocalRegistryServiceMock.cs

示例2: GetInstance

        internal static BaseMock GetInstance()
        {
            //Create a base mock
            GenericMockFactory factory = new GenericMockFactory("ILocalRegistry3", new Type[] { typeof(ILocalRegistry3) });
            BaseMock mockObj = factory.GetInstance();

            //Add method call back for GetLocalRegistryRoot
            string methodName = string.Format("{0}.{1}", typeof(ILocalRegistry3).FullName, "GetLocalRegistryRoot");
            mockObj.AddMethodCallback(methodName, new EventHandler<CallbackArgs>(GetLocalRegistryRootCallBack));

            return mockObj;
        }
開發者ID:ufosky-server,項目名稱:MultiversePlatform,代碼行數:12,代碼來源:MockILocalRegistry.cs

示例3: TestOutput

        public void TestOutput() {
            callbackExecuted = false;
            // As first create a service provider.
            using(OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices()) {
                // Create a mock object for the output window pane.
                GenericMockFactory mockWindowPaneFactory = new GenericMockFactory("MockOutputWindowPane", new Type[] { typeof(IVsOutputWindowPane) });
                BaseMock mockWindowPane = mockWindowPaneFactory.GetInstance();
                mockWindowPane.AddMethodCallback(string.Format("{0}.{1}", typeof(IVsOutputWindowPane).FullName, "OutputString"),
                                                 new EventHandler<CallbackArgs>(OutputWindowPaneCallback));

                // Now create the mock object for the output window.
                if(null == mockOutputWindowFactory) {
                    mockOutputWindowFactory = new GenericMockFactory("MockOutputWindow1", new Type[] { typeof(IVsOutputWindow) });
                }
                BaseMock mockOutputWindow = mockOutputWindowFactory.GetInstance();
                mockOutputWindow.AddMethodReturnValues(
                        string.Format("{0}.{1}", typeof(IVsOutputWindow).FullName, "GetPane"),
                        new object[] { 0, Guid.Empty, (IVsOutputWindowPane)mockWindowPane });

                // Add the output window to the services provided by the service provider.
                serviceProvider.AddService(typeof(SVsOutputWindow), mockOutputWindow, false);

                // Create an instance of the package and initialize it calling SetSite.
                SrcMLServicePackage package = new SrcMLServicePackage();
                int result = ((IVsPackage)package).SetSite(serviceProvider);
                Assert.IsTrue(Microsoft.VisualStudio.ErrorHandler.Succeeded(result), "SetSite failed.");

                // Now we can create an instance of the service
                SrcMLGlobalService service = new SrcMLGlobalService(package, extensionDirectory);

                service.GlobalServiceFunction();
                
                Assert.IsTrue(callbackExecuted, "OutputText not called.");
                ((IVsPackage)package).SetSite(null);
                ((IVsPackage)package).Close();
            }
        }
開發者ID:nkcsgexi,項目名稱:SrcML.NET,代碼行數:37,代碼來源:SrcMLGlobalServiceTests.cs

示例4: GetIVsTextLinesInstance

 private static BaseMock GetIVsTextLinesInstance()
 {
     GenericMockFactory factory = new GenericMockFactory("IVsTextLines", new Type[] { typeof(IVsTextLines), typeof(IObjectWithSite) });
     BaseMock mockObj = factory.GetInstance();
     return mockObj;
 }
開發者ID:ZinkoSoft,項目名稱:NuSet,代碼行數:6,代碼來源:LocalRegistryServiceMock.cs


注:本文中的Microsoft.VsSDK.UnitTestLibrary.GenericMockFactory.GetInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。