PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Mercurial.Net.Tests/AdditionalArgumentsTests.cs

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