public OrderService( BetaBrewDbContext dbContext, ILogger <OrderService> logger, IProductService productService, IInventoryService inventoryService) { _db = dbContext; _logger = logger; _productService = productService; _inventoryService = inventoryService; }
public void CustomerService_CreatesCustomer_GivenNewCustomerObject() { var options = new DbContextOptionsBuilder <BetaBrewDbContext>() .UseInMemoryDatabase("add_writes_to_database").Options; using var context = new BetaBrewDbContext(options); var sut = new CustomerService(context); sut.CreateCustomer(new Customer { Id = 123123 }); var allCustomers = sut.GetAllCustomers(); context.Customers.Single().Id.Should().Be(123123); }
public void CustomerService_DeleteCustomer_GivenId() { var options = new DbContextOptionsBuilder <BetaBrewDbContext>() .UseInMemoryDatabase("deletes_one").Options; using var context = new BetaBrewDbContext(options); var sut = new CustomerService(context); var customerId = 123123; sut.CreateCustomer(new Customer { Id = customerId }); sut.DeleteCustomer(customerId); var allCustomers = sut.GetAllCustomers(); allCustomers.Count().Should().Be(0); }
public void CustomerService_GetsAllCustomers_GivenTheyExist() { var options = new DbContextOptionsBuilder <BetaBrewDbContext>() .UseInMemoryDatabase("gets_all").Options; using var context = new BetaBrewDbContext(options); var sut = new CustomerService(context); sut.CreateCustomer(new Customer { Id = 123123 }); sut.CreateCustomer(new Customer { Id = 123 }); var allCustomers = sut.GetAllCustomers(); allCustomers.Count.Should().Be(2); }
public ProductService(BetaBrewDbContext dbContext) { _db = dbContext; }
public InventoryService(BetaBrewDbContext dbContext, ILogger <InventoryService> logger) { _db = dbContext; _logger = logger; }
public CustomerService(BetaBrewDbContext dbContext) { _db = dbContext; }