public void Test04After30MinutesCanNotAddABookInTheCart()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.RegisterClient("marcos", "123");
            Client aClient   = application.Login("marcos", "123");
            Guid   aCartId   = application.CreateCart(aClient.Id, aClient.Password);
            string aBook     = objectProvider.ABook();
            string otherBook = objectProvider.OtherBook();


            application.AddAQuantityOfAnItem(1, aBook, aCartId);
            application.Clock.UpdateSomeMinutes(30); // minutes

            try
            {
                application.AddAQuantityOfAnItem(1, otherBook, aCartId);
                Assert.Fail();
            }
            catch (TimeoutException e)
            {
                Assert.AreEqual("The cart has been expired", e.Message);

                Cart aCart = application.GetCart(aCartId);
                Assert.IsFalse(aCart.HasABook(otherBook));
            }
        }
        public void Test01CanGetAnEmptyCart()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.RegisterClient("marcos", "123");
            Client aClient = application.Login("marcos", "123");
            Guid   cartId  = application.CreateCart(aClient.Id, aClient.Password);

            Cart cart = application.GetCart(cartId);

            Assert.IsTrue(cart.IsEmpty());
        }
        public void Test02CanAddABookInACart()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.RegisterClient("marcos", "123");
            Client aClient = application.Login("marcos", "123");
            Guid   aCartId = application.CreateCart(aClient.Id, aClient.Password);

            application.AddAQuantityOfAnItem(1, objectProvider.ABook(), aCartId);

            Cart aCart = application.GetCart(aCartId);

            Assert.IsFalse(aCart.IsEmpty());
        }
        public void Test03WhenAddABookInACartThenTheBookIsInTheCart()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();
            string aBook = objectProvider.ABook();

            application.RegisterClient("marcos", "123");
            Client aClient = application.Login("marcos", "123");
            Guid   aCartId = application.CreateCart(aClient.Id, aClient.Password);

            application.AddAQuantityOfAnItem(1, aBook, aCartId);

            Cart aCart = application.GetCart(aCartId);

            Assert.IsTrue(aCart.HasABook(aBook));
        }
        public void Test05CanAddABookAfter32MinutesWhenTheLastUsageOfTheCartWasBeforeHisExpiration()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.RegisterClient("marcos", "123");
            Client aClient = application.Login("marcos", "123");
            Guid   aCartId = application.CreateCart(aClient.Id, aClient.Password);
            string aBook   = objectProvider.ABook();

            application.Clock.UpdateSomeMinutes(20); // 20 minutes
            application.AddAQuantityOfAnItem(1, aBook, aCartId);

            application.Clock.UpdateSomeMinutes(12); // 12 minutes
            application.AddAQuantityOfAnItem(1, aBook, aCartId);

            Cart aCart = application.GetCart(aCartId);

            Assert.IsTrue(aCart.HasABook(aBook));
        }