public void TwoValueArrayWithEqualValues() { var val = Faker.Random.Int(0, MaxProfitFinder.MaxValue); var A = new[] { val, val }; TestInstance.GetMaxProfit(A).ShouldBe(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); }
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); }
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); }
public void SingleValueArray() { var A = new[] { Faker.Random.Int(0, MaxProfitFinder.MaxValue) }; TestInstance.GetMaxProfit(A).ShouldBe(0); }
public void TwoValueArrayWithTooBigValueInArray(int val1, int val2) { var A = new[] { val1, val2 }; Should.Throw <ArgumentException>(() => TestInstance.GetMaxProfit(A)); }
public void SingleValueArrayTooBigValueInArray() { var A = new[] { Faker.Random.Int(TooBigValue, int.MaxValue) }; TestInstance.GetMaxProfit(A).ShouldBe(0); }
public void TooLongArray() { var A = new int[TooLongValue]; Should.Throw <ArgumentException>(() => TestInstance.GetMaxProfit(A)); }
public void EmptyMaximumValidLengthArray() { var A = new int[MaxProfitFinder.MaxLength]; TestInstance.GetMaxProfit(A).ShouldBe(0); }
public void EmptyArray() { var A = new int[0]; TestInstance.GetMaxProfit(A).ShouldBe(0); }
public void CodilityTestArray() { var A = new[] { 23171, 21011, 21123, 21366, 21013, 21367 }; TestInstance.GetMaxProfit(A).ShouldBe(356); }