PageRenderTime 17ms CodeModel.GetById 14ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/Mercurial.Net.Tests/MercurialVersionAttributeTests.cs

#
C# | 43 lines | 38 code | 5 blank | 0 comment | 0 complexity | aa6cda0a2d693aa041ad06cc7743b089 MD5 | raw file
 1using System;
 2using Mercurial.Versions;
 3using NUnit.Framework;
 4
 5namespace Mercurial.Tests
 6{
 7    [TestFixture]
 8    public class MercurialVersionAttributeTests
 9    {
10        [Test]
11        [Category("API")]
12        [TestCase("", "0.0.0.0", "65535.65535.65535.65535")]
13        [TestCase("1", "1.0.0.0", "1.65535.65535.65535")]
14        [TestCase("1.2", "1.2.0.0", "1.2.65535.65535")]
15        [TestCase("1.2.3", "1.2.3.0", "1.2.3.65535")]
16        [TestCase("1.2.3.4", "1.2.3.4", "1.2.3.4")]
17        public void VersionStringParsing_WithTestCases(string versionString, string expectedFromVersionString, string expectedToVersionString)
18        {
19            var attr = new MercurialVersionAttribute(versionString, versionString);
20
21            Assert.That(attr.FromVersion, Is.EqualTo(new Version(expectedFromVersionString)));
22            Assert.That(attr.ToVersion, Is.EqualTo(new Version(expectedToVersionString)));
23        }
24
25        [Test]
26        [Category("API")]
27        [TestCase("1.0.0.0", "2.0.0.0", "1.0.0.0", "2.0.0.0", 0)]
28        [TestCase("1", "1", "2", "2", -1)] // 1 .. 1.* < 2 .. 2.*
29        [TestCase("1", "1", "1.6", "1.6", +1)] // 1.6 .. 1.6.* < 1 .. 1.*
30        [TestCase("1.6", "1.6", "1.6.2", "1.6.2", +1)] // 1.6.2 .. 1.6.2.* < 1.6 .. 1.6.*
31        public void VersionStringOrdering_WithTestCases(string fromVersion1, string toVersion1, string fromVersion2, string toVersion2, int expectedOrdering)
32        {
33            var attr1 = new MercurialVersionAttribute(fromVersion1, toVersion1);
34            var attr2 = new MercurialVersionAttribute(fromVersion2, toVersion2);
35
36            int ordering = attr1.CompareTo(attr2);
37            Assert.That(ordering, Is.EqualTo(expectedOrdering));
38
39            ordering = attr2.CompareTo(attr1);
40            Assert.That(ordering, Is.EqualTo(-expectedOrdering));
41        }
42    }
43}