public void CanNotAddACustomerWithEmptyName() { CustomerBook customerBook = new CustomerBook(); shouldThrowWithExceptionDo <Exception>(() => customerBook.addCustomerNamed(""), (exceptionMessage) => CheckErrorMessageAndEmptyCustomer(CustomerBook.CUSTOMER_NAME_EMPTY, customerBook, exceptionMessage)); }
public void AddingCustomerShouldNotTakeMoreThan50Milliseconds() { CustomerBook customerBook = new CustomerBook(); String nombreCustomer = "John Lennon"; TakesLessThan(TimeTakenBy(() => customerBook.addCustomerNamed(nombreCustomer)), 50); }
public void CanNotRemoveNotAddedCustomer() { CustomerBook customerBook = new CustomerBook(); shouldThrowWithExceptionDo <InvalidOperationException>(() => customerBook.removeCustomerNamed("John Lennon"), (exception) => CheckErrorMessageAndEmptyCustomer(CustomerBook.INVALID_CUSTOMER_NAME, customerBook, exception)); }
public static void TryCustomerBookActionForTesting(CustomerBook customerBook, Action <CustomerBook> customerBookActionToTry, Action <CustomerBook, Exception> customerBookActionWhenExceptionIsThrown) { Action actionToTry = () => customerBookActionToTry(customerBook); Action <Exception> catchAction = (Exception e) => customerBookActionWhenExceptionIsThrown(customerBook, e); TryCatchForTesting(actionToTry, catchAction); }
public void CanNotRemoveNotAddedCustomer() { CustomerBook aCustomerBook = new CustomerBook(); CheckInAndCheckOutCustomersForTesting someTest = new CheckInAndCheckOutCustomersForTesting(); CatchExceptionsForTesting catchingATest = new CatchExceptionsForTesting(); CustomerBookTestingExceptionCatcher.TryCustomerBookActionForTesting(aCustomerBook, someTest.RemoveJonhLennonFromCustomerBook, catchingATest.CatchRemovingNotAddedCustomer); }
public void RemovingCustomerShouldNotTakeMoreThan100Milliseconds() { CustomerBook customerBook = new CustomerBook(); String nombreCustomer = "Paul McCartney"; customerBook.addCustomerNamed(nombreCustomer); TakesLessThan(TimeTakenBy(() => customerBook.removeCustomerNamed(nombreCustomer)), 100); }
public void CanNotAddACustomerWithEmptyName() { CustomerBook aCustomerBook = new CustomerBook(); CheckInAndCheckOutCustomersForTesting someTest = new CheckInAndCheckOutCustomersForTesting(); CatchExceptionsForTesting catchingATest = new CatchExceptionsForTesting(); CustomerBookTestingExceptionCatcher.TryCustomerBookActionForTesting(aCustomerBook, someTest.AddNoNamedToCustomerBook, catchingATest.CatchAddingACustomerWithEmptyName); }
public void RemovingCustomerShouldNotTakeMoreThan100Milliseconds() { CustomerBook customerBook = new CustomerBook(); String paulMcCartney = "Paul McCartney"; customerBook.addCustomerNamed(paulMcCartney); FunctionShouldTakeLessThan(() => customerBook.removeCustomerNamed(paulMcCartney), 100); }
public void CustomerActionShouldNotTakeMoreThanSomeMilliseconds(CustomerBook customerBook, Action <CustomerBook> customberBookAction, int maximumMillisecondsOfCustomerAction) { DateTime timeBeforeAction = DateTime.Now; customberBookAction(customerBook); DateTime timeAfterAction = DateTime.Now; Assert.IsTrue(timeAfterAction.Subtract(timeBeforeAction).TotalMilliseconds < maximumMillisecondsOfCustomerAction); }
public void AddingCustomerShouldNotTakeMoreThan50Milliseconds() { CustomerBook aCustomerBook = new CustomerBook(); CheckInAndCheckOutCustomersForTesting someTest = new CheckInAndCheckOutCustomersForTesting(); Chronometer chronometer = new Chronometer(); chronometer.CustomerActionShouldNotTakeMoreThanSomeMilliseconds(aCustomerBook, someTest.AddJonhLennonToCustomerBook, 50); }
public void RemovingCustomerShouldNotTakeMoreThan100Milliseconds() { CustomerBook aCustomerBook = new CustomerBook(); CheckInAndCheckOutCustomersForTesting someTest = new CheckInAndCheckOutCustomersForTesting(); someTest.AddPaulMcCartneyToCustomerBook(aCustomerBook); Chronometer chronometer = new Chronometer(); chronometer.CustomerActionShouldNotTakeMoreThanSomeMilliseconds(aCustomerBook, someTest.RemovePaulMcCartneyFromCustomerBook, 100); }
private void CheckErrorMessageAndEmptyCustomer(String expectedMessage, CustomerBook customerBook, Exception exception) { Assert.AreEqual(expectedMessage, exception.Message); Assert.IsTrue(customerBook.isEmpty()); }
public void RemovePaulMcCartneyFromCustomerBook(CustomerBook customerBookForTesting) { String paulMcCartney = "Paul McCartney"; customerBookForTesting.removeCustomerNamed(paulMcCartney); }
public void RemoveJonhLennonFromCustomerBook(CustomerBook customerBookForTesting) { String johnLennon = "John Lennon"; customerBookForTesting.removeCustomerNamed(johnLennon); }
public void AddingCustomerShouldNotTakeMoreThan50Milliseconds() { CustomerBook customerBook = new CustomerBook(); FunctionShouldTakeLessThan(() => customerBook.addCustomerNamed("paulMcCartney"), 50); }
public void CatchAddingACustomerWithEmptyName(CustomerBook customerBook, Exception exceptionThrown) { ThrowCorrectException(exceptionThrown, CustomerBook.CUSTOMER_NAME_EMPTY); CheckIfCustomerBookIsEmpty(customerBook); }
public void AddJonhLennonToCustomerBook(CustomerBook customerBookForTesting) { String johnLennon = "John Lennon"; customerBookForTesting.addCustomerNamed(johnLennon); }
public void AddNoNamedToCustomerBook(CustomerBook customerBookForTesting) { customerBookForTesting.addCustomerNamed(""); }
public void CheckIfCustomerBookIsEmpty(CustomerBook customerBook) { Assert.IsTrue(customerBook.isEmpty()); }
public void CatchRemovingNotAddedCustomer(CustomerBook customerBook, Exception exceptionThrown) { ThrowCorrectException(exceptionThrown, CustomerBook.INVALID_CUSTOMER_NAME); CheckIfCustomerBookIsEmpty(customerBook); }
public void CanNotRemoveNotAddedCustomer() { CustomerBook customerBook = new CustomerBook(); MustFail <InvalidOperationException>(() => customerBook.removeCustomerNamed("John Lennon"), CustomerBook.INVALID_CUSTOMER_NAME, customerBook); }
private void MustFail <T>(Action func, IComparable <String> aStringDescribingFailure, CustomerBook customerBook) where T : Exception { try { func(); Assert.Fail(); } catch (T e) { Assert.AreEqual(e.Message, aStringDescribingFailure); Assert.IsTrue(customerBook.isEmpty()); } }
public void CanNotAddACustomerWithEmptyName() { CustomerBook customerBook = new CustomerBook(); MustFail <Exception>(() => customerBook.addCustomerNamed(""), CustomerBook.CUSTOMER_NAME_EMPTY, customerBook); }
public void AddPaulMcCartneyToCustomerBook(CustomerBook customerBookForTesting) { String paulMcCartney = "Paul McCartney"; customerBookForTesting.addCustomerNamed(paulMcCartney); }