public void WithDraw_Failed_On_Insufficient_Fund() { IAccount account = new CashAccount("1234123412341234", 100); ICard card = new CashCard(account, 1234); var retVal = card.WithDraw(1234, 200); Assert.IsFalse(retVal == 0); }
public void WithDraw_Successful_On_Sufficient_Fund() { IAccount account = new CashAccount("1234123412341234", 100); ICard card = new CashCard(account, 1234); var retVal = card.WithDraw(1234, 5); Assert.IsTrue(retVal == 0); }
public void WithDrawal_Failed_On_Invalid_Pin() { var initBalance = 100; IAccount account = new CashAccount("1234123412341234", initBalance); ICard card = new CashCard(account, 1234); var retVal = card.WithDraw(9999, 5); }
public void WithDrawal_Successful_On_Valid_Pin() { var initBalance = 100; IAccount account = new CashAccount("1234123412341234", initBalance); ICard card = new CashCard(account, 1234); var retVal = card.WithDraw(1234, 5); Assert.IsTrue(retVal == 0); }
public void Parallel_WithDrawals_Failed_After_Funds_Runout() { var initBalance = 100; IAccount account = new CashAccount("1234123412341234", initBalance); ICard card = new CashCard(account, 1234); int total = 0; Parallel.For(0, 10, () => 0, (i, loop, subtotal) => { subtotal += card.WithDraw(1234, 20); return(subtotal); }, (x) => { Interlocked.Add(ref total, x); } ); Assert.IsTrue(total == -5); }