public void MVS_ShowingWindowCreatesWindowFrame() { ServiceContainer sc = new ServiceContainer(); var shellUi = mr.DynamicMock <IDecompilerShellUiService>(); var decSvc = mr.StrictMock <IDecompilerService>(); var windowFrame = mr.DynamicMock <IWindowFrame>(); var uiPrefSvc = mr.Stub <IUiPreferencesService>(); sc.AddService(typeof(IDecompilerShellUiService), shellUi); sc.AddService <IDecompilerService>(decSvc); AddStubService <IUiPreferencesService>(sc); Given_Program(); var service = mr.Stub <LowLevelViewServiceImpl>(sc); var interactor = new LowLevelViewInteractor(); service.Stub(x => x.CreateMemoryViewInteractor()).Return(interactor); var svc = (ILowLevelViewService)service; Expect.Call(shellUi.FindWindow("memoryViewWindow")).Return(null); Expect.Call(shellUi.CreateWindow( Arg <string> .Is.Anything, Arg <string> .Is.Equal("Memory View"), Arg <IWindowPane> .Is.Anything)) .Return(windowFrame); Expect.Call(windowFrame.Show); mr.ReplayAll(); interactor.SetSite(sc); interactor.CreateControl(); svc.ShowMemoryAtAddress(program, program.Image.BaseAddress); mr.VerifyAll(); }
private void Given_Interactor() { interactor = mr.PartialMock <LowLevelViewInteractor>(); interactor.SetSite(sp); control = (LowLevelView)interactor.CreateControl(); interactor.Program = program; }
public void MVS_ShowingWindowCreatesWindowFrame() { ServiceContainer sc = new ServiceContainer(); var shellUi = new Mock <IDecompilerShellUiService>(); var decSvc = new Mock <IDecompilerService>(); var windowFrame = new Mock <IWindowFrame>(); sc.AddService <IDecompilerShellUiService>(shellUi.Object); sc.AddService <IDecompilerService>(decSvc.Object); AddStubService <IUiPreferencesService>(sc).Setup(u => u.Styles) .Returns(new Dictionary <string, UiStyle>()); Given_Program(); var service = new Mock <LowLevelViewServiceImpl>(sc); var interactor = new LowLevelViewInteractor(); service.Setup(x => x.CreateMemoryViewInteractor()) .Returns(interactor); var svc = (ILowLevelViewService)service.Object; shellUi.Setup(s => s.FindDocumentWindow("memoryViewWindow", program)) .Returns((IWindowFrame)null) .Verifiable(); shellUi.Setup(s => s.CreateDocumentWindow( It.IsAny <string>(), program, "Memory View", It.IsAny <IWindowPane>())) .Returns(windowFrame.Object) .Verifiable(); windowFrame.Setup(w => w.Show()); interactor.SetSite(sc); interactor.CreateControl(); svc.ShowMemoryAtAddress(this.program, (Address)this.program.ImageMap.BaseAddress); shellUi.Verify(); windowFrame.Verify(); }