Esempio n. 1
0
 public OrderService(
     BetaBrewDbContext dbContext,
     ILogger <OrderService> logger,
     IProductService productService,
     IInventoryService inventoryService)
 {
     _db               = dbContext;
     _logger           = logger;
     _productService   = productService;
     _inventoryService = inventoryService;
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
 public ProductService(BetaBrewDbContext dbContext)
 {
     _db = dbContext;
 }
Esempio n. 6
0
 public InventoryService(BetaBrewDbContext dbContext, ILogger <InventoryService> logger)
 {
     _db     = dbContext;
     _logger = logger;
 }
Esempio n. 7
0
 public CustomerService(BetaBrewDbContext dbContext)
 {
     _db = dbContext;
 }