PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/Mercurial.Net.Tests/AdditionalArgumentsTests.cs

#
C# | 46 lines | 40 code | 6 blank | 0 comment | 0 complexity | 7ef8fec8bdbcb6f290e772c24f13d149 MD5 | raw file
 1using System;
 2using System.Globalization;
 3using NUnit.Framework;
 4
 5namespace Mercurial.Tests
 6{
 7    [TestFixture]
 8    [Category("Integration")]
 9    public class AdditionalArgumentsTests : SingleRepositoryTestsBase
10    {
11        [Test]
12        public void Log_WithUnknownArgument_ThrowsMercurialExecutionException()
13        {
14            Repo.Init();
15
16            var command = new LogCommand();
17            command.AdditionalArguments.Add("--dummyargument");
18
19            Assert.Throws<MercurialExecutionException>(() => Repo.Execute(command));
20        }
21
22        [Test]
23        public void Log_WithUnknownArgument_ThrowsMercurialExecutionExceptionThatMentionesArgument()
24        {
25            Repo.Init();
26
27            var command = new LogCommand();
28            command.AdditionalArguments.Add("--dummyargument");
29
30            try
31            {
32                Repo.Execute(command);
33            }
34            catch (MercurialExecutionException ex)
35            {
36                Assert.That(ex.Message, Is.StringContaining("hg log: option --dummyargument not recognized"));
37                return;
38            }
39            catch (Exception ex)
40            {
41                Assert.Fail(string.Format(CultureInfo.InvariantCulture, "Log with unknown argument should not have thrown {0}", ex.GetType().Name));
42            }
43            Assert.Fail("Log with unknown argument should have thrown MercurialExecutionException");
44        }
45    }
46}