public void RemoveById_CartFound_RemoveFromDb() { var target = new FakeShoppingCartRepository(_databaseSettings); var cart1 = new CartBuilder().WithId(null).WithCustomerId("1").Build(); target.Create(cart1); target.Remove(cart1.Id); var result = target.FindById(cart1.Id); Assert.Null(result); }
public void Update_CartFound_UpdateValue() { var target = new FakeShoppingCartRepository(_databaseSettings); var cart1 = new CartBuilder().WithId(null).WithCustomerId("1").Build(); target.Create(cart1); cart1.CustomerId = "other"; target.Update(cart1.Id, cart1); var result = target.FindById(cart1.Id); Assert.Equal("other", cart1.CustomerId); }
public void GetById_hasThreeCartsInDB_returnReturnOnlyCartWithCorrectId() { var target = new FakeShoppingCartRepository(_databaseSettings); var cart1 = new CartBuilder().WithId(null).WithCustomerId("1").Build(); target.Create(cart1); var cart2 = new CartBuilder().WithId(null).WithCustomerId("2").Build(); target.Create(cart2); var cart3 = new CartBuilder().WithId(null).WithCustomerId("3").Build(); target.Create(cart3); var actual = target.FindById(cart2.Id); Assert.Equal(cart2, actual); }
public void GetById_CartNotFound_ReturnNull() { var target = new FakeShoppingCartRepository(_databaseSettings); var cart1 = new CartBuilder().WithId(null).WithCustomerId("1").Build(); target.Create(cart1); var cart2 = new CartBuilder().WithId(null).WithCustomerId("2").Build(); target.Create(cart2); var cart3 = new CartBuilder().WithId(null).WithCustomerId("3").Build(); target.Create(cart3); var actual = target.FindById(Invalid_ID); Assert.Null(actual); }