本文整理匯總了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;
}
示例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;
}
示例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();
}
}
示例4: GetIVsTextLinesInstance
private static BaseMock GetIVsTextLinesInstance()
{
GenericMockFactory factory = new GenericMockFactory("IVsTextLines", new Type[] { typeof(IVsTextLines), typeof(IObjectWithSite) });
BaseMock mockObj = factory.GetInstance();
return mockObj;
}