本文整理汇总了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);
}