public void CanLoadCartWithNoItems() { string databaseName = Guid.NewGuid().ToString(); var context = new GlobalmanticsContext(new DbContextOptionsBuilder() .UseInMemoryDatabase(databaseName: databaseName) .Options); var userService = new UserService(context); var cartService = new CartService(context); var user = userService.GetUserByEmail("*****@*****.**"); context.SaveChanges(); var cart = cartService.GetCartForUser(user); context.SaveChanges(); cart.CartItems.Count().Should().Be(0); }
private void InitializeCartWithOneItem(string databaseName) { var context = new GlobalmanticsContext(new DbContextOptionsBuilder() .UseInMemoryDatabase(databaseName) .Options); var user = context.Add(User.Create("*****@*****.**")) .Entity; context.SaveChanges(); var cart = context.Add(Cart.Create(user.UserId)).Entity; var catalogItem = context.Add(CatalogItem.Create ( sku: "CAFE-314", description: "1 Pound Guatemalan Coffee Beans", unitPrice: 18.80m )).Entity; cart.AddItem(catalogItem, 2); context.SaveChanges(); }
public void CanCreateUser() { var context = new GlobalmanticsContext(); var userSerice = new UserService(context); User user = userSerice.GetUserByEmail( "*****@*****.**"); context.SaveChanges(); user.UserId.Should().NotBe(0); user.Email.Should().Be("*****@*****.**"); }
public void CanCreateUser() { var context = new GlobalmanticsContext(new DbContextOptionsBuilder() .UseInMemoryDatabase() .Options); var userService = new UserService(context); User user = userService.GetUserByEmail( "*****@*****.**"); context.SaveChanges(); user.UserId.Should().NotBe(0); user.Email.Should().Be("*****@*****.**"); }