public void Prld_LoadMetadata_NoPlatform_ShouldQuery() { var ldr = mr.Stub <ILoader>(); var oracle = mr.StrictMock <IOracleService>(); var arch = mr.Stub <IProcessorArchitecture>(); var platform = mockFactory.CreatePlatform(); var typeLib = new TypeLibrary(); ldr.Stub(l => l.LoadMetadata(Arg <string> .Is.NotNull, Arg <IPlatform> .Is.Equal(platform), Arg <TypeLibrary> .Is.NotNull)).Return(typeLib); oracle.Expect(o => o.QueryPlatform(Arg <string> .Is.NotNull)).Return(platform); sc.AddService <IOracleService>(oracle); mr.ReplayAll(); var prld = new ProjectLoader(sc, ldr); prld.LoadProject( "project.dcproj", new Project_v2 { Inputs = { new MetadataFile_v2 { Filename = "foo", } } }); mr.VerifyAll(); }
public void Setup() { this.mr = new MockRepository(); this.mockFactory = new MockFactory(mr); this.platform = mockFactory.CreatePlatform(); this.program = mockFactory.CreateProgram(); }
public void Setup() { mr = new MockRepository(); mockFactory = new MockFactory(mr); var platform = mockFactory.CreatePlatform(); var imageMap = new SegmentMap(Address32.Ptr32(0x05)); program = new Program(imageMap, platform.Architecture, platform); interactor = new CombinedCodeViewInteractor(); var uiPreferencesSvc = mr.Stub <IUiPreferencesService>(); var uiSvc = mr.Stub <IDecompilerShellUiService>(); var styles = new Dictionary <string, UiStyle>() { { UiStyles.CodeWindow, new UiStyle { Background = new SolidBrush(Color.White), } } }; uiPreferencesSvc.Stub(u => u.Styles).Return(styles); var sc = new ServiceContainer(); sc.AddService <IUiPreferencesService>(uiPreferencesSvc); sc.AddService <IDecompilerShellUiService>(uiSvc); interactor.SetSite(sc); }
private void Given_Loader() { var bytes = new byte[1000]; var mem = new MemoryArea(Address.SegPtr(0x0C00, 0x0000), bytes); loader = mr.StrictMock <ILoader>(); loader.Stub(l => l.LoadImageBytes(null, 0)).IgnoreArguments() .Return(bytes); loader.Stub(l => l.LoadExecutable(null, null, null, null)).IgnoreArguments() .Return(new Program { SegmentMap = new SegmentMap( mem.BaseAddress, new ImageSegment("0C00", mem, AccessMode.ReadWriteExecute)), Platform = mockFactory.CreatePlatform() }); }
private void Given_ExecutableProgram(string exeName, Address address) { var bytes = new byte[0x1000]; var mem = new MemoryArea(address, bytes); var program = new Program { Architecture = arch, Platform = mockFactory.CreatePlatform(), ImageMap = new ImageMap(address, new ImageSegment(".text", mem, AccessMode.ReadWriteExecute)) }; loader.Stub(l => l.LoadImageBytes( Arg <string> .Matches(s => s.EndsWith(exeName)), Arg <int> .Is.Anything)).Return(bytes); loader.Stub(l => l.LoadExecutable( Arg <string> .Matches(s => s.EndsWith(exeName)), Arg <byte[]> .Is.NotNull, Arg <Address> .Is.Null)).Return(program); }