public void Setup()
 {
     mr         = new MockRepository();
     sp         = new ServiceContainer();
     uiSvc      = mr.StrictMock <IDecompilerShellUiService>();
     uiPrefsSvc = mr.StrictMock <IUiPreferencesService>();
     dlgFactory = mr.StrictMock <IDialogFactory>();
     uiSvc.Stub(u => u.GetContextMenu(MenuIds.CtxMemoryControl)).Return(new ContextMenu());
     uiSvc.Stub(u => u.GetContextMenu(MenuIds.CtxDisassembler)).Return(new ContextMenu());
     uiSvc.Replay();
     uiPrefsSvc.Replay();
     sp.AddService(typeof(IDecompilerShellUiService), uiSvc);
     sp.AddService(typeof(IDialogFactory), dlgFactory);
     sp.AddService(typeof(IUiPreferencesService), uiPrefsSvc);
     addrBase = Address.Ptr32(0x1000);
 }
        public void Setup()
        {
            mr = new MockRepository();
            sp = new ServiceContainer();
            uiSvc = mr.StrictMock<IDecompilerShellUiService>();
            uiPrefsSvc = mr.StrictMock<IUiPreferencesService>();
            dlgFactory = mr.StrictMock<IDialogFactory>();
            uiSvc.Stub(u => u.GetContextMenu(MenuIds.CtxMemoryControl)).Return(new ContextMenu());
            uiSvc.Stub(u => u.GetContextMenu(MenuIds.CtxDisassembler)).Return(new ContextMenu());
            uiSvc.Replay();
            uiPrefsSvc.Stub(u => u.Styles).Return(new Dictionary<string, UiStyle>());
            uiPrefsSvc.Replay();
            sp.AddService(typeof(IDecompilerShellUiService), uiSvc);
			sp.AddService(typeof(IDialogFactory), dlgFactory);
            sp.AddService(typeof(IUiPreferencesService), uiPrefsSvc);
            addrBase = Address.Ptr32(0x1000);
        }
Example #3
0
 public void Setup()
 {
     mr        = new MockRepository();
     sc        = new ServiceContainer();
     mockTree  = mr.StrictMock <ITreeView>();
     mockNodes = mr.StrictMock <ITreeNodeCollection>();
     uiSvc     = mr.StrictMock <IDecompilerShellUiService>();
     uiPrefSvc = mr.Stub <IUiPreferencesService>();
     mockTree.Stub(t => t.Nodes).Return(mockNodes);
     uiSvc.Stub(u => u.SetContextMenu(null, 0)).IgnoreArguments();
     sc.AddService <IDecompilerShellUiService>(uiSvc);
     sc.AddService <IUiPreferencesService>(uiPrefSvc);
     fakeTree = new FakeTreeView();
 }
Example #4
0
 public void Setup()
 {
     mr         = new MockRepository();
     sp         = new ServiceContainer();
     uiSvc      = mr.StrictMock <IDecompilerShellUiService>();
     uiPrefsSvc = mr.StrictMock <IUiPreferencesService>();
     dlgFactory = mr.StrictMock <IDialogFactory>();
     uiSvc.Stub(u => u.SetContextMenu(null, 0)).IgnoreArguments();
     uiSvc.Replay();
     uiPrefsSvc.Stub(u => u.Styles).Return(new Dictionary <string, UiStyle>());
     uiPrefsSvc.Replay();
     sp.AddService(typeof(IDecompilerShellUiService), uiSvc);
     sp.AddService(typeof(IDialogFactory), dlgFactory);
     sp.AddService(typeof(IUiPreferencesService), uiPrefsSvc);
     addrBase = Address.Ptr32(0x1000);
 }
Example #5
0
        public void Mfi_NextPhase_AdvanceToNextInteractor()
        {
            Given_Loader();
            Given_MainFormInteractor();
            diagnosticSvc.Expect(d => d.ClearDiagnostics());
            brSvc.Stub(b => b.Clear());
            Given_LoadPreferences();
            Given_DecompilerInstance();
            Given_SavePrompt(true);
            dcSvc.Stub(d => d.Decompiler = null);
            uiSvc.Stub(u => u.DocumentWindows).Return(new List <IWindowFrame>());
            mr.ReplayAll();

            When_CreateMainFormInteractor();
            interactor.OpenBinary(null);
            Assert.AreSame(interactor.InitialPageInteractor, interactor.CurrentPhase);
            interactor.NextPhase();
            Assert.AreSame(interactor.LoadedPageInteractor, interactor.CurrentPhase);

            mr.VerifyAll();
        }
        public void Mfi_NextPhase_AdvanceToNextInteractor()
        {
            Given_Loader();
            Given_MainFormInteractor();
            diagnosticSvc.Expect(d => d.ClearDiagnostics());
            brSvc.Stub(b => b.Clear());
            Given_LoadPreferences();
            Given_DecompilerInstance();
            Given_XmlWriter();
            Given_SavePrompt(true);
            dcSvc.Stub(d => d.Decompiler = null);
            uiSvc.Stub(u => u.DocumentWindows).Return(new List <IWindowFrame>());
            fsSvc.Stub(f => f.MakeRelativePath("foo.dcproject", "foo.exe")).Return("foo.exe");
            fsSvc.Stub(f => f.MakeRelativePath(Arg <string> .Is.Equal("foo.dcproject"), Arg <string> .Is.Null)).Return(null);
            mr.ReplayAll();

            When_CreateMainFormInteractor();
            interactor.OpenBinary(null);
            Assert.AreSame(interactor.InitialPageInteractor, interactor.CurrentPhase);
            interactor.NextPhase();
            Assert.AreSame(interactor.ScannedPageInteractor, interactor.CurrentPhase);

            mr.VerifyAll();
        }
        private void Given_MainFormInteractor()
        {
            program       = CreateFakeProgram();
            svcFactory    = mr.StrictMock <IServiceFactory>();
            archSvc       = mr.StrictMock <IArchiveBrowserService>();
            dlgFactory    = mr.StrictMock <IDialogFactory>();
            uiSvc         = mr.StrictMock <IDecompilerShellUiService>();
            memSvc        = mr.StrictMock <ILowLevelViewService>();
            disasmSvc     = mr.StrictMock <IDisassemblyViewService>();
            typeLibSvc    = mr.StrictMock <ITypeLibraryLoaderService>();
            brSvc         = mr.Stub <IProjectBrowserService>();
            uiPrefs       = mr.StrictMock <IUiPreferencesService>();
            fsSvc         = mr.StrictMock <IFileSystemService>();
            tcHostSvc     = mr.StrictMock <ITabControlHostService>();
            dcSvc         = mr.StrictMock <IDecompilerService>();
            srSvc         = MockRepository.GenerateMock <ISearchResultService, IWindowPane>();
            diagnosticSvc = MockRepository.GenerateMock <IDiagnosticsService, IWindowPane>();
            resEditSvc    = mr.StrictMock <IResourceEditorService>();
            cgvSvc        = mr.StrictMock <ICallGraphViewService>();
            loader        = mr.StrictMock <ILoader>();
            vimpSvc       = mr.StrictMock <IViewImportsService>();
            symLdrSvc     = mr.StrictMock <ISymbolLoadingService>();

            svcFactory.Stub(s => s.CreateArchiveBrowserService()).Return(archSvc);
            svcFactory.Stub(s => s.CreateDecompilerConfiguration()).Return(new FakeDecompilerConfiguration());
            svcFactory.Stub(s => s.CreateDiagnosticsService(Arg <ListView> .Is.Anything)).Return(diagnosticSvc);
            svcFactory.Stub(s => s.CreateDecompilerService()).Return(dcSvc);
            svcFactory.Stub(s => s.CreateDisassemblyViewService()).Return(disasmSvc);
            svcFactory.Stub(s => s.CreateMemoryViewService()).Return(memSvc);
            svcFactory.Stub(s => s.CreateDecompilerEventListener()).Return(new FakeDecompilerEventListener());
            svcFactory.Stub(s => s.CreateInitialPageInteractor()).Return(new FakeInitialPageInteractor());
            svcFactory.Stub(s => s.CreateScannedPageInteractor()).Return(new FakeScannedPageInteractor());
            svcFactory.Stub(s => s.CreateAnalyzedPageInteractor()).Return(new FakeAnalyzedPageInteractor());
            svcFactory.Stub(s => s.CreateFinalPageInteractor()).Return(new FakeFinalPageInteractor());
            svcFactory.Stub(s => s.CreateTypeLibraryLoaderService()).Return(typeLibSvc);
            svcFactory.Stub(s => s.CreateProjectBrowserService(Arg <ITreeView> .Is.NotNull)).Return(brSvc);
            svcFactory.Stub(s => s.CreateUiPreferencesService()).Return(uiPrefs);
            svcFactory.Stub(s => s.CreateFileSystemService()).Return(fsSvc);
            svcFactory.Stub(s => s.CreateShellUiService(Arg <IMainForm> .Is.NotNull, Arg <DecompilerMenus> .Is.NotNull)).Return(uiSvc);
            svcFactory.Stub(s => s.CreateTabControlHost(Arg <TabControl> .Is.NotNull)).Return(tcHostSvc);
            svcFactory.Stub(s => s.CreateLoader()).Return(loader);
            svcFactory.Stub(s => s.CreateSearchResultService(Arg <ListView> .Is.NotNull)).Return(srSvc);
            svcFactory.Stub(s => s.CreateResourceEditorService()).Return(resEditSvc);
            svcFactory.Stub(s => s.CreateCallGraphViewService()).Return(cgvSvc);
            svcFactory.Stub(s => s.CreateViewImportService()).Return(vimpSvc);
            svcFactory.Stub(s => s.CreateSymbolLoadingService()).Return(symLdrSvc);
            services.AddService(typeof(IDialogFactory), dlgFactory);
            services.AddService(typeof(IServiceFactory), svcFactory);
            brSvc.Stub(b => b.Clear());

            form = mr.StrictMock <IMainForm>();
            var listView       = new ListView();
            var imagelist      = new ImageList();
            var tabResults     = new TabPage();
            var tabDiagnostics = new TabPage();
            var tabControl     = new TabControl {
                TabPages = { tabResults, tabDiagnostics }
            };
            var toolStrip   = new ToolStrip {
            };
            var statusStrip = new StatusStrip {
                Items = { new ToolStripLabel() }
            };
            var brToolbar      = new ToolStrip();
            var projectBrowser = mr.Stub <ITreeView>();

            form.Stub(f => f.DiagnosticsList).Return(listView);
            form.Stub(f => f.ImageList).Return(imagelist);
            form.Stub(f => f.Menu).SetPropertyAndIgnoreArgument();
            form.Stub(f => f.AddToolbar(null)).IgnoreArguments();
            form.Stub(f => f.AddProjectBrowserToolbar(null)).IgnoreArguments();
            form.Stub(f => f.Dispose());
            form.Stub(f => f.TabControl).Return(tabControl);
            form.Stub(f => f.FindResultsPage).Return(tabResults);
            form.Stub(f => f.DiagnosticsPage).Return(tabDiagnostics);
            form.Stub(f => f.FindResultsList).Return(listView);
            form.Stub(f => f.ToolBar).Return(toolStrip);
            form.Stub(f => f.ProjectBrowserToolbar).Return(toolStrip);
            form.Stub(f => f.ProjectBrowser).Return(projectBrowser);
            form.Stub(f => f.StatusStrip).Return(statusStrip);
            form.Stub(f => f.AddProjectBrowserToolbar(null)).IgnoreArguments();
            form.Stub(f => f.ProjectBrowserToolbar).Return(brToolbar);
            form.Stub(f => f.TitleText = "main.exe ").IgnoreArguments();
            form.Load += null;
            LastCall.IgnoreArguments();
            form.Closed += null;
            LastCall.IgnoreArguments();
            form.ProcessCommandKey += null;
            LastCall.IgnoreArguments();
            dlgFactory.Stub(d => d.CreateMainForm()).Return(form);
            tcHostSvc.Stub(t => t.Attach(Arg <IWindowPane> .Is.NotNull, Arg <TabPage> .Is.NotNull));
            tcHostSvc.Stub(t => t.QueryStatus(
                               Arg <CommandID> .Is.Anything,
                               Arg <CommandStatus> .Is.Anything,
                               Arg <CommandText> .Is.Anything)).Return(false);
            tcHostSvc.Stub(t => t.Execute(Arg <CommandID> .Is.Anything)).Return(false);

            uiSvc.Stub(u => u.DocumentWindows).Return(new List <IWindowFrame>());
        }
        public void Mfi_OpenBinary_SwitchToInitialPhase()
        {
            Given_Loader();
            Given_MainFormInteractor();
            diagnosticSvc.Stub(d => d.ClearDiagnostics());
            brSvc.Stub(d => d.Clear());
            Given_DecompilerInstance();
            Given_LoadPreferences();
            dcSvc.Stub(d => d.Decompiler = null);
            Given_XmlWriter();
            Given_SavePrompt(true);
            fsSvc.Stub(f => f.MakeRelativePath("foo.dcproject", "foo.exe")).Return("foo.exe");
            fsSvc.Stub(f => f.MakeRelativePath(Arg <string> .Is.Equal("foo.dcproject"), Arg <string> .Is.Null)).Return(null);
            uiSvc.Stub(u => u.ShowSaveFileDialog("foo.dcproject")).Return("foo.dcproject");
            sbSvc.Expect(s => s.SetText(""));
            mr.ReplayAll();

            When_CreateMainFormInteractor();
            interactor.OpenBinary("floxie.exe");

            mr.VerifyAll();
            Assert.AreSame(interactor.CurrentPhase, interactor.InitialPageInteractor);
            Assert.IsTrue(((FakeInitialPageInteractor)interactor.InitialPageInteractor).OpenBinaryCalled);
        }