コード例 #1
0
 public static void GetMaxProfit_RespectsTime()
 {
     Assert.That(AppleStocks.GetMaxProfit(new int[] { 15, 1, 5 }), Is.EqualTo(4));
 }
コード例 #2
0
 public static void GetMaxProfit_MustBuyAndSellStock_Cont()
 {
     Assert.That(AppleStocks.GetMaxProfit(new int[] { 5, -2, -3 }), Is.EqualTo(-1));
 }
コード例 #3
0
 public static void GetMaxProfit_HandlesInvalidArguments()
 {
     Assert.Throws <ArgumentNullException>(() => AppleStocks.GetMaxProfit(null));
 }
コード例 #4
0
 public static void GetMaxProfit_HandlesNotEnoughStockPrices()
 {
     Assert.Throws <ArgumentException>(() => AppleStocks.GetMaxProfit(new int[0]));
     Assert.Throws <ArgumentException>(() => AppleStocks.GetMaxProfit(new int[] { 1 }));
 }
コード例 #5
0
 public static void GetMaxProfit_BasicExample_ReturnsExpected()
 {
     Assert.That(AppleStocks.GetMaxProfit(new int[] { 10, 7, 5, 8, 11, 9 }), Is.EqualTo(6));
 }