当前位置: 首页>>代码示例>>C#>>正文


C# GenericMockFactory.AddMethodReturnValues方法代码示例

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


在下文中一共展示了GenericMockFactory.AddMethodReturnValues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PackageTestEnvironment

            public PackageTestEnvironment()
            {
                // Create the project
                project = new ProjectTestClass(new ProjectTestPackage());

                // Site the project
                services = Microsoft.VsSDK.UnitTestLibrary.OleServiceProvider.CreateOleServiceProviderWithBasicServices();
                LocalRegistryMock localRegistry = new LocalRegistryMock();
                localRegistry.RegistryRoot = @"Software\Microsoft\VisualStudio\9.0";
                services.AddService(typeof(SLocalRegistry), localRegistry, true);

                BaseMock mockConfiguration = new GenericMockFactory("MockConfiguration", new[] { typeof(Configuration) }).GetInstance();
                mockConfiguration.AddMethodReturnValues(string.Format("{0}.{1}", typeof(Configuration).FullName, "ConfigurationName"), new[] { "Debug" });
                mockConfiguration.AddMethodReturnValues(string.Format("{0}.{1}", typeof(Configuration).FullName, "PlatformName"), new[] { "AnyCPU" });

                BaseMock mockConfigMgr = ConfigurationManagerFactory.GetInstance();
                mockConfigMgr.AddMethodReturnValues(string.Format("{0}.{1}", typeof(ConfigurationManager).FullName, ""), new[] { mockConfiguration });

                BaseMock extensibility = ExtensibilityFactory.GetInstance();
                extensibility.AddMethodReturnValues(
                    string.Format("{0}.{1}", typeof(IVsExtensibility3).FullName, "GetConfigMgr"),
                    new object[] { 0, null, null, mockConfigMgr });
                services.AddService(typeof(IVsExtensibility), extensibility, false);

                project.SetSite(services);

                // Init the msbuild engine
                Microsoft.Build.Evaluation.ProjectCollection engine = VisualStudio.Project.Utilities.InitializeMsBuildEngine(null, services);
                Assert.IsNotNull(engine, "MSBuild Engine could not be initialized");

                // Retrieve the project file content, load it and save it
                string fullpath = Path.Combine(new DirectoryInfo(Assembly.GetExecutingAssembly().Location).Parent.FullName, "TestProject.proj");
                if(string.IsNullOrEmpty(projectXml))
                {
                    projectXml = Properties.Resources.TestProject;
                    using(TextWriter writer = new StreamWriter(fullpath))
                    {
                        writer.Write(projectXml);
                    }
                }

                // Init the msbuild project
                Microsoft.Build.Evaluation.Project buildProject = VisualStudio.Project.Utilities.InitializeMsBuildProject(engine, fullpath);
                Assert.IsNotNull(buildProject, "MSBuild project not initialized correctly in InitializeMsBuildProject");

                //Verify that we can set the build project on the projectnode
                project.BuildProject = buildProject;

                // Now the project is opened, so we can update its internal variable.
                if(null == projectOpened)
                {
                    projectOpened = typeof(VisualStudio.Project.ProjectNode).GetField("projectOpened", BindingFlags.Instance | BindingFlags.NonPublic);
                }
                projectOpened.SetValue(project, true);
            }
开发者ID:tunnelvisionlabs,项目名称:MPFProj10,代码行数:55,代码来源:ProjectTest.cs


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