示例#1
0
        public void Cvp_CreateGlobalsViewerIfNotVisible()
        {
            var segment = new ImageSegment(
                ".seg", Address32.Ptr32(0x17), 0, AccessMode.ReadWrite);
            var label = ".seg global variables";

            var uiSvc = AddMockService <IDecompilerShellUiService>();

            uiSvc.Expect(s => s.FindDocumentWindow(
                             "CombinedCodeViewInteractor", segment))
            .Return(null);
            var windowPane  = mr.Stub <CombinedCodeViewInteractor>();
            var windowFrame = mr.StrictMock <IWindowFrame>();

            windowFrame.Stub(f => f.Pane).Return(windowPane);
            uiSvc.Expect(s => s.CreateDocumentWindow(
                             Arg <string> .Is.Equal("CombinedCodeViewInteractor"),
                             Arg <string> .Is.Equal(segment),
                             Arg <string> .Is.Equal(label),
                             Arg <IWindowPane> .Is.Anything))
            .Return(windowFrame);
            windowFrame.Expect(s => s.Show());

            mr.ReplayAll();

            var codeViewerSvc = new CodeViewerServiceImpl(sc);

            codeViewerSvc.DisplayGlobals(program, segment);

            uiSvc.VerifyAllExpectations();
        }
示例#2
0
        public void Cvp_CreateGlobalsViewerIfNotVisible()
        {
            var segment = new ImageSegment(
                ".seg", Address32.Ptr32(0x17), 0, AccessMode.ReadWrite);
            var label = ".seg global variables";

            var uiSvc = AddMockService <IDecompilerShellUiService>();

            uiSvc.Setup(s => s.FindDocumentWindow(
                            "CombinedCodeViewInteractor", segment))
            .Returns((IWindowFrame)null)
            .Verifiable();
            var windowPane  = new Mock <CombinedCodeViewInteractor>();
            var windowFrame = new Mock <IWindowFrame>();

            windowFrame.Setup(f => f.Pane).Returns(windowPane.Object);
            uiSvc.Setup(s => s.CreateDocumentWindow(
                            "CombinedCodeViewInteractor",
                            segment,
                            label,
                            It.IsAny <IWindowPane>()))
            .Returns(windowFrame.Object);
            windowFrame.Setup(s => s.Show()).Verifiable();

            var codeViewerSvc = new CodeViewerServiceImpl(sc);

            codeViewerSvc.DisplayGlobals(program, segment);

            uiSvc.VerifyAll();
            windowFrame.VerifyAll();
        }