Ejemplo n.º 1
0
 private void RefreshCommandCacheItems()
 {
     if (TabControl.SelectedTab == tabPageCommandCache)
     {
         RefreshListBox(CommandCacheItems, GitCommandCache.CachedCommands());
     }
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
        private void GitLogFormLoad(object sender, EventArgs e)
        {
            RestorePosition("log");

            LogItems.DataSource = Settings.GitLog.Commands();

            CommandCacheItems.DataSource = GitCommandCache.CachedCommands().ToList();
        }
Ejemplo n.º 4
0
        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()));
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 9
0
        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;
            }
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
 public void TestAddCannotCache()
 {
     GitCommandCache.Add(null, null, null);
     Assert.IsFalse(GitCommandCache.CachedCommands().Any());
 }
Ejemplo n.º 12
0
 public void Cleanup()
 {
     GitCommandCache.CleanCache();
 }