PageRenderTime 28ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/Mercurial.Net.Tests/ForgetTests.cs

#
C# | 55 lines | 49 code | 6 blank | 0 comment | 0 complexity | 58c44266d72985438489a86a14e4b89c MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using NUnit.Framework;
  5. namespace Mercurial.Tests
  6. {
  7. [TestFixture]
  8. public class ForgetTests : SingleRepositoryTestsBase
  9. {
  10. [TestCase((string)null)]
  11. [TestCase("")]
  12. [TestCase(" \t\n\r")]
  13. [Test]
  14. [Category("API")]
  15. public void Forget_NullOrEmptyPath_ThrowsArgumentNullException(string input)
  16. {
  17. Assert.Throws<ArgumentNullException>(() => Repo.Forget(input));
  18. }
  19. [Test]
  20. [Category("Integration")]
  21. public void Forget_InUninitializedRepository_ThrowsMercurialExecutionException()
  22. {
  23. File.WriteAllText(Path.Combine(Repo.Path, "test.txt"), "contents");
  24. Assert.Throws<MercurialExecutionException>(() => Repo.Forget("test.txt"));
  25. }
  26. [Test]
  27. [Category("Integration")]
  28. public void Forget_TrackedFile_MarksFileForForgettal()
  29. {
  30. Repo.Init();
  31. WriteTextFileAndCommit(Repo, "test.txt", "dummy", "dummy", true);
  32. Repo.Forget("test.txt");
  33. FileStatus[] status = Repo.Status().ToArray();
  34. CollectionAssert.AreEqual(
  35. status, new[]
  36. {
  37. new FileStatus(FileState.Removed, "test.txt"),
  38. });
  39. }
  40. [Test]
  41. [Category("Integration")]
  42. public void Forget_UnTrackedFile_ThrowsMercurialExecutionException()
  43. {
  44. Repo.Init();
  45. File.WriteAllText(Path.Combine(Repo.Path, "test.txt"), "contents");
  46. Assert.Throws<MercurialExecutionException>(() => Repo.Forget("test.txt"));
  47. }
  48. }
  49. }