public void CreateSetAsStartCommandItemTest() { _hexDataContext.FocusPosition = 512; var cmi = HexDataContextCommandFactory.CreateSetAsStartCommandItem(_hexDataContext); cmi.Command.Execute(null); Assert.AreEqual(_hexDataContext.SelectionStart, 512); }
public void CreateCopyAsProCodeCommandItemTest() { _hexDataContext.SelectionStart = 0; _hexDataContext.SelectionLength = 512; var cmi = HexDataContextCommandFactory.CreateCopyAsProCodeCommandItem(_hexDataContext); cmi.Children.ElementAt(0).Command.Execute(null); }
private void AddKeyBindingsToHexDataContext(IHexDataContext hexDataContext) { if (hexDataContext == null) { throw new ArgumentNullException(nameof(hexDataContext)); } hexDataContext.AddKeyBinding(HexDataContextCommandFactory.CreateCopyToClipBoardCommand(hexDataContext), Key.C, ModifierKeys.Control); hexDataContext.AddKeyBinding(HexDataContextCommandFactory.CreateCopyToCopyHexToCBoardCommand(hexDataContext), Key.C, ModifierKeys.Control | ModifierKeys.Shift); }
private static void AddContextCommandsToHexDataContext(IHexDataContext hexDataContext) { if (hexDataContext == null) { throw new ArgumentNullException(nameof(hexDataContext)); } hexDataContext.AddContextCommand(HexDataContextCommandFactory.CreateSetAsStartCommandItem(hexDataContext)); hexDataContext.AddContextCommand(HexDataContextCommandFactory.CreateSetAsEndCommandItem(hexDataContext)); hexDataContext.AddContextCommand(HexDataContextCommandFactory.CreateCopyToNewFileCommandItem(hexDataContext)); hexDataContext.AddContextCommand(HexDataContextCommandFactory.CreateCopyToClipBoardCommandItem(hexDataContext)); hexDataContext.AddContextCommand(HexDataContextCommandFactory.CreateCopyToCopyHexToCBoardCommandItem(hexDataContext)); hexDataContext.AddContextCommand(HexDataContextCommandFactory.CreateCopyAsProCodeCommandItem(hexDataContext)); }
public void CreateCopyToNewFileCommandItemTest() { _hexDataContext.SelectionStart = 0; _hexDataContext.SelectionLength = 512; var saveFileName = "E://anli/noname2"; AppMockers.SaveFileName = saveFileName; var cmi = HexDataContextCommandFactory.CreateCopyToNewFileCommandItem(_hexDataContext); _hexDataContext.AddContextCommand(cmi); Assert.IsTrue(_hexDataContext.ContextCommands.Contains(cmi)); cmi.Command.Execute(null); Assert.IsTrue(File.Exists(saveFileName)); var bts = File.ReadAllBytes(saveFileName); Assert.AreEqual(bts.Length, _hexDataContext.SelectionLength); Assert.AreEqual(bts[510], 0x55); Assert.AreEqual(bts[511], 0xAA); }