PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Mercurial.Net.Tests/PushTests.cs

#
C# | 59 lines | 49 code | 10 blank | 0 comment | 0 complexity | 000d118cf53f904de69daeee039bf8d8 MD5 | raw file
 1using System;
 2using System.Linq;
 3using NUnit.Framework;
 4
 5namespace Mercurial.Tests
 6{
 7    [TestFixture]
 8    public class PushTests : DualRepositoryTestsBase
 9    {
10        #region Setup/Teardown
11
12        public override void SetUp()
13        {
14            base.SetUp();
15            Repo1.Init();
16            Repo2.Init();
17        }
18
19        #endregion
20
21        [TestCase((string)null)]
22        [TestCase("")]
23        [TestCase(" \n\r\t")]
24        [Test]
25        [Category("API")]
26        public void Push_WithNullOrEmptyDestination_ThrowsMercurialExecutionException(string destination)
27        {
28            Assert.Throws<ArgumentNullException>(() => Repo2.Push(destination));
29        }
30
31        [Test]
32        [Category("Integration")]
33        public void Push_IntoUnrelatedRepositoryWithForce_PushesSuccessfullyAndCreatesAnotherHead()
34        {
35            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);
36            WriteTextFileAndCommit(Repo2, "test2.txt", "dummy", "dummy", true);
37
38            Repo2.Push(
39                Repo1.Path, new PushCommand
40                {
41                    Force = true,
42                });
43
44            Changeset[] log = Repo1.Heads().ToArray();
45
46            Assert.That(log.Length, Is.EqualTo(2));
47        }
48
49        [Test]
50        [Category("Integration")]
51        public void Push_IntoUnrelatedRepository_ThrowsMercurialExecutionException()
52        {
53            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);
54            WriteTextFileAndCommit(Repo2, "test2.txt", "dummy", "dummy", true);
55
56            Assert.Throws<MercurialExecutionException>(() => Repo2.Push(Repo1.Path));
57        }
58    }
59}