public void OrderService_GetsAllProducts_GivenTheyExist() { var options = new DbContextOptionsBuilder <CoffeeBoxDbContext>() .UseInMemoryDatabase("gets_all").Options; using var context = new CoffeeBoxDbContext(options); }
public void InventoryService_GetsAllInventory_GivenTheyExist() { var options = new DbContextOptionsBuilder <CoffeeBoxDbContext>() .UseInMemoryDatabase("gets_all").Options; using var context = new CoffeeBoxDbContext(options); var sut = new ProductService(context); }
public OrderService( CoffeeBoxDbContext dbContext, ILogger <OrderService> logger, IProductService productService, IInventoryService inventoryService) { _db = dbContext; _logger = logger; _productService = productService; _inventoryService = inventoryService; }
public void ProductService_CreatesProduct_GivenNewProductObject() { var options = new DbContextOptionsBuilder <CoffeeBoxDbContext>() .UseInMemoryDatabase("Archives_product").Options; using var context = new CoffeeBoxDbContext(options); var sut = new ProductService(context); sut.CreateProduct(new Product { Id = 7689 }); context.Products.Single().Id.Should().Be(7689); }
public void CustomerService_CreatesCustomer_GivenNewCustomerObject() { var options = new DbContextOptionsBuilder <CoffeeBoxDbContext>() .UseInMemoryDatabase("Add_writes_to_database").Options; using var context = new CoffeeBoxDbContext(options); var sut = new CustomerService(context); sut.CreateCustomer(new Customer { Id = 66795 }); context.Customers.Single().Id.Should().Be(66795); }
public void ProductService_ArchivesProduct_GivenNewProductObject() { var options = new DbContextOptionsBuilder <CoffeeBoxDbContext>() .UseInMemoryDatabase("Add_writes_to_database").Options; using var context = new CoffeeBoxDbContext(options); var sut = new ProductService(context); sut.CreateProduct(new Product { Id = 7 }); sut.ArchiveProduct(7); var archivedProduct = sut.GetProductById(7); archivedProduct.IsArchived.Should().Be(true); }
public void CustomerService_DeletesCustomer_GivenId() { var options = new DbContextOptionsBuilder <CoffeeBoxDbContext>() .UseInMemoryDatabase("deletes_one") .Options; using var context = new CoffeeBoxDbContext(options); var sut = new CustomerService(context); sut.CreateCustomer(new Customer { Id = 66795 }); sut.DeleteCustomer(66795); var allCustomers = sut.GetAllCustomers(); allCustomers.Count.Should().Be(0); }
public void ProductService_GetProductById_GivenTheyExist() { var options = new DbContextOptionsBuilder <CoffeeBoxDbContext>() .UseInMemoryDatabase("gets_one").Options; using var context = new CoffeeBoxDbContext(options); var sut = new ProductService(context); sut.CreateProduct(new Product { Id = 7 }); sut.CreateProduct(new Product { Id = 24 }); var getProductWithId = sut.GetProductById(24); getProductWithId.Id.Should().Be(24); }
public void ProductService_GetsAllProducts_GivenTheyExist() { var options = new DbContextOptionsBuilder <CoffeeBoxDbContext>() .UseInMemoryDatabase("gets_all").Options; using var context = new CoffeeBoxDbContext(options); var sut = new ProductService(context); sut.CreateProduct(new Data.Models.Product { Id = 1 }); sut.CreateProduct(new Data.Models.Product { Id = 2 }); var allProducts = sut.GetAllProducts(); allProducts.Count.Should().Be(2); }
public void CustomerService_GetsAllCustomers_GivenTheyExist() { var options = new DbContextOptionsBuilder <CoffeeBoxDbContext>() .UseInMemoryDatabase("gets_all").Options; using var context = new CoffeeBoxDbContext(options); var sut = new CustomerService(context); sut.CreateCustomer(new Data.Models.Customer { Id = 23134 }); sut.CreateCustomer(new Data.Models.Customer { Id = 345 }); sut.CreateCustomer(new Data.Models.Customer { Id = 23 }); var allCustomers = sut.GetAllCustomers(); allCustomers.Count.Should().Be(3); }
public InventoryService(CoffeeBoxDbContext dbContext, ILogger <InventoryService> logger) { _db = dbContext; _logger = logger; }
public CustomerService(CoffeeBoxDbContext dbContext) { _db = dbContext; }
public ProductService(CoffeeBoxDbContext dbContext) { _db = dbContext; }