private void Seed(BrewCrewContext testContext)
 {
     testContext.Users.AddRange(TestUsers);
     testContext.Breweries.AddRange(TestBreweries);
     testContext.Beers.AddRange(TestBeers);
     testContext.Orders.AddRange(TestOrders);
     testContext.LineItems.AddRange(TestLineItems);
     testContext.BreweryManagers.AddRange(TestBreweryManagers);
     testContext.SaveChanges();
 }
Esempio n. 2
0
 private void Seed(BrewCrewContext testContext)
 {
     testContext.Managers.AddRange(TestManagers);
     testContext.Breweries.AddRange(TestBreweries);
     testContext.Beers.AddRange(TestBeers);
     testContext.Orders.AddRange(TestOrders);
     testContext.Beers.Add(TestBeer);
     testContext.Customers.Add(TestCustomer);
     testContext.SaveChanges();
 }
Esempio n. 3
0
        public void TestAddBrewery()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestAddBrewery").Options;

            using var testContext = new BrewCrewContext(options);
            repo = new DBRepo(testContext);

            //Act
            repo.AddBreweryAsync(TestBrewery);

            //Assert
            using var assertContext = new BrewCrewContext(options);
            Assert.NotNull(assertContext.Breweries.SingleAsync(c => c.Name == TestBrewery.Name));
        }
        public void TestAddBreweryManager()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestAddBreweryManager").Options;

            using var testContext = new BrewCrewContext(options);
            _breweryManagerRepo   = new BreweryManagerRepo(testContext);

            //Act
            _breweryManagerRepo.Add(TestBreweryManager);

            //Assert
            using var assertContext = new BrewCrewContext(options);
            Assert.NotNull(assertContext.Breweries.SingleAsync(c => c.ID == TestBreweryManager.ID));
        }
        public void TestAddLineItem()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestAddLineItem").Options;

            using var testContext = new BrewCrewContext(options);
            _lineItemRepo         = new LineItemRepo(testContext);

            //Act
            _lineItemRepo.Add(TestLineItem);

            //Assert
            using var assertContext = new BrewCrewContext(options);
            Assert.NotNull(assertContext.LineItems.SingleAsync(c => c.ID == TestLineItem.ID));
        }
        public void TestAddCustomer()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestAddCustomer").Options;

            using var testContext = new BrewCrewContext(options);
            _userRepo             = new UserRepo(testContext);

            //Act
            _userRepo.Add(TestCustomer);

            //Assert
            using var assertContext = new BrewCrewContext(options);
            Assert.NotNull(assertContext.Users.SingleAsync(c => c.Type == TestCustomer.Type));
        }
Esempio n. 7
0
        public void TestPlaceOrder()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestPlaceOrder").Options;

            using var testContext = new BrewCrewContext(options);
            repo = new DBRepo(testContext);

            //Act
            repo.PlaceOrderAsync(TestOrder);

            //Assert
            using var assertContext = new BrewCrewContext(options);
            Assert.NotNull(assertContext.Orders.SingleAsync(c => c.ID == TestOrder.ID));
        }
Esempio n. 8
0
        public void TestGetBeerById()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestGetBeerById").Options;

            using var testContext = new BrewCrewContext(options);

            Seed(testContext);

            //Act
            using var assertContext = new BrewCrewContext(options);
            repo = new DBRepo(assertContext);
            var result = repo.GetBeerByIdAsync("1");

            //Assert
            Assert.NotNull(result.Result);
        }
        public void TestGetOrderById()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestGetOrderById").Options;

            using var testContext = new BrewCrewContext(options);

            Seed(testContext);

            //Act
            using var assertContext = new BrewCrewContext(options);
            _orderRepo = new OrderRepo(assertContext);
            var result = _orderRepo.GetById("2");

            //Assert
            Assert.NotNull(assertContext.Orders.SingleAsync(c => c.ID == result.Result.ID));
        }
Esempio n. 10
0
        public void TestGetAllOrdersByCustomerId()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestGetAllOrdersByCustomerId").Options;

            using var testContext = new BrewCrewContext(options);

            Seed(testContext);

            //Act
            using var assertContext = new BrewCrewContext(options);
            _orderRepo = new OrderRepo(assertContext);
            var result = _orderRepo.GetAllOrdersByCustomerId("1");

            //Assert
            Assert.NotNull(result.Result);
            Assert.Equal(1, result.Result.Count);
        }
Esempio n. 11
0
        public void TestGetUserByEmail()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestGetUserByEmail").Options;

            using var testContext = new BrewCrewContext(options);

            Seed(testContext);

            //Act
            using var assertContext = new BrewCrewContext(options);
            repo = new DBRepo(assertContext);
            var result = repo.GetUserByEmailAsync("*****@*****.**");

            //Assert
            Assert.NotNull(result);
            Assert.Equal("*****@*****.**", result.Email);
        }
Esempio n. 12
0
        public void TestGetBreweries()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestGetBreweries").Options;

            using var testContext = new BrewCrewContext(options);

            Seed(testContext);

            //Act
            using var assertContext = new BrewCrewContext(options);
            repo = new DBRepo(assertContext);
            var result = repo.GetAllBreweriesAsync();

            //Assert
            Assert.NotNull(result.Result);
            Assert.Equal(2, result.Result.Count);
        }
Esempio n. 13
0
        public void TestGetAllUsersByType()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <BrewCrewContext>().UseInMemoryDatabase("TestGetAllUsersByType").Options;

            using var testContext = new BrewCrewContext(options);

            Seed(testContext);

            //Act
            using var assertContext = new BrewCrewContext(options);
            _userRepo = new UserRepo(assertContext);
            var result = _userRepo.GetAllUsersByType("customer");

            //Assert
            Assert.NotNull(result);
            foreach (var user in result.Result)
            {
                Assert.Equal("customer", user.Type);
            }
        }
 public IDataRepo(BrewCrewContext context)
 {
     this.context = context;
 }
Esempio n. 15
0
 public MainMenu(BrewCrewContext context)
 {
     this.adminMenu    = new AdminWizardMenu(new DBRepo(context));
     this.managerMenu  = new ManagerWelcomeMenu(new DBRepo(context));
     this.customerMenu = new CustomerWelcomeMenu(new DBRepo(context));
 }
 public BreweryRepo(BrewCrewContext context) : base(context)
 {
 }
 public BreweryManagerRepo(BrewCrewContext context) : base(context)
 {
 }
Esempio n. 18
0
 public UserRepo(BrewCrewContext context) : base(context)
 {
 }
Esempio n. 19
0
 public LineItemRepo(BrewCrewContext context) : base(context)
 {
 }