本文整理汇总了C#中Microsoft.VsSDK.UnitTestLibrary.GenericMockFactory类的典型用法代码示例。如果您正苦于以下问题:C# GenericMockFactory类的具体用法?C# GenericMockFactory怎么用?C# GenericMockFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GenericMockFactory类属于Microsoft.VsSDK.UnitTestLibrary命名空间,在下文中一共展示了GenericMockFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetSite
public void SetSite()
{
// Create the package
var package = new PowerToolsCommandsPackage() as IVsPackage;
Assert.IsNotNull(package, "The object does not implement IVsPackage");
// Create a basic service provider
var serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices();
var activityLogMock =
new GenericMockFactory(
"MockVsActivityLog",
new[] { typeof(Microsoft.VisualStudio.Shell.Interop.IVsActivityLog) }
).GetInstance();
serviceProvider.AddService(
typeof(Microsoft.VisualStudio.Shell.Interop.SVsActivityLog),
activityLogMock,
true);
// Site the package
//Assert.AreEqual(0, package.SetSite(serviceProvider), "SetSite did not return S_OK");
// Unsite the package
Assert.AreEqual(0, package.SetSite(null), "SetSite(null) did not return S_OK");
}
示例2: GetPBInstance
/// <summary>
/// Returns a property bag that does not implement any methods
/// </summary>
/// <returns></returns>
internal static BaseMock GetPBInstance()
{
if (PBFactory == null)
PBFactory = new GenericMockFactory("PropertyBag", new Type[] { typeof(IPropertyBag) });
BaseMock pb = PBFactory.GetInstance();
return pb;
}
示例3: GetBaseMonSelInstance
/// <summary>
/// Returns a monitor selection object that does not implement any methods
/// </summary>
/// <returns></returns>
internal static BaseMock GetBaseMonSelInstance()
{
if (MonSelFactory == null)
MonSelFactory = new GenericMockFactory("MonitorSelection", new Type[] { typeof(IVsMonitorSelection), typeof (IVsMultiItemSelect) });
BaseMock pb = MonSelFactory.GetInstance();
return pb;
}
示例4: GetRegisterEditorsInstance
/// <summary>
/// Returns an SVsRegisterEditors service that does not implement any methods
/// </summary>
/// <returns></returns>
internal static BaseMock GetRegisterEditorsInstance()
{
if (registerEditorFactory == null)
registerEditorFactory = new GenericMockFactory("SVsRegisterEditors", new Type[] { typeof(IVsRegisterEditors) });
BaseMock registerEditor = registerEditorFactory.GetInstance();
return registerEditor;
}
示例5: TestOutputNoPane
public void TestOutputNoPane() {
// Create an instance of the package and initialize it so that the GetService
// will succeed, but the GetPane will fail.
// As first create a service provider.
using(OleServiceProvider serviceProvider = OleServiceProvider.CreateOleServiceProviderWithBasicServices()) {
// Now create the mock object for the output window.
if(null == mockOutputWindowFactory) {
mockOutputWindowFactory = new GenericMockFactory("MockOutputWindow", new Type[] { typeof(IVsOutputWindow) });
}
BaseMock mockBase = mockOutputWindowFactory.GetInstance() as BaseMock;
mockBase.AddMethodReturnValues(string.Format("{0}.{1}", typeof(IVsOutputWindow).FullName, "GetPane"),
new object[] { -1, Guid.Empty, null });
// Add the output window to the services provided by the service provider.
serviceProvider.AddService(typeof(SVsOutputWindow), mockBase, 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
SetUpSrcMLServiceExtensionDirectory();
SrcMLGlobalService service = new SrcMLGlobalService(package, extensionDirectory);
service.GlobalServiceFunction();
((IVsPackage)package).SetSite(null);
((IVsPackage)package).Close();
}
}
示例6: GetBaseRegisterScciProvider
/// <summary>
/// Return a IVsRegisterScciProvider without any special implementation
/// </summary>
/// <returns></returns>
internal static IVsRegisterScciProvider GetBaseRegisterScciProvider()
{
if (registerScciProviderFactory == null)
registerScciProviderFactory = new GenericMockFactory("RegisterScciProvider", new Type[] { typeof(IVsRegisterScciProvider) });
IVsRegisterScciProvider registerProvider = (IVsRegisterScciProvider)registerScciProviderFactory.GetInstance();
return registerProvider;
}
示例7: GetBaseFrame
/// <summary>
/// Return a IVsWindowFrame without any special implementation
/// </summary>
/// <returns></returns>
internal static IVsWindowFrame GetBaseFrame()
{
if (frameFactory == null)
frameFactory = new GenericMockFactory("WindowFrame", new Type[] { typeof(IVsWindowFrame) });
IVsWindowFrame frame = (IVsWindowFrame)frameFactory.GetInstance();
return frame;
}
示例8: GetUiShellInstance
/// <summary>
/// Returns an IVsUiShell that does not implement any methods
/// </summary>
/// <returns></returns>
internal static BaseMock GetUiShellInstance()
{
if (uiShellFactory == null)
uiShellFactory = new GenericMockFactory("UiShell", new Type[] { typeof(IVsUIShell) });
BaseMock uiShell = uiShellFactory.GetInstance();
return uiShell;
}
示例9: GetShellInstance
/// <summary>
/// Returns an IVsShell that does not implement any methods
/// </summary>
/// <returns></returns>
internal static BaseMock GetShellInstance()
{
if (ShellFactory == null)
ShellFactory = new GenericMockFactory("Shell", new Type[] { typeof(IVsShell) });
BaseMock Shell = ShellFactory.GetInstance();
return Shell;
}
示例10: 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;
}
示例11: GetUiShellInstance
internal static BaseMock GetUiShellInstance()
{
if (_uiShellFactory == null)
{
_uiShellFactory = new GenericMockFactory("UiShell", new[] { typeof(IVsUIShell), typeof(IVsUIShellOpenDocument) });
}
var uiShell = _uiShellFactory.GetInstance();
return uiShell;
}
示例12: GetSolutionBuildManagerInstance
/// <summary>
/// Returns a SVsSolutionBuildManager that does not implement any methods
/// </summary>
/// <returns></returns>
internal static BaseMock GetSolutionBuildManagerInstance()
{
if(solutionBuildManager == null)
{
solutionBuildManager = new GenericMockFactory("SolutionBuildManager", new Type[] { typeof(IVsSolutionBuildManager2), typeof(IVsSolutionBuildManager3) });
}
BaseMock buildManager = solutionBuildManager.GetInstance();
return buildManager;
}
示例13: GetUserSettingsFactoryInstance
/// <summary>
/// Returns an IVSUserSettings that does not implement any methods.
/// </summary>
/// <returns></returns>
internal static BaseMock GetUserSettingsFactoryInstance()
{
if (userSettingsFactory == null)
{
userSettingsFactory = new GenericMockFactory("MockUserSettings", new Type[] { typeof(IVsUserSettings) });
}
BaseMock userSettings = userSettingsFactory.GetInstance();
return userSettings;
}
示例14: GetRegisterProjectInstance
/// <summary>
/// Gets an IVsRegisterProject service mock object
/// </summary>
/// <returns></returns>
internal static BaseMock GetRegisterProjectInstance()
{
if(null == registerProjectFactory)
{
registerProjectFactory = new GenericMockFactory("MockRegisterProject", new Type[] { typeof(IVsRegisterProjectTypes) });
}
BaseMock mock = registerProjectFactory.GetInstance();
return mock;
}
示例15: GetIVsFileChangeEx
/// <summary>
/// Gets an IVsFileChnageEx service mock object
/// </summary>
/// <returns></returns>
internal static BaseMock GetIVsFileChangeEx()
{
if (null == fileChangeEx)
{
fileChangeEx = new GenericMockFactory("MockIVsFileChangeEx", new Type[] { typeof(IVsFileChangeEx) });
}
BaseMock mock = fileChangeEx.GetInstance();
return mock;
}