public void CreateTagWithMessageWritesTagMessageFile() { var args = new GitCreateTagArgs(TagName, Revision, TagOperation.Annotate, TagMessage); _controller.CreateTag(args, null); _fileSystem.File.Received(1).WriteAllText(_tagMessageFile, TagMessage); }
private int CreateLostFoundTags() { var selectedLostObjects = Warnings.Rows .Cast <DataGridViewRow>() .Select(row => row.Cells[columnIsLostObjectSelected.Index]) .Where(cell => (bool?)cell.Value == true) .Select(cell => _filteredLostObjects[cell.RowIndex]) .ToList(); if (selectedLostObjects.Count == 0) { MessageBox.Show(this, selectLostObjectsToRestoreMessage.Text, selectLostObjectsToRestoreCaption.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning); return(0); } var currentTag = 0; foreach (var lostObject in selectedLostObjects) { currentTag++; var createTagArgs = new GitCreateTagArgs($"{RestoredObjectsTagPrefix}{currentTag}", lostObject.Hash); _gitTagController.CreateTag(createTagArgs, this); } return(currentTag); }
public void Tag_key_id_null(string signKeyId) { var args = new GitCreateTagArgs(TagName, Revision, TagOperation.SignWithSpecificKey, signKeyId: signKeyId); var cmd = new GitCreateTagCmd(args, _tagMessageFile); cmd.Validate(); }
public void Tag_supported_operation(TagOperation operation) { var args = new GitCreateTagArgs(TagName, Revision, operation, signKeyId: KeyId, force: true); var cmd = new GitCreateTagCmd(args, _tagMessageFile); var actualCmdLine = cmd.ToLine(); var switches = ""; switch (operation) { case TagOperation.Lightweight: break; case TagOperation.Annotate: switches = $" -a -F \"{_tagMessageFile}\""; break; case TagOperation.SignWithDefaultKey: switches = $" -s -F \"{_tagMessageFile}\""; break; case TagOperation.SignWithSpecificKey: switches = $" -u {KeyId} -F \"{_tagMessageFile}\""; break; } var expectedCmdLine = $"tag -f{switches} \"{TagName}\" -- \"{Revision}\""; Assert.AreEqual(expectedCmdLine, actualCmdLine); }
public void ToLine_should_throw_if_operation_not_supported() { var args = new GitCreateTagArgs(TagName, Revision, (TagOperation)10); var cmd = new GitCreateTagCmd(args, TagMessageFile); Assert.Throws <NotSupportedException>(() => cmd.ToLine()); }
public void Validate_should_throw_for_SignWithSpecificKey_if_tag_keyId_invalid(string signKeyId) { var args = new GitCreateTagArgs(TagName, Revision, TagOperation.SignWithSpecificKey, signKeyId: signKeyId); var cmd = new GitCreateTagCmd(args, TagMessageFile); Assert.Throws <ArgumentException>(() => cmd.Validate()); }
private string CreateTag() { GitCreateTagArgs createTagArgs = new GitCreateTagArgs(); createTagArgs.Revision = commitPickerSmallControl1.SelectedCommitHash; if (createTagArgs.Revision.IsNullOrEmpty()) { MessageBox.Show(this, _noRevisionSelected.Text, _messageCaption.Text); return(string.Empty); } createTagArgs.TagName = textBoxTagName.Text; createTagArgs.Force = ForceTag.Checked; createTagArgs.OperationType = GetSelectedOperation(annotate.SelectedIndex); createTagArgs.TagMessage = tagMessage.Text; createTagArgs.SignKeyId = textBoxGpgKey.Text; IGitTagController _gitTagController = new GitTagController(UICommands, Module); if (!_gitTagController.CreateTag(createTagArgs, this)) { return(string.Empty); } DialogResult = DialogResult.OK; return(textBoxTagName.Text); }
public void Tag_revision_null(string revision) { var args = new GitCreateTagArgs(TagName, revision); var cmd = new GitCreateTagCmd(args, _tagMessageFile); Assert.Throws <ArgumentException>(() => cmd.Validate()); }
private string CreateTag() { var objectId = commitPickerSmallControl1.SelectedObjectId; if (objectId == null) { MessageBox.Show(this, _noRevisionSelected.Text, _messageCaption.Text); return(""); } var createTagArgs = new GitCreateTagArgs(textBoxTagName.Text, objectId, GetSelectedOperation(annotate.SelectedIndex), tagMessage.Text, textBoxGpgKey.Text, ForceTag.Checked); var success = _gitTagController.CreateTag(createTagArgs, this); if (!success) { return(""); } DialogResult = DialogResult.OK; return(textBoxTagName.Text); }
public void Tag_operation_not_supported() { var args = new GitCreateTagArgs(TagName, Revision, (TagOperation)10); var cmd = new GitCreateTagCmd(args, _tagMessageFile); cmd.ToLine(); }
public void Tag_revision_null(string revision) { var args = new GitCreateTagArgs(TagName, revision); var cmd = new GitCreateTagCmd(args, _tagMessageFile); cmd.Validate(); }
public void Validate_should_throw_if_tag_revision_invalid(string revision) { var args = new GitCreateTagArgs(TagName, revision); var cmd = new GitCreateTagCmd(args, TagMessageFile); Assert.Throws <ArgumentException>(() => cmd.Validate()); }
public void CreateTagWithMessageWritesTagMessageFile() { var args = new GitCreateTagArgs("tagname", "00000", TagOperation.Annotate, "hello world"); _controller.GetCreateTagCommand(args); _fileSystem.File.Received(1).WriteAllText(_tagMessageFile, "hello world"); }
public void ToLine_should_render_force_flag(bool force, string expected) { var args = new GitCreateTagArgs(TagName, Revision, TagOperation.SignWithDefaultKey, TagMessage, KeyId, force); var cmd = new GitCreateTagCmd(args, TagMessageFile); var cmdLine = cmd.ToLine(); Assert.AreEqual(expected, cmdLine); }
public void ToLine_should_render_different_operations(TagOperation operation, string expected) { var args = new GitCreateTagArgs(TagName, Revision, operation, signKeyId: KeyId, force: true); var cmd = new GitCreateTagCmd(args, TagMessageFile); var actualCmdLine = cmd.ToLine(); Assert.AreEqual(expected, actualCmdLine); }
public void CreateTagReturnsCmdResult(bool expectedCmdResult) { var args = new GitCreateTagArgs(TagName, Revision, TagOperation.Annotate); _uiCommands.StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null).Returns(expectedCmdResult); var actualCmdResult = _controller.CreateTag(args, null); Assert.AreEqual(expectedCmdResult, actualCmdResult); }
public void CreateTagReturnsCmdResult(bool expectedCmdResult) { GitCreateTagArgs args = CreateDefaultArgs(); args.OperationType = TagOperation.Annotate; _uiCommands.StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null).Returns(expectedCmdResult); bool actualCmdResult = _controller.CreateTag(args, null); Assert.AreEqual(expectedCmdResult, actualCmdResult); }
private GitCreateTagArgs CreateDefaultArgs() { GitCreateTagArgs args = new GitCreateTagArgs(); args.Revision = Revision; args.TagName = TagName; args.TagMessage = TagMessage; args.SignKeyId = KeyId; return(args); }
public void Tag_sign_with_default_gpg(bool force) { var args = new GitCreateTagArgs(TagName, Revision, TagOperation.SignWithDefaultKey, TagMessage, KeyId, force); var cmd = new GitCreateTagCmd(args, _tagMessageFile); var cmdLine = cmd.ToLine(); var expectedCmdLine = $"tag{(force ? " -f" : "")} -s -F \"{_tagMessageFile}\" \"{TagName}\" -- \"{Revision}\""; Assert.AreEqual(expectedCmdLine, cmdLine); }
public void CreateTagWithMessageWritesTagMessageFile() { GitCreateTagArgs args = CreateDefaultArgs(); args.OperationType = TagOperation.Annotate; _controller.CreateTag(args, null); var tagMagPath = Path.Combine(WorkingDir, "TAGMESSAGE"); _fileSystem.File.Received(1).WriteAllText(tagMagPath, TagMessage); }
public void CreateTagUsesGivenArgs() { var args = new GitCreateTagArgs(TagName, Revision, TagOperation.Lightweight, TagMessage, KeyId); _uiCommands.StartCommandLineProcessDialog(Arg.Do <IGitCommand>( cmd => { var createTagCmd = cmd as GitCreateTagCmd; Assert.AreEqual(args, createTagCmd.Arguments); } ), null); _controller.CreateTag(args, null); _uiCommands.Received(1).StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null); }
public void CreateTagWithMessageAssignsTagMessageFile() { var args = new GitCreateTagArgs(TagName, Revision, TagOperation.Annotate); _uiCommands.StartCommandLineProcessDialog(Arg.Do <IGitCommand>( cmd => { var createTagCmd = cmd as GitCreateTagCmd; Assert.AreEqual(_tagMessageFile, createTagCmd.TagMessageFileName); } ), null); _controller.CreateTag(args, null); _uiCommands.Received(1).StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null); }
public void CreateTagUsesGivenArgs() { GitCreateTagArgs args = CreateDefaultArgs(); _uiCommands.StartCommandLineProcessDialog(Arg.Do <IGitCommand>( cmd => { GitCreateTagCmd createTagCmd = cmd as GitCreateTagCmd; Assert.AreEqual(args, createTagCmd.Args); } ), null); _controller.CreateTag(args, null); _uiCommands.Received(1).StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null); }
public void CreateTagWithMessageAssignsTagMessageFile() { GitCreateTagArgs args = CreateDefaultArgs(); args.OperationType = TagOperation.Annotate; _uiCommands.StartCommandLineProcessDialog(Arg.Do <IGitCommand>( cmd => { GitCreateTagCmd createTagCmd = cmd as GitCreateTagCmd; Assert.AreEqual(Path.Combine(WorkingDir, "TAGMESSAGE"), createTagCmd.TagMessageFileName); } ), null); _controller.CreateTag(args, null); _uiCommands.Received(1).StartCommandLineProcessDialog(Arg.Any <IGitCommand>(), null); }
private string CreateTag() { if (string.IsNullOrWhiteSpace(commitPickerSmallControl1.SelectedCommitHash)) { MessageBox.Show(this, _noRevisionSelected.Text, _messageCaption.Text); return(string.Empty); } var createTagArgs = new GitCreateTagArgs(textBoxTagName.Text, commitPickerSmallControl1.SelectedCommitHash, GetSelectedOperation(annotate.SelectedIndex), tagMessage.Text, textBoxGpgKey.Text, ForceTag.Checked); if (!_gitTagController.CreateTag(createTagArgs, this)) { return(string.Empty); } DialogResult = DialogResult.OK; return(textBoxTagName.Text); }