Ejemplo n.º 1
0
        public void Identify_RepositoryOverHttp_ReturnsRevSpec()
        {
            IdentifyCommand cmd = new IdentifyCommand().WithPath("https://hg01.codeplex.com/mercurialnet");

            NonPersistentClient.Execute(cmd);

            Assert.That(cmd.Result, Is.Not.Null);
        }
Ejemplo n.º 2
0
        public void GetHelpText_ForLogCommand_ReturnsText()
        {
            var command = new HelpCommand
            {
                Topic = "log"
            };

            NonPersistentClient.Execute(command);
            string text = command.Result;

            Assert.That(text, Is.StringContaining("show revision history of entire repository or files"));
        }
Ejemplo n.º 3
0
        public void GetHelpText_WithoutGlobalOptions_DoesNotIncludeGlobalOptions()
        {
            var command = new HelpCommand
            {
                Topic = "log"
            };

            NonPersistentClient.Execute(command);
            string text = command.Result;

            Assert.That(text, Is.Not.StringContaining("enable debugging output"));
        }
Ejemplo n.º 4
0
        public void GetHelpText_WithGlobalOptions_IncludesGlobalOptions()
        {
            var command = new HelpCommand
            {
                Topic             = "log",
                IncludeGlobalHelp = true
            };

            NonPersistentClient.Execute(command);
            string text = command.Result;

            Assert.That(text, Contains.Substring("enable debugging output"));
        }
Ejemplo n.º 5
0
        protected override void OnCheckConnection(PluginProfileErrorCollection errors, MercurialPluginProfile settings)
        {
            settings.ValidateUri(errors);

            if (!errors.Any())
            {
                var identifyCommand = new IdentifyCommand().WithPath(settings.Uri).WithTimeout(20);
                NonPersistentClient.Execute(identifyCommand);
                if (identifyCommand.RawExitCode != 0)
                {
                    throw new Exception("Can't establish connection");
                }
            }
        }
Ejemplo n.º 6
0
        public void Identify_WebSiteThatIsntRepository_ThrowsMercurialExecutionException()
        {
            try
            {
                new WebClient().DownloadString("http://localhost");
            }
            catch (WebException)
            {
                Assert.Inconclusive("No web server set up locally, test not executed");
                return;
            }

            IdentifyCommand cmd = new IdentifyCommand().WithPath("http://localhost");

            Assert.Throws <MercurialExecutionException>(() => NonPersistentClient.Execute(cmd));
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Refreshes the client configuration information by calling the Mercurial command line
        /// client and asking it to report the current configuration.
        /// </summary>
        public void Refresh()
        {
            lock (_Configuration)
            {
                _Configuration.Clear();
                var command = new ShowConfigCommand();
                NonPersistentClient.Execute(command);

                foreach (ConfigurationEntry entry in command.Result.ToArray())
                {
                    Dictionary <string, string> section;
                    if (!_Configuration.TryGetValue(entry.Section, out section))
                    {
                        section = new Dictionary <string, string>();
                        _Configuration[entry.Section] = section;
                    }
                    section[entry.Name] = entry.Value;
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Refreshes the client configuration information by calling the Mercurial command line
        /// client and asking it to report the current configuration.
        /// </summary>
        /// <param name="currentWorkingDirectory">Path to repo passed through --cwd param to Mercurial</param>
        public void Refresh(string currentWorkingDirectory = null)
        {
            lock (_Configuration)
            {
                _Configuration.Clear();
                var command = new ShowConfigCommand();
                if (currentWorkingDirectory != null)
                {
                    command.AddArgument($"--cwd {currentWorkingDirectory}");
                }
                NonPersistentClient.Execute(command);

                foreach (ConfigurationEntry entry in command.Result.ToArray())
                {
                    Dictionary <string, string> section;
                    if (!_Configuration.TryGetValue(entry.Section, out section))
                    {
                        section = new Dictionary <string, string>();
                        _Configuration[entry.Section] = section;
                    }
                    section[entry.Name] = entry.Value;
                }
            }
        }
Ejemplo n.º 9
0
        public void Identify_WebSiteThatDoesNotExist_ThrowsMercurialExecutionException()
        {
            IdentifyCommand cmd = new IdentifyCommand().WithPath("http://localhostxyzklm");

            Assert.Throws <MercurialExecutionException>(() => NonPersistentClient.Execute(cmd));
        }
Ejemplo n.º 10
0
        public void Execute_NullCommand_ThrowsArgumentNullException()
        {
            IMercurialCommand command = null;

            Assert.Throws <ArgumentNullException>(() => NonPersistentClient.Execute(command));
        }
Ejemplo n.º 11
0
        public void Execute_NullOrEmptyRepositoryPath_ThrowsArgumentNullException(string input)
        {
            var command = new DummyCommand();

            Assert.Throws <ArgumentNullException>(() => NonPersistentClient.Execute(input, command));
        }