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

/Mercurial.Net.Tests/ForgetTests.cs

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