• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# UnitTestLibrary.GenericMockFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Microsoft.VsSDK.UnitTestLibrary.GenericMockFactory的典型用法代码示例。如果您正苦于以下问题:C# GenericMockFactory类的具体用法?C# GenericMockFactory怎么用?C# GenericMockFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



GenericMockFactory类属于Microsoft.VsSDK.UnitTestLibrary命名空间,在下文中一共展示了GenericMockFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
        }
开发者ID:v2m,项目名称:FSharpVSPowerTools,代码行数:26,代码来源:PackageTest.cs


示例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;
 }
开发者ID:rsweeney21,项目名称:VisualGit,代码行数:11,代码来源:MockPropertyBag.cs


示例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;
 }
开发者ID:rsweeney21,项目名称:VisualGit,代码行数:11,代码来源:MockIVsMonitorSelection.cs


示例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;
 }
开发者ID:Graham-Pedersen,项目名称:IronPlot,代码行数:11,代码来源:RegisterEditorsServiceMock.cs


示例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();
            }
        }
开发者ID:nkcsgexi,项目名称:SrcML.NET,代码行数:31,代码来源:SrcMLGlobalServiceTests.cs


示例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;
 }
开发者ID:jradxl,项目名称:All-In-One-Framework-VS2012,代码行数:11,代码来源:MockRegisterScciProvider.cs


示例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;
 }
开发者ID:CodeMangler,项目名称:vsgit,代码行数:11,代码来源:WindowFrameMock.cs


示例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;
 }
开发者ID:rsweeney21,项目名称:VisualGit,代码行数:11,代码来源:MockUiShellProvider.cs


示例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;
 }
开发者ID:rsweeney21,项目名称:VisualGit,代码行数:11,代码来源:MockShellProvider.cs


示例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;
 }
开发者ID:ZinkoSoft,项目名称:NuSet,代码行数:8,代码来源:LocalRegistryServiceMock.cs


示例11: GetUiShellInstance

 internal static BaseMock GetUiShellInstance()
 {
     if (_uiShellFactory == null)
     {
         _uiShellFactory = new GenericMockFactory("UiShell", new[] { typeof(IVsUIShell), typeof(IVsUIShellOpenDocument) });
     }
     var uiShell = _uiShellFactory.GetInstance();
     return uiShell;
 }
开发者ID:duncansmart,项目名称:TortoiseGitToolbar,代码行数:9,代码来源:UIShellServiceMock.cs


示例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;
 }
开发者ID:mimura1133,项目名称:uo_mpfproj14,代码行数:13,代码来源:MockServicesProvider.cs


示例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;
 }
开发者ID:jradxl,项目名称:All-In-One-Framework-VS2012,代码行数:13,代码来源:MockServiceProvider.cs


示例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;
        }
开发者ID:ldematte,项目名称:BlenXVSP,代码行数:14,代码来源:MockServicesProvider.cs


示例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;
        }
开发者ID:tunnelvisionlabs,项目名称:MPFProj10,代码行数:14,代码来源:MockServicesProvider.cs


示例16: GetBaseFrame

        /// <summary>
        /// Return a IVsWindowFrame without any special implementation
        /// </summary>
        internal static IVsWindowFrame GetBaseFrame()
        {
            if (_frameFactory == null)
            {
                _frameFactory = new GenericMockFactory("WindowFrame", new[] { typeof(IVsWindowFrame), typeof(IVsWindowFrame2) });
            }

            var frame = (IVsWindowFrame)_frameFactory.GetInstance();
            return frame;
        }
开发者ID:reima,项目名称:codemaid,代码行数:13,代码来源:WindowFrameMock.cs


示例17: CreateOleServiceProviderWithBasicServices

		/// <summary>
		/// Use to create an IOleServiceProvider with the basic services required by
		/// MS.VS.Shell.Package.SetSite() base implementation
		/// </summary>
		/// <returns></returns>
		public static OleServiceProvider CreateOleServiceProviderWithBasicServices()
		{
			// Create the service provider
			OleServiceProvider serviceProvider = new OleServiceProvider();

			// Add IProfferService
			// Create the type only once, then create as many instances as required.
			if (profferServiceFactory == null)
			{
				profferServiceFactory = new GenericMockFactory("MockProfferService", new Type[] { typeof(IProfferService) });
			}
			BaseMock mockObject = profferServiceFactory.GetInstance();
			mockObject.AddMethodCallback(string.Format(CultureInfo.InvariantCulture, "{0}.{1}", typeof(IProfferService).FullName, "ProfferService"),
                                         new EventHandler<CallbackArgs>(ProfferServiceCallback));
			serviceProvider.AddService(typeof(SProfferService), mockObject, false);

			// Add IUIHostLocale
			if (hostLocaleFactory == null)
			{
				hostLocaleFactory = new GenericMockFactory("MockUiHostLocale", new Type[] { typeof(IUIHostLocale), typeof(IUIHostLocale2) });
			}
			mockObject = hostLocaleFactory.GetInstance();
			// Set the return value to 0 (S_OK) and the out parameter to 1033 (enu).
			mockObject.AddMethodReturnValues(string.Format(CultureInfo.InvariantCulture,
                                                      "{0}.{1}",
                                                      typeof(IUIHostLocale).FullName,
                                                      "GetUILocale"), 
                                             new object[] { 0, (uint)1033 });
			serviceProvider.AddService(typeof(SUIHostLocale), mockObject, false);

			// Add IVsResourceManager
			if (resourceManagerFactory == null)
			{
				resourceManagerFactory = new GenericMockFactory("MockResourceManager", new Type[] { typeof(IVsResourceManager) });
			}
			mockObject = resourceManagerFactory.GetInstance();
			mockObject.AddMethodReturnValues(string.Format(CultureInfo.InvariantCulture,
                                                      "{0}.{1}",
                                                      typeof(IVsResourceManager).FullName,
                                                      "LoadResourceString"), 
                                             new object[] { 0, Guid.Empty, 0, null, "Mock Localized String" });
			serviceProvider.AddService(typeof(SVsResourceManager), mockObject, false);

            if(activityLogFactory == null)
            {
                activityLogFactory = new GenericMockFactory("Microsoft.VisualStudio.Shell.Interop.SVsActivityLog", new Type[] { typeof(SVsActivityLog), typeof(IVsActivityLog) });
            }
            BaseMock fakeActivityLog = activityLogFactory.GetInstance();
            serviceProvider.AddService(typeof(SVsActivityLog), fakeActivityLog, false);


            return serviceProvider;
		}
开发者ID:NikitaEgorov,项目名称:Visual-StyleCop,代码行数:58,代码来源:OleServiceProvider.cs


示例18: 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


示例19: AddMockActivityLogService

        private void AddMockActivityLogService(OleServiceProvider provider)
        {
            BaseMock activityLogMock =
                new GenericMockFactory(
                    "MockVsActivityLog",
                    new[] { typeof(Microsoft.VisualStudio.Shell.Interop.IVsActivityLog) }
                ).GetInstance();

            provider.AddService(
                typeof(Microsoft.VisualStudio.Shell.Interop.SVsActivityLog),
                activityLogMock,
                true
            );
        }
开发者ID:ChaosCabbage,项目名称:plotter-service-for-visual-studio,代码行数:14,代码来源:PackageTest.cs


示例20: GetQueryEditQuerySaveInstance

        /// <summary>
        /// Gets an IVsQueryEditQuerySave2 mock object which implements QuerySaveFile and QueryEditFiles methods
        /// </summary>
        /// <returns></returns>
        internal static BaseMock GetQueryEditQuerySaveInstance()
        {
            if(null == qeqsFactory)
            {
                qeqsFactory = new GenericMockFactory("QueryEditQuerySave", new Type[] { typeof(IVsQueryEditQuerySave2) });
            }

            BaseMock qeqs = qeqsFactory.GetInstance();

            string name = string.Format("{0}.{1}", typeof(IVsQueryEditQuerySave2).FullName, "QuerySaveFile");
            qeqs.AddMethodCallback(name, new EventHandler<CallbackArgs>(QuerySaveFileCallBack));
            name = string.Format("{0}.{1}", typeof(IVsQueryEditQuerySave2).FullName, "QueryEditFiles");
            qeqs.AddMethodCallback(name, new EventHandler<CallbackArgs>(QueryEditFilesCallBack));
            return qeqs;
        }
开发者ID:ldematte,项目名称:BlenXVSP,代码行数:19,代码来源:MockServicesProvider.cs



注:本文中的Microsoft.VsSDK.UnitTestLibrary.GenericMockFactory类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Administration.ServerManager类代码示例发布时间:2022-05-26
下一篇:
C# UnitTestLibrary.CallbackArgs类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap