本文整理汇总了C#中IServiceProvider.Stub方法的典型用法代码示例。如果您正苦于以下问题:C# IServiceProvider.Stub方法的具体用法?C# IServiceProvider.Stub怎么用?C# IServiceProvider.Stub使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IServiceProvider
的用法示例。
在下文中一共展示了IServiceProvider.Stub方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
public void Setup()
{
mr = new MockRepository();
this.services = mr.Stub<IServiceProvider>();
var tlSvc = new TypeLibraryLoaderServiceImpl(services);
var configSvc = mr.StrictMock<IConfigurationService>();
var fsSvc = new FileSystemServiceImpl();
var win32env = new OperatingEnvironmentElement
{
TypeLibraries =
{
new TypeLibraryElement { Name= "msvcrt.xml" },
new TypeLibraryElement { Name= "windows32.xml" },
}
};
configSvc.Stub(c => c.GetEnvironment("win32")).Return(win32env);
configSvc.Stub(c => c.GetInstallationRelativePath(null)).IgnoreArguments()
.Do(new Func<string, string>(s => s));
services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc);
services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(configSvc);
services.Stub(s => s.GetService(typeof(DecompilerEventListener))).Return(new FakeDecompilerEventListener());
services.Stub(s => s.GetService(typeof(CancellationTokenSource))).Return(null);
services.Stub(s => s.GetService(typeof(IFileSystemService))).Return(new FileSystemServiceImpl());
services.Replay();
configSvc.Replay();
arch = new IntelArchitecture(ProcessorMode.Protected32);
win32 = new Reko.Environments.Windows.Win32Platform(services, arch);
}
示例2: AddServiceToFakeServiceProvider
void AddServiceToFakeServiceProvider(IServiceProvider serviceProvider, Type serviceType, object service)
{
serviceProvider
.Stub(provider => provider.GetService(serviceType))
.Return(service);
}
示例3: Setup
public void Setup()
{
mr = new MockRepository();
this.services = mr.Stub<IServiceProvider>();
var tlSvc = mr.Stub<ITypeLibraryLoaderService>();
var configSvc = mr.StrictMock<IConfigurationService>();
var win32env = new OperatingEnvironmentElement
{
TypeLibraries =
{
new TypeLibraryElement { Name= "msvcrt.xml" },
new TypeLibraryElement { Name= "windows32.xml" },
}
};
configSvc.Stub(c => c.GetEnvironment("win32")).Return(win32env);
configSvc.Stub(c => c.GetPath(null)).IgnoreArguments()
.Do(new Func<string, string>(s => s));
services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc);
services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(configSvc);
services.Stub(s => s.GetService(typeof(DecompilerEventListener))).Return(new FakeDecompilerEventListener());
services.Stub(s => s.GetService(typeof(CancellationTokenSource))).Return(null);
tlSvc.Stub(t => t.LoadLibrary(null, null)).IgnoreArguments()
.Do(new Func<Platform, string, TypeLibrary>((p, n) =>
{
var lib = TypeLibrary.Load(p, Path.ChangeExtension(n, ".xml"));
return lib;
}));
services.Replay();
tlSvc.Replay();
configSvc.Replay();
arch = new IntelArchitecture(ProcessorMode.Protected32);
win32 = new Reko.Environments.Windows.Win32Platform(services, arch);
}
示例4: AddServiceObjectToReturnFromServiceProvider
void AddServiceObjectToReturnFromServiceProvider(IServiceProvider serviceProvider, Type type, object objectToReturn)
{
serviceProvider.Stub(provider => provider.GetService(type)).Return(objectToReturn);
}
示例5: Setup
public void Setup()
{
this.mr = new MockRepository();
this.arch = mr.Stub<IProcessorArchitecture>();
this.services = mr.Stub<IServiceProvider>();
this.dcSvc = mr.Stub<IConfigurationService>();
this.tlSvc = mr.Stub<ITypeLibraryLoaderService>();
services.Stub(s => s.GetService(typeof(IConfigurationService))).Return(dcSvc);
services.Stub(s => s.GetService(typeof(ITypeLibraryLoaderService))).Return(tlSvc);
dcSvc.Stub(d => d.GetArchitecture("x86-protected-32")).Return(arch);
dcSvc.Stub(d => d.GetEnvironment("elf-neutral")).Return(new OperatingEnvironmentElement
{
TypeName = typeof(SysVPlatform).AssemblyQualifiedName
});
}