コード例 #1
0
        public void TwoValueArrayWithEqualValues()
        {
            var val = Faker.Random.Int(0, MaxProfitFinder.MaxValue);
            var A   = new[] { val, val };

            TestInstance.GetMaxProfit(A).ShouldBe(0);
        }
コード例 #2
0
        public void TwoValueArrayWithProfit()
        {
            var val1 = Faker.Random.Int(0, MaxProfitFinder.MaxValue - 1);
            var val2 = val1 + 1;
            var A    = new[] { val1, val2 };

            TestInstance.GetMaxProfit(A).ShouldBe(val2 - val1);
        }
コード例 #3
0
        public void TwoValueArrayWithLoss()
        {
            var val1 = Faker.Random.Int(1, MaxProfitFinder.MaxValue);
            var val2 = val1 - 1;
            var A    = new[] { val1, val2 };

            TestInstance.GetMaxProfit(A).ShouldBe(0);
        }
コード例 #4
0
        public void LargeArrayWithoutProfit()
        {
            const int length  = 100;
            var       valNext = MaxProfitFinder.MaxValue;

            var valueList = new List <int>(length)
            {
                valNext
            };

            for (var i = 0; i < length - 1; i++)
            {
                valNext = Faker.Random.Int(0, valNext - 1);
                valueList.Add(valNext);
            }

            var A = valueList.ToArray();

            TestInstance.GetMaxProfit(A).ShouldBe(0);
        }
コード例 #5
0
        public void SingleValueArray()
        {
            var A = new[] { Faker.Random.Int(0, MaxProfitFinder.MaxValue) };

            TestInstance.GetMaxProfit(A).ShouldBe(0);
        }
コード例 #6
0
        public void TwoValueArrayWithTooBigValueInArray(int val1, int val2)
        {
            var A = new[] { val1, val2 };

            Should.Throw <ArgumentException>(() => TestInstance.GetMaxProfit(A));
        }
コード例 #7
0
        public void SingleValueArrayTooBigValueInArray()
        {
            var A = new[] { Faker.Random.Int(TooBigValue, int.MaxValue) };

            TestInstance.GetMaxProfit(A).ShouldBe(0);
        }
コード例 #8
0
        public void TooLongArray()
        {
            var A = new int[TooLongValue];

            Should.Throw <ArgumentException>(() => TestInstance.GetMaxProfit(A));
        }
コード例 #9
0
        public void EmptyMaximumValidLengthArray()
        {
            var A = new int[MaxProfitFinder.MaxLength];

            TestInstance.GetMaxProfit(A).ShouldBe(0);
        }
コード例 #10
0
        public void EmptyArray()
        {
            var A = new int[0];

            TestInstance.GetMaxProfit(A).ShouldBe(0);
        }
コード例 #11
0
        public void CodilityTestArray()
        {
            var A = new[] { 23171, 21011, 21123, 21366, 21013, 21367 };

            TestInstance.GetMaxProfit(A).ShouldBe(356);
        }