public void TestPointersView() { PointerRegistersView registryView = new PointerRegistersView(new HexParser()); ValueTuple <string, byte[]> tupleMock = new ValueTuple <string, byte[]>(); tupleMock.Item1 = "BP"; tupleMock.Item2 = new byte[] { 0, 1 }; registryView.Update(tupleMock); Assert.AreEqual(registryView.BP, "0x0100"); tupleMock.Item1 = "SP"; tupleMock.Item2 = new byte[] { 0, 255 }; registryView.Update(tupleMock); Assert.AreEqual(registryView.SP, "0xFF00"); tupleMock.Item1 = "BP"; tupleMock.Item2 = new byte[] { 1, 1 }; registryView.Update(tupleMock); Assert.AreEqual(registryView.BP, "0x0101"); tupleMock.Item1 = "SP"; tupleMock.Item2 = new byte[] { 255, 0 }; registryView.Update(tupleMock); Assert.AreEqual(registryView.SP, "0x00FF"); }
public MainWindow() { InitializeComponent(); MemoryModel.SetAddressBusLength = 20; MemoryModel.GetInstance().AddObserver(this); memoryView = new MemoryView(); Go_Click(null, null); generalPurposeRegisters = new GeneralPurposeRegisters(); indexRegisters = new IndexRegisters(); pointerRegisters = new PointerRegisters(); segmentRegisters = new SegmentRegisters(); commandInterpreter = InitDefaultRegistryCommander(); generalPurposeRegistersView = new GeneralPurposeRegistersView(new HexParser()); indexRegistersView = new IndexRegistersView(new HexParser()); pointerRegistersView = new PointerRegistersView(new HexParser()); segmentRegistersView = new SegmentRegistersView(new HexParser()); if (generalPurposeRegisters is Observable observableGeneralPurposeReg) { observableGeneralPurposeReg.AddObserver(generalPurposeRegistersView); } if (indexRegisters is Observable observableIndexReg) { observableIndexReg.AddObserver(indexRegistersView); } if (pointerRegisters is Observable observablePointersReg) { observablePointersReg.AddObserver(pointerRegistersView); } if (segmentRegisters is Observable observableSegmentsReg) { observableSegmentsReg.AddObserver(segmentRegistersView); } SetBlockDataContext(); }