public void CanAddNewCartWithProductToCartsDbSet() { var cart = NewCart.CreateCartFromProductSelection(_theUri, null, 1, 1, 9.99m); _context.Carts.Add(cart); Assert.AreEqual(1, _context.Carts.Local.Count); }
private int SeedCartAndReturnId(WebSiteOrderData repo) { var cart = NewCart.CreateCartFromProductSelection(_theUri, null, 1, 1, 9.99m); var createdCart = repo.StoreCartWithInitialProduct(cart); return(createdCart.CartId); }
public void ItemUpdateQuantityCanChangeStateToModified() { var cart = NewCart.CreateCartFromProductSelection("", null, 1, 1, 9.99m); cart.CartItems.First().UpdateQuantity(2); Assert.AreEqual(ObjectState.Modified, cart.CartItems.First().State); }
public void CanStoreCartWithInitialProduct() { var cart = NewCart.CreateCartFromProductSelection(_theUri, null, 1, 1, 9.99m); var data = new WebSiteOrderData(_context, _refContext); var resultCart = data.StoreCartWithInitialProduct(cart); WriteLog(); Assert.AreNotEqual(0, resultCart.CartId); }
private RevisitedCart InitializeCart(int productId, int quantity, decimal displayedPrice, string sourceUrl, string memberCookie) { var cart = NewCart.CreateCartFromProductSelection (sourceUrl, memberCookie, productId, quantity, displayedPrice); return(_siteOrderData.StoreCartWithInitialProduct(cart)); }
public void CanRetrieveCartAndItemsUsingCartCookieMocked() { var cart = NewCart.CreateCartFromProductSelection(_theUri, null, 1, 1, 9.99m); _cartsInMemory.Add(cart); var storedCartCookie = cart.CartCookie; var repo = new WebSiteOrderData(_scMockingContext, _refMockingContext); Assert.AreEqual(1, repo.RetrieveCart(storedCartCookie).CartItems.Count()); }
public void FixStateCanInterpretLocalState() { var cart = NewCart.CreateCartFromProductSelection(_theUri, null, 1, 1, 9.99m); cart.CartItems.First().UpdateQuantity(2); _context.Carts.Attach(cart); _context.FixState(); Assert.AreEqual(EntityState.Unchanged, _context.Entry(cart).State); Assert.AreEqual(EntityState.Modified, _context.Entry(cart.CartItems.First()).State); }
public void CanRetrieveCartFromRepoUsingCartId() { //Arrange var cart = NewCart.CreateCartFromProductSelection(_theUri, null, 1, 1, 9.99m); var data = new WebSiteOrderData(_context, _refContext); var createdCart = data.StoreCartWithInitialProduct(cart); Debug.WriteLine($"Stored Cart Id from database {createdCart.CartId}"); //Act (retrieve) and Assert Assert.AreEqual(createdCart.CartId, data.RetrieveCart(cart.CartId).CartId); }
public void CanCreateNewCartFromProductSelectionWithNoKnownCustomer() { var cart = NewCart.CreateCartFromProductSelection("http://thedatafarm.com", null, 1, 1, 9.99m); Assert.AreEqual(9.99m, cart.CartItems.Single().CurrentPrice); }