private void RefreshCommandCacheItems() { if (TabControl.SelectedTab == tabPageCommandCache) { RefreshListBox(CommandCacheItems, GitCommandCache.CachedCommands()); } }
public void TestTryGetFails() { Assert.IsFalse(GitCommandCache.TryGet(null, out var output, out var error)); Assert.IsFalse(GitCommandCache.TryGet(String.Empty, out output, out error)); Assert.IsNull(output); Assert.IsNull(error); }
private void GitLogFormLoad(object sender, EventArgs e) { RestorePosition("log"); LogItems.DataSource = Settings.GitLog.Commands(); CommandCacheItems.DataSource = GitCommandCache.CachedCommands().ToList(); }
public void TestAdd() { byte[] output = new byte[] { 11, 12 }; byte[] error = new byte[] { 13, 14 }; string[] expectedCachedCommand = { "git command" }; GitCommandCache.Add("git command", output, error); Assert.IsTrue(expectedCachedCommand.SequenceEqual(GitCommandCache.CachedCommands())); }
private void CommandCacheItems_SelectedIndexChanged(object sender, EventArgs e) { string command = (string)CommandCacheItems.SelectedItem; if (GitCommandCache.TryGet(command, out var cmdout, out var cmderr)) { commandCacheOutput.Text = command + "\n-------------------------------------\n\n"; Encoding encoding = GitModule.SystemEncoding; commandCacheOutput.Text += EncodingHelper.DecodeString(cmdout, cmderr, ref encoding).Replace("\0", "\\0"); }
public void TestTryGetFails() { byte[] output = null; byte[] error = null; Assert.IsFalse(GitCommandCache.TryGet(null, out output, out error)); Assert.IsFalse(GitCommandCache.TryGet(String.Empty, out output, out error)); Assert.IsNull(output); Assert.IsNull(error); }
public void TestTryGet() { byte[] originalOutput = new byte[] { 11, 12 }; byte[] originalError = new byte[] { 13, 14 }; GitCommandCache.Add("git command", originalOutput, originalError); Assert.IsTrue(GitCommandCache.TryGet("git command", out var cachedOutput, out var cachedError)); Assert.AreEqual(cachedOutput, originalOutput); Assert.AreEqual(cachedError, originalError); }
public void TestClean() { byte[] output = { 11, 12 }; byte[] error = { 13, 14 }; string[] expectedCachedCommand = { "git command" }; GitCommandCache.Add("git command", output, error); Assert.IsTrue(expectedCachedCommand.SequenceEqual(GitCommandCache.CachedCommands())); GitCommandCache.CleanCache(); Assert.IsFalse(GitCommandCache.CachedCommands().Any()); }
private void CommandCacheItems_SelectedIndexChanged(object sender, EventArgs e) { string command = CommandCacheItems.SelectedItem as string; string output; if (GitCommandCache.TryGet(command, out output)) { commandCacheOutput.Text = command + "\n-------------------------------------\n\n"; commandCacheOutput.Text += output.Replace("\0", "\\0"); } else { commandCacheOutput.Text = string.Empty; } }
protected void RefreshCommandCacheItems() { SendOrPostCallback method = o => { if (TabControl.SelectedTab == tabPageCommandCache) { bool selectLastIndex = CommandCacheItems.Items.Count == 0 || CommandCacheItems.SelectedIndex == CommandCacheItems.Items.Count - 1; CommandCacheItems.DataSource = GitCommandCache.CachedCommands(); if (selectLastIndex && CommandCacheItems.Items.Count > 0) { CommandCacheItems.SelectedIndex = CommandCacheItems.Items.Count - 1; } } }; syncContext.Post(method, this); }
public void TestAddCannotCache() { GitCommandCache.Add(null, null, null); Assert.IsFalse(GitCommandCache.CachedCommands().Any()); }
public void Cleanup() { GitCommandCache.CleanCache(); }