Example #1
0
        public void Should_GenNext()
        {
            var lexorank     = LexoRank.Min();
            var nextLexorank = lexorank.GenNext();

            lexorank.CompareTo(nextLexorank).ShouldBe(-1);
        }
Example #2
0
        public void Should_InPrevBucket()
        {
            var lexorank  = LexoRank.Min();
            var lexorank1 = lexorank.InPrevBucket();

            lexorank.Format().Contains("0|").ShouldBeTrue();
            lexorank1.Format().Contains("2|").ShouldBeTrue();
        }
Example #3
0
        public void Should_Between()
        {
            var lexorank  = LexoRank.Min();
            var lexorank1 = lexorank.GenNext();
            var between   = lexorank.Between(lexorank1);

            lexorank.CompareTo(between).ShouldBeLessThan(0);
            lexorank1.CompareTo(between).ShouldBeGreaterThan(0);
        }
Example #4
0
        public void Should_Between_MinMax()
        {
            var minRank = LexoRank.Min();
            var maxRank = LexoRank.Max();
            var between = minRank.Between(maxRank);

            between.ToString().ShouldBe("0|hzzzzz:");
            minRank.CompareTo(between).ShouldBeLessThan(0);
            maxRank.CompareTo(between).ShouldBeGreaterThan(0);
        }
Example #5
0
        public void Should_Between_MinGenNext()
        {
            var minRank  = LexoRank.Min();
            var nextRank = minRank.GenNext();
            var between  = minRank.Between(nextRank);

            between.ToString().ShouldBe("0|0i0000:");
            minRank.CompareTo(between).ShouldBeLessThan(0);
            nextRank.CompareTo(between).ShouldBeGreaterThan(0);
        }
Example #6
0
        public void Should_Create_Million_Instances()
        {
            var cursorLexoRank = LexoRank.Min();
            var items          = new List <LexoRank> {
                cursorLexoRank
            };

            for (var i = 0; i < 1000000; i++)
            {
                cursorLexoRank = cursorLexoRank.GenNext();
                items.Add(cursorLexoRank);
            }

            items.Count.ShouldBe(1000001);
        }
Example #7
0
        public void Should_Between_Middle()
        {
            // Arrange
            var minRank = LexoRank.Min();
            var maxRank = LexoRank.Max();
            // Act
            var middleRank     = LexoRank.Middle();
            var prevMiddleRank = middleRank.GenPrev();
            var nextMiddleRank = middleRank.GenNext();

            // Assert
            middleRank.ToString().ShouldBe("0|hzzzzz:");
            minRank.CompareTo(middleRank).ShouldBeLessThan(0);
            maxRank.CompareTo(middleRank).ShouldBeGreaterThan(0);
            prevMiddleRank.CompareTo(middleRank).ShouldBeLessThan(0);
            nextMiddleRank.CompareTo(middleRank).ShouldBeGreaterThan(0);
        }
Example #8
0
        public void Should_Correct_OrderBy_Value()
        {
            var cursorLexoRank = LexoRank.Min();
            var items          = new List <LexoRank> {
                cursorLexoRank
            };

            for (var i = 0; i < 100000; i++)
            {
                cursorLexoRank = cursorLexoRank.GenNext();
                items.Add(cursorLexoRank);
            }

            var originItems = items.Select(x => x.Format()).ToList();
            var sortItems   = originItems.ToList();

            sortItems.Shuffle();
            sortItems = sortItems.OrderBy(x => x).ToList();

            originItems.SequenceEqual(sortItems).ShouldBeTrue();
        }
Example #9
0
        public void Should_Between_MoveTo(int prevStep, int nextStep, string expected)
        {
            // Arrange
            var prevRank = LexoRank.Min();

            for (var i = 0; i < prevStep; i++)
            {
                prevRank = prevRank.GenNext();
            }

            var nextRank = LexoRank.Min();

            for (var i = 0; i < nextStep; i++)
            {
                nextRank = nextRank.GenNext();
            }

            // Act
            var between = prevRank.Between(nextRank);

            // Assert
            between.ToString().ShouldBe(expected);
        }
Example #10
0
        public void Should_IsMin()
        {
            var lexorank = LexoRank.Min();

            lexorank.IsMin().ShouldBeTrue();
        }