Esempio n. 1
0
        public void CanNotAddACustomerWithEmptyName()
        {
            CustomerBook customerBook = new CustomerBook();

            shouldThrowWithExceptionDo <Exception>(() => customerBook.addCustomerNamed(""),
                                                   (exceptionMessage) => CheckErrorMessageAndEmptyCustomer(CustomerBook.CUSTOMER_NAME_EMPTY, customerBook, exceptionMessage));
        }
Esempio n. 2
0
        public void AddingCustomerShouldNotTakeMoreThan50Milliseconds()
        {
            CustomerBook customerBook   = new CustomerBook();
            String       nombreCustomer = "John Lennon";

            TakesLessThan(TimeTakenBy(() => customerBook.addCustomerNamed(nombreCustomer)), 50);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 5
0
        public void CanNotRemoveNotAddedCustomer()
        {
            CustomerBook aCustomerBook = new CustomerBook();
            CheckInAndCheckOutCustomersForTesting someTest      = new CheckInAndCheckOutCustomersForTesting();
            CatchExceptionsForTesting             catchingATest = new CatchExceptionsForTesting();

            CustomerBookTestingExceptionCatcher.TryCustomerBookActionForTesting(aCustomerBook, someTest.RemoveJonhLennonFromCustomerBook, catchingATest.CatchRemovingNotAddedCustomer);
        }
Esempio n. 6
0
        public void RemovingCustomerShouldNotTakeMoreThan100Milliseconds()
        {
            CustomerBook customerBook   = new CustomerBook();
            String       nombreCustomer = "Paul McCartney";

            customerBook.addCustomerNamed(nombreCustomer);
            TakesLessThan(TimeTakenBy(() => customerBook.removeCustomerNamed(nombreCustomer)), 100);
        }
Esempio n. 7
0
        public void CanNotAddACustomerWithEmptyName()
        {
            CustomerBook aCustomerBook = new CustomerBook();
            CheckInAndCheckOutCustomersForTesting someTest      = new CheckInAndCheckOutCustomersForTesting();
            CatchExceptionsForTesting             catchingATest = new CatchExceptionsForTesting();

            CustomerBookTestingExceptionCatcher.TryCustomerBookActionForTesting(aCustomerBook, someTest.AddNoNamedToCustomerBook, catchingATest.CatchAddingACustomerWithEmptyName);
        }
Esempio n. 8
0
        public void RemovingCustomerShouldNotTakeMoreThan100Milliseconds()
        {
            CustomerBook customerBook  = new CustomerBook();
            String       paulMcCartney = "Paul McCartney";

            customerBook.addCustomerNamed(paulMcCartney);

            FunctionShouldTakeLessThan(() => customerBook.removeCustomerNamed(paulMcCartney), 100);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
0
        public void AddingCustomerShouldNotTakeMoreThan50Milliseconds()
        {
            CustomerBook aCustomerBook = new CustomerBook();
            CheckInAndCheckOutCustomersForTesting someTest = new CheckInAndCheckOutCustomersForTesting();

            Chronometer chronometer = new Chronometer();

            chronometer.CustomerActionShouldNotTakeMoreThanSomeMilliseconds(aCustomerBook, someTest.AddJonhLennonToCustomerBook, 50);
        }
Esempio n. 11
0
        public void RemovingCustomerShouldNotTakeMoreThan100Milliseconds()
        {
            CustomerBook aCustomerBook = new CustomerBook();
            CheckInAndCheckOutCustomersForTesting someTest = new CheckInAndCheckOutCustomersForTesting();

            someTest.AddPaulMcCartneyToCustomerBook(aCustomerBook);

            Chronometer chronometer = new Chronometer();

            chronometer.CustomerActionShouldNotTakeMoreThanSomeMilliseconds(aCustomerBook, someTest.RemovePaulMcCartneyFromCustomerBook, 100);
        }
Esempio n. 12
0
 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);
        }
Esempio n. 15
0
        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);
 }
Esempio n. 21
0
        public void CanNotRemoveNotAddedCustomer()
        {
            CustomerBook customerBook = new CustomerBook();

            MustFail <InvalidOperationException>(() => customerBook.removeCustomerNamed("John Lennon"), CustomerBook.INVALID_CUSTOMER_NAME, customerBook);
        }
Esempio n. 22
0
 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());
     }
 }
Esempio n. 23
0
        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);
        }