コード例 #1
0
        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));
            }
        }
コード例 #2
0
        public void Test08WhenAClientHasNoPurchasesThenHisListOfPurchasesIsEmpty()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.RegisterClient("marcos", "123");
            Client aClient = objectProvider.AClient();

            Assert.IsTrue(application.PurchasesFor(aClient).Item2 == 0);//TODO; ver esta monstruosidad. Asertar lo que corresponda.
        }
コード例 #3
0
        public void Test00CanRegisterAndLoginAnUSer()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.RegisterClient("marcos", "123");
            Client aClient = application.Login("marcos", "123");

            Assert.IsTrue(aClient.SameUserNameAndPassword("marcos", "123"));
        }
コード例 #4
0
        public void Test11WhenGetListCartOfAnEmptyCartThenIsEmpty()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

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

            Assert.IsTrue(application.ListCart(aCartId).Count == 0);
        }
コード例 #5
0
        public void Test12WhenAddBookToCartAndGetListCartThenIsNotEmpty()
        {
            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);

            Assert.IsFalse(application.ListCart(aCartId).Count == 0);
        }
コード例 #6
0
        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());
        }
コード例 #7
0
        public void Test13WhenAddAQuantityTimesABookToCartAndGetListCartThereAreTheBookWithThisQuantity()
        {
            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.AddAQuantityOfAnItem(4, aBook, aCartId);

            Assert.IsTrue(application.ContainsThisQuantityOfBook(aCartId, aBook, 4));
        }
コード例 #8
0
        public void Test09WhenAClientHasPurchasesThenHisPurchasesIsNotEmpty()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.RegisterClient("marcos", "123");
            Client aClient = application.Login("marcos", "123"); //TODO: revisar si no queremos seguir desacoplando los ID de la base de datos.

            Guid aCartId = application.CreateCart(aClient.Id, aClient.Password);

            application.AddAQuantityOfAnItem(1, objectProvider.ABook(), aCartId);
            application.CheckoutCart(aCartId, objectProvider.AValidCreditCard(), objectProvider.ACatalog());

            Assert.IsTrue(application.PurchasesFor(aClient).Item2 != 0);//TODO; ver esta monstruosidad. Asertar lo que corresponda.
        }
コード例 #9
0
        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());
        }
コード例 #10
0
        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));
        }
コード例 #11
0
        public void Test10WhenAClientBuyABookHisPurchasesHasRegisteredThatSale()
        {
            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);
            Guid transactionId = application.CheckoutCart(aCartId, objectProvider.AValidCreditCard(), objectProvider.ACatalog());

            Sale aSale = application.GetSale(transactionId);

            Assert.IsTrue(application.PurchasesContainsASaleForAClient(aSale, aClient));
        }
コード例 #12
0
        public void Test000CanNotRegisterADuplicatedUser()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.RegisterClient("marcos", "123");
            try
            {
                application.RegisterClient("marcos", "123");
                Assert.Fail();
            }
            catch (RegisterException e)
            {
                Assert.AreEqual("User already registered", e.Message);
            }
        }
コード例 #13
0
        public void Test06CanCheckoutACartWithOneBookWithASpecificCatalog()
        {
            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);

            Guid transactionId = application.CheckoutCart(aCartId, objectProvider.AValidCreditCard(), objectProvider.ACatalog());

            Sale sale = application.GetSale(transactionId);

            Assert.IsTrue(application.IsSaleRegistered(sale));
        }
コード例 #14
0
        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));
        }
コード例 #15
0
        public void Test07CanNotCheckoutACartWithAnInvalidBookWithASpecificCatalog()
        {
            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.AnInvalidBook(), aCartId);

            try
            {
                application.CheckoutCart(aCartId, objectProvider.AValidCreditCard(), objectProvider.ACatalog());
                Assert.Fail();
            }
            catch (ArgumentException e)
            {
                Assert.AreEqual("The cart has invalid books!", e.Message);
            }
        }
コード例 #16
0
        public void TearDown()
        {
            IYourBooksApplication application = objectProvider.YourBooksApplication();

            application.DeleteUser("marcos", "123");
        }
コード例 #17
0
 public AccountController(IYourBooksApplication anApplication)
 {
     Application = anApplication;
 }
コード例 #18
0
 public HomeController(IYourBooksApplication anApplication)
 {
     Application = anApplication;
 }
コード例 #19
0
 public void SetUp()
 {
     Environment = new DevelopmentEnvironment(new TransientDataBaseStrategy());
     Application = Environment.GetApplication();
     Controller  = new HomeController(Application);
 }
コード例 #20
0
 public TusLibrosControllerFactory()
 {
     Environment = new DevelopmentEnvironment(new TransientDataBaseStrategy());
     Application = Environment.GetApplication();
 }