public void Setup() { mr = new MockRepository(); var 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); tlSvc.Stub(t => t.LoadLibrary(null, null)).IgnoreArguments() .Do(new Func<IProcessorArchitecture, string, TypeLibrary>((a, n) => { var lib = TypeLibrary.Load(a, Path.ChangeExtension(n, ".xml")); return lib; })); services.Replay(); tlSvc.Replay(); configSvc.Replay(); arch = new IntelArchitecture(ProcessorMode.Protected32); win32 = new Decompiler.Environments.Win32.Win32Platform(services, arch); }
private void Given_Configuration_With_Win32_Element() { var dcSvc = repository.Stub<IConfigurationService>(); var opEnv = new OperatingEnvironmentElement { TypeLibraries = { new TypeLibraryElement { Name = "windows.xml" } } }; dcSvc.Expect(d => d.GetEnvironment("win32")).Return(opEnv); dcSvc.Stub(c => c.GetPath(null)).IgnoreArguments() .Do(new Func<string, string>(s => s)); sc.AddService<IConfigurationService>(dcSvc); }