public void Create_Chronology_Valid_Basic()
        {
            // Does it work at all?
            var ch = new SemanticVersion[]
            {
                new SemanticVersion(1, 0),
                new SemanticVersion(1, 1),
                new SemanticVersion(1, 2),
            };
            var mv = new MonotonicVersioner(ch);

            Assert.AreEqual(1, mv.Compatibility);
            Assert.AreEqual(2, mv.Release);

            Assert.AreEqual(new SemanticVersion(1, 2), mv.Latest);

            Assert.AreEqual(ch.Last(), mv.LatestVersions[1]);

            Assert.IsTrue(mv.Chronology.SequenceEqual(ch));
        }
        public void Create_Chronology_Valid_StartsAtZero()
        {
            var ch = new SemanticVersion[]
            {
                new SemanticVersion(0, 0),
                new SemanticVersion(0, 1),
                new SemanticVersion(1, 2),
                new SemanticVersion(2, 3),
            };
            var mv = new MonotonicVersioner(ch);

            Assert.AreEqual(2, mv.Compatibility);
            Assert.AreEqual(3, mv.Release);

            Assert.AreEqual(ch.Last(), mv.Latest);

            Assert.AreEqual(ch[1], mv.LatestVersions[0]);
            Assert.AreEqual(ch[2], mv.LatestVersions[1]);
            Assert.AreEqual(ch[3], mv.LatestVersions[2]);

            Assert.AreEqual(3, mv.LatestVersions.Keys.Count());

            Assert.IsTrue(mv.Chronology.SequenceEqual(ch));
        }
        public void Create_Chronology_Valid_Complex()
        {
            var ch = new SemanticVersion[]
            {
                /* 0 */ new SemanticVersion(1, 0),
                /* 1 */ new SemanticVersion(1, 1),
                /* 2 */ new SemanticVersion(2, 2), // Latest, line 2
                /* 3 */ new SemanticVersion(1, 3),
                /* 4 */ new SemanticVersion(3, 4),
                /* 5 */ new SemanticVersion(3, 5), // Latest, line 3
                /* 6 */ new SemanticVersion(1, 6), // Latest, line 1 & overall
            };
            var mv = new MonotonicVersioner(ch);

            // [Compatibility] provides the greatest-value component
            // yet generated by the class, not the latest component.
            Assert.AreEqual(3, mv.Compatibility);
            // [Release] is not related to [Compatibility], and provides
            // the current release number.
            Assert.AreEqual(6, mv.Release);

            // [Latest] should provide the chronologically-latest version,
            // regardless of the line of compatibility.
            Assert.AreEqual(ch.Last(), mv.Latest);

            // [LatestVersions] should, as the name might imply, provide
            // the latest version in each line of compatibility.
            Assert.AreEqual(ch[6], mv.LatestVersions[1]);
            Assert.AreEqual(ch[2], mv.LatestVersions[2]);
            Assert.AreEqual(ch[5], mv.LatestVersions[3]);
            // Make sure these are the only keys in the collection.
            Assert.AreEqual(3, mv.LatestVersions.Keys.Count());

            // The chronology must be in order.
            Assert.IsTrue(mv.Chronology.SequenceEqual(ch));
        }
        public void Create_Chronology_Valid_StartsAtZero()
        {
            var ch = new SemanticVersion[]
            {
                new SemanticVersion(0, 0),
                new SemanticVersion(0, 1),
                new SemanticVersion(1, 2),
                new SemanticVersion(2, 3),
            };
            var mv = new MonotonicVersioner(ch);

            Assert.AreEqual(2, mv.Compatibility);
            Assert.AreEqual(3, mv.Release);

            Assert.AreEqual(ch.Last(), mv.Latest);

            Assert.AreEqual(ch[1], mv.LatestVersions[0]);
            Assert.AreEqual(ch[2], mv.LatestVersions[1]);
            Assert.AreEqual(ch[3], mv.LatestVersions[2]);

            Assert.AreEqual(3, mv.LatestVersions.Keys.Count());

            Assert.IsTrue(mv.Chronology.SequenceEqual(ch));
        }
        public void Create_Chronology_Valid_Complex()
        {
            var ch = new SemanticVersion[]
            {
                /* 0 */ new SemanticVersion(1, 0),
                /* 1 */ new SemanticVersion(1, 1),
                /* 2 */ new SemanticVersion(2, 2), // Latest, line 2
                /* 3 */ new SemanticVersion(1, 3),
                /* 4 */ new SemanticVersion(3, 4),
                /* 5 */ new SemanticVersion(3, 5), // Latest, line 3
                /* 6 */ new SemanticVersion(1, 6), // Latest, line 1 & overall
            };
            var mv = new MonotonicVersioner(ch);

            // [Compatibility] provides the greatest-value component
            // yet generated by the class, not the latest component.
            Assert.AreEqual(3, mv.Compatibility);
            // [Release] is not related to [Compatibility], and provides
            // the current release number.
            Assert.AreEqual(6, mv.Release);

            // [Latest] should provide the chronologically-latest version,
            // regardless of the line of compatibility.
            Assert.AreEqual(ch.Last(), mv.Latest);

            // [LatestVersions] should, as the name might imply, provide
            // the latest version in each line of compatibility.
            Assert.AreEqual(ch[6], mv.LatestVersions[1]);
            Assert.AreEqual(ch[2], mv.LatestVersions[2]);
            Assert.AreEqual(ch[5], mv.LatestVersions[3]);
            // Make sure these are the only keys in the collection.
            Assert.AreEqual(3, mv.LatestVersions.Keys.Count());

            // The chronology must be in order.
            Assert.IsTrue(mv.Chronology.SequenceEqual(ch));
        }
        public void Create_Chronology_Valid_Basic()
        {
            // Does it work at all?
            var ch = new SemanticVersion[]
            {
                new SemanticVersion(1, 0),
                new SemanticVersion(1, 1),
                new SemanticVersion(1, 2),
            };
            var mv = new MonotonicVersioner(ch);

            Assert.AreEqual(1, mv.Compatibility);
            Assert.AreEqual(2, mv.Release);

            Assert.AreEqual(new SemanticVersion(1, 2), mv.Latest);

            Assert.AreEqual(ch.Last(), mv.LatestVersions[1]);

            Assert.IsTrue(mv.Chronology.SequenceEqual(ch));
        }