PageRenderTime 32ms CodeModel.GetById 13ms app.highlight 13ms RepoModel.GetById 1ms app.codeStats 1ms

/MSBuildVersioning.Test/SvnInfoProviderTest.cs

#
C# | 113 lines | 96 code | 17 blank | 0 comment | 0 complexity | cef95792ea7ff7adec2cdff45e7409c6 MD5 | raw file
  1using System;
  2using System.Collections.Generic;
  3using System.Diagnostics;
  4using System.IO;
  5using System.Text;
  6using NUnit.Framework;
  7
  8namespace MSBuildVersioning.Test
  9{
 10    [TestFixture]
 11    public class SvnInfoProviderTest
 12    {
 13        private const string TestRepositoriesPath = @"..\..\..\TestRepositories";
 14
 15        [TestFixtureSetUp]
 16        public void Init()
 17        {
 18            using (Process process = new Process())
 19            {
 20                process.StartInfo.FileName = "powershell.exe";
 21                process.StartInfo.Arguments = @"-ExecutionPolicy Bypass .\build-svn.ps1";
 22                process.StartInfo.WorkingDirectory = TestRepositoriesPath;
 23
 24                process.Start();
 25                process.WaitForExit();
 26            }
 27        }
 28
 29        [TestFixtureTearDown]
 30        public void CleanUp()
 31        {
 32            using (Process process = new Process())
 33            {
 34                process.StartInfo.FileName = "powershell.exe";
 35                process.StartInfo.Arguments = @"-ExecutionPolicy Bypass .\clean-svn.ps1";
 36                process.StartInfo.WorkingDirectory = TestRepositoriesPath;
 37
 38                process.Start();
 39                process.WaitForExit();
 40            }
 41        }
 42
 43        public SvnInfoProvider SvnWC1
 44        {
 45            get { return new SvnInfoProvider() { Path = Path.Combine(TestRepositoriesPath, "SvnWC1") }; }
 46        }
 47
 48        public SvnInfoProvider SvnWC2
 49        {
 50            get { return new SvnInfoProvider() { Path = Path.Combine(TestRepositoriesPath, "SvnWC2") }; }
 51        }
 52
 53        [Test]
 54        public void GetRevisionNumberTest()
 55        {
 56            Assert.AreEqual(6, SvnWC1.GetRevisionNumber());
 57            Assert.AreEqual(5, SvnWC2.GetRevisionNumber());
 58        }
 59
 60        [Test]
 61        public void IsMixedRevisionsTest()
 62        {
 63            Assert.IsTrue(SvnWC1.IsMixedRevisions());
 64            Assert.IsFalse(SvnWC2.IsMixedRevisions());
 65        }
 66
 67        [Test]
 68        public void IsWorkingCopyDirtyTest()
 69        {
 70            Assert.IsFalse(SvnWC1.IsWorkingCopyDirty());
 71            Assert.IsTrue(SvnWC2.IsWorkingCopyDirty());
 72        }
 73
 74        [Test]
 75        public void GetRepositoryUrlTest()
 76        {
 77            string repoUrl = "file:///" + Path.GetFullPath(TestRepositoriesPath).Replace('\\', '/') + "/SvnRepo";
 78
 79            Assert.AreEqual(repoUrl, SvnWC1.GetRepositoryUrl());
 80            Assert.AreEqual(repoUrl + "/branches/beef", SvnWC2.GetRepositoryUrl());
 81        }
 82
 83        [Test]
 84        public void GetRepositoryRootTest()
 85        {
 86            string repoUrl = "file:///" + Path.GetFullPath(TestRepositoriesPath).Replace('\\', '/') + "/SvnRepo";
 87
 88            Assert.AreEqual(repoUrl, SvnWC1.GetRepositoryRoot());
 89            Assert.AreEqual(repoUrl, SvnWC2.GetRepositoryRoot());
 90        }
 91
 92        [Test]
 93        public void GetRepositoryPathTest()
 94        {
 95            Assert.AreEqual("/", SvnWC1.GetRepositoryPath());
 96            Assert.AreEqual("/branches/beef", SvnWC2.GetRepositoryPath());
 97        }
 98
 99        [Test]
100        public void GetBranchTest()
101        {
102            Assert.AreEqual("", SvnWC1.GetBranch());
103            Assert.AreEqual("beef", SvnWC2.GetBranch());
104        }
105
106        [Test]
107        public void GetTagTest()
108        {
109            Assert.AreEqual("", SvnWC1.GetTag());
110            Assert.AreEqual("", SvnWC2.GetTag());
111        }
112    }
113}