Example #1
0
        public void SameValues_RemainIntact()
        {
            var input    = GeneratePowers(100, () => 101, () => 101);
            var expected = (Power[])input.Clone();
            var sut      = new PowersSorter();

            sut.Sort(input);

            input.Should().Equal(expected);
        }
Example #2
0
        public void SameBase_ExponentsGrow()
        {
            var random = new Random(12345);
            var input  = GeneratePowers(100, () => 999, () => random.Next(100, 10000));
            var sut    = new PowersSorter();

            sut.Sort(input);

            input.Select(x => x.Exponent).Should().BeInAscendingOrder();
        }
Example #3
0
        public void RandomMaxInput_PerformanceTests()
        {
            var random = new Random(12345);
            var input  = GeneratePowers(10000, () => random.Next(100, 10000), () => random.Next(100, 10000));

            var sut       = new PowersSorter();
            var stopwatch = new Stopwatch();

            stopwatch.Start();
            sut.Sort(input);
            stopwatch.Stop();

            this.output.WriteLine($"Max example took: {stopwatch.Elapsed.Milliseconds} ms. ");
        }
Example #4
0
        public void RandomSmallInput_VerifiesAccuratelly()
        {
            var random = new Random(12345);
            var input  = GeneratePowers(100, () => random.Next(2, 8), () => random.Next(2, 8));
            var copy   = input.ComputePowers().ToArray();

            Array.Sort(copy);

            var sut = new PowersSorter();

            sut.Sort(input);

            input.ComputePowers().ShouldAllBeEquivalentTo(copy);
        }
Example #5
0
        public void EmptySet_DoesNotFail()
        {
            var sut = new PowersSorter();

            sut.Sort(new Power[] { });
        }