public void PBS_SingleBinary() { var pbs = new ProjectBrowserService(sc, fakeTree); Given_Project(); Given_ProgramWithOneSegment(); Given_ImageMapItem(0x12340000); pbs.Load(project); Assert.IsTrue(fakeTree.ShowNodeToolTips); Expect( "<?xml version=\"1.0\" encoding=\"utf-16\"?>" + "<root>" + "<node " + "text=\"foo.exe\" " + "tip=\"c:\\test\\foo.exe" + cr + "12300000\" " + "tag=\"ProgramDesigner\">" + "<node text=\"Foo Processor\" tag=\"ArchitectureDesigner\" />" + "<node text=\"(Unknown operating environment)\" tag=\"PlatformDesigner\" />" + "<node " + "text=\".text\" " + "tip=\".text" + cr + "Address: 12340000" + cr + "Size: 1000" + cr + "r-x" + "\" " + "tag=\"ImageMapSegmentNodeDesigner\">" + "<node " + "text=\"Global variables\" " + "tag=\"GlobalVariablesNodeDesigner\" />" + "</node>" + "<node tag=\"ProgramResourceGroupDesigner\" />" + "</node>" + "</root>"); }
public void PBS_NoProject() { var pbs = new ProjectBrowserService(sc, tabPage.Object, fakeTree); pbs.Load(null); Expect("<?xml version=\"1.0\" encoding=\"utf-16\"?><root><node text=\"(No project loaded)\" /></root>"); Assert.IsFalse(fakeTree.ShowRootLines); Assert.IsFalse(fakeTree.ShowNodeToolTips); }
public void PBS_NoGrandParent() { var mockTree = new FakeTreeView(); var pbs = new ProjectBrowserService(sc, tabPage.Object, mockTree); var p = new ParentComponent(); var c = new TestComponent(); pbs.AddComponents(new[] { p }); pbs.AddComponents(p, new[] { c }); var o = pbs.GetAncestorOfType <GrandParentComponent>(c); Assert.IsNull(o); }
public void PBS_RejectTextDrop() { var mockTree = new FakeTreeView(); var pbs = new ProjectBrowserService(sc, mockTree); var e = Given_DraggedText(); mr.ReplayAll(); var project = new Project(); pbs.Load(project); mockTree.PerformDragEnter(e); Assert.AreEqual(DragDropEffects.None, e.Effect); }
public void PBS_AcceptFiles() { var mockTree = new FakeTreeView(); var pbs = new ProjectBrowserService(sc, mockTree); var e = Given_DraggedFile(); mr.ReplayAll(); var project = new Project(); pbs.Load(project); mockTree.PerformDragEnter(e); Assert.AreEqual(DragDropEffects.Copy, e.Effect); }
public void PBS_AddTypeLib() { var mockTree = new FakeTreeView(); var pbs = new ProjectBrowserService(sc, tabPage.Object, mockTree); var project = new Project(); pbs.Load(project); project.MetadataFiles.Add(new MetadataFile { Filename = ".." + sep + "foo.tlb" }); Assert.AreEqual(1, mockTree.Nodes.Count); Assert.AreEqual("foo.tlb", mockTree.Nodes[0].Text); }
public void PBS_FindGrandParent() { var mockTree = new FakeTreeView(); var pbs = new ProjectBrowserService(sc, mockTree); var gp = new GrandParentComponent(); var p = new ParentComponent(); var c = new TestComponent(); pbs.AddComponents(new[] { gp }); pbs.AddComponents(gp, new[] { p }); pbs.AddComponents(p, new[] { c }); var o = pbs.GetAncestorOfType <GrandParentComponent>(c); Assert.AreSame(gp, o); }
public void PBS_AddTypeLib() { mockTree = new FakeTreeView(); var pbs = new ProjectBrowserService(sc, mockTree); var project = new Project(); pbs.Load(project); project.MetadataFiles.Add(new MetadataFile { ModuleName = "..\\foo.tlb" }); Assert.AreEqual(1, mockTree.Nodes.Count); Assert.AreEqual("foo.tlb", mockTree.Nodes[0].Text); }
public void PBS_AcceptDrop() { string filename = null; var mockTree = new FakeTreeView(); var pbs = new ProjectBrowserService(sc, mockTree); pbs.FileDropped += (sender, ee) => { filename = ee.Filename; }; var e = Given_DraggedFile(); mr.ReplayAll(); var project = new Project(); pbs.Load(project); mockTree.PerformDragDrop(e); Assert.AreEqual("/home/bob/foo.exe", filename); }
public void PBS_AfterSelect_Calls_DoDefaultAction() { var des = mr.StrictMock <TreeNodeDesigner>(); des.Expect(d => d.DoDefaultAction()); des.Stub(d => d.Initialize(null)).IgnoreArguments(); mockTree = new FakeTreeView(); mr.ReplayAll(); var pbs = new ProjectBrowserService(sc, mockTree); pbs.AddComponents(new object[] { des }); var desdes = pbs.GetDesigner(des); Assert.IsNotNull(desdes); mockTree.SelectedNode = des.TreeNode; mr.VerifyAll(); }
public void PBS_AfterSelect_Calls_DoDefaultAction() { var des = new Mock <TreeNodeDesigner> { CallBase = true }; des.Setup(d => d.DoDefaultAction()).Verifiable(); des.Setup(d => d.Initialize(It.IsAny <object>())); des.Object.Component = "foo"; var mockTree = new FakeTreeView(); var pbs = new ProjectBrowserService(sc, tabPage.Object, mockTree); pbs.AddComponents(new object[] { des.Object }); var desdes = pbs.GetDesigner(des.Object); Assert.IsNotNull(desdes); mockTree.SelectedNode = des.Object.TreeNode; des.Verify(); }
public void PBS_AddBinary() { var pbs = new ProjectBrowserService(sc, fakeTree); Given_Project(); Given_ProgramWithOneSegment(); mr.ReplayAll(); pbs.Load(project); project.Programs.Add(new Program { Filename = "bar.exe", Image = new LoadedImage(Address.Ptr32(0x1231300), new byte[128]) }); Expect("<?xml version=\"1.0\" encoding=\"utf-16\"?>" + "<root><node text=\"foo.exe\" tip=\"c:\\test\\foo.exe
12340000\" tag=\"Program\">" + "<node text=\"Image base\" tip=\"Image base
Address: 12340000
Size: 1000
rw-\" tag=\"ImageMapSegment\" />" + "</node>" + "</root>"); mr.VerifyAll(); }
public ProjectBrowserDialog() { InitializeComponent(); pbs = new ProjectBrowserService(null, new TreeViewWrapper(treeView)); }