Example #1
0
        public void Cmasp_Do()
        {
            var addr     = Address.SegPtr(0x0C20, 0);
            var proc     = new Procedure("foo", null);
            var progaddr = new ProgramAddress(program, addr);
            var dc       = mr.Stub <IDecompiler>();
            var dcSvc    = mr.Stub <IDecompilerService>();
            var brSvc    = mr.Stub <IProjectBrowserService>();

            dcSvc.Decompiler = dc;
            sc.AddService <IDecompilerService>(dcSvc);
            sc.AddService <IProjectBrowserService>(brSvc);
            sc.AddService <IDecompilerShellUiService>(new FakeShellUiService());
            dc.Expect(d => d.ScanProcedure(progaddr)).IgnoreArguments().Return(proc);
            brSvc.Expect(b => b.Reload());
            mr.ReplayAll();

            var locations = new[] { new ProgramAddress(program, addr) };
            var cmd       = new Cmd_MarkProcedures(sc, locations);

            cmd.DoIt();

            mr.VerifyAll();
            Assert.AreEqual(1, program.User.Procedures.Count);
            var uproc = program.User.Procedures.Values[0];

            Assert.AreEqual("0C20:0000", uproc.Address);
        }
Example #2
0
        public void Cmasp_Do()
        {
            var addr     = Address.SegPtr(0x0C20, 0);
            var proc     = new Procedure(new FakeArchitecture(), "foo", addr, null);
            var progaddr = new ProgramAddress(program, addr);
            var dc       = new Mock <IDecompiler>();
            var dcSvc    = new Mock <IDecompilerService>();
            var brSvc    = new Mock <IProjectBrowserService>();

            dcSvc.Setup(d => d.Decompiler).Returns(dc.Object);
            sc.AddService <IDecompilerService>(dcSvc.Object);
            sc.AddService <IProjectBrowserService>(brSvc.Object);
            sc.AddService <IDecompilerShellUiService>(new FakeShellUiService());
            dc.Setup(d => d.ScanProcedure(It.IsAny <ProgramAddress>())).Returns(proc).Verifiable();
            brSvc.Setup(b => b.Reload()).Verifiable();
            brSvc.Setup(b => b.CurrentProgram).Returns(program);

            var locations = new[] { new ProgramAddress(program, addr) };
            var cmd       = new Cmd_MarkProcedures(sc, locations);

            cmd.DoIt();

            dc.VerifyAll();
            brSvc.Verify();
            Assert.AreEqual(1, program.User.Procedures.Count);
            var uproc = program.User.Procedures.Values[0];

            Assert.AreEqual("0C20:0000", uproc.Address);
        }