예제 #1
0
 public ManagerCreateBeerWizard(string breweryId, string breweryName, DBRepo repo)
 {
     this.BreweryID      = breweryId;
     this.BreweryName    = breweryName;
     this.repo           = repo;
     this.managerService = new ManagerService(repo);
 }
예제 #2
0
        private void CreateContactsTable()
        {
            DBRepo dbr    = new DBRepo();
            var    result = dbr.CreateTable();

            Toast.MakeText(this, result, ToastLength.Short).Show();
        }
예제 #3
0
        private void GetAllDBContacts()
        {
            DBRepo dbr = new DBRepo();

            mContacts.AddRange(dbr.GetAllContacts());
            mAdapter.NotifyDataSetChanged();
        }
예제 #4
0
        private void CreateDatabse()
        {
            DBRepo dbr    = new DBRepo();
            var    result = dbr.CreateDB();

            Toast.MakeText(this, result, ToastLength.Short).Show();
        }
예제 #5
0
 public ManagerRefillMenu(string breweryId, string breweryName, DBRepo repo)
 {
     this.BreweryID      = breweryId;
     this.BreweryName    = breweryName;
     this.repo           = repo;
     this.managerService = new ManagerService(repo);
 }
예제 #6
0
        public void UpdateInventoryLineItemShouldUpdateLineItem()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <IceShopContext>().UseInMemoryDatabase("UpdateInventoryLineItemShouldUpdateLineItem").Options;

            using var testContext = new IceShopContext(options);
            // add sample data to testContext
            testContext.InventoryLineItems.AddRange(SampleData.GetSampleInventoryLineItems());
            // This data needs to be added so that navigation properties of the Inventory Line Items aren't null.
            testContext.Locations.AddRange(SampleData.GetSampleLocations());
            testContext.Products.AddRange(SampleData.GetSampleProducts());
            testContext.SaveChanges();

            repo = new DBRepo(testContext);

            //Act
            // get a location that has an InventoryLineItem
            int sampleLocationId             = repo.GetAllLocations().First().Id;
            InventoryLineItem sampleLineItem = repo.GetAllInventoryLineItemsAtLocation(sampleLocationId).FindLast(ili => ili.LocationId == sampleLocationId);
            int startingQuantity             = sampleLineItem.ProductQuantity;

            sampleLineItem.ProductQuantity += 1;


            repo.UpdateInventoryLineItem(sampleLineItem);
            repo.SaveChanges();

            //Assert
            //using var assertContext = new IceShopContext(options);
            Assert.NotEqual(startingQuantity, sampleLineItem.ProductQuantity);
        }
예제 #7
0
        static void Main(string[] args)
        {
            ICarRepository carRepo    = new DBRepo();
            CarManager     carManager = new CarManager(carRepo);

            do
            {
                Console.WriteLine("1)book car\n2)exit");
                int response = Convert.ToInt32(Console.ReadLine());

                if (response == 2)
                {
                    Environment.Exit(0);
                }
                else
                {
                    Console.WriteLine("enter start date (dd.mm.yyyy)");
                    DateTime startDate = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture);
                    Console.WriteLine("enter end date (dd.mm.yyyy)");
                    DateTime        endDate = DateTime.ParseExact(Console.ReadLine(), "dd.MM.yyyy", System.Globalization.CultureInfo.InvariantCulture);
                    List <DateTime> dates   = carManager.GetDatesBetween(startDate, endDate).ToList();
                    Console.WriteLine("cars that not booked on this dates (enter car ID):");
                    foreach (string car in carManager.GetCarsNotBookedOnThisDates(dates))
                    {
                        Console.WriteLine(car);
                    }
                    response = Convert.ToInt32(Console.ReadLine());
                    carManager.RentCarForDates(response, dates);
                }
            } while (true);
        }
 public CustomerWelcomeMenu(DBRepo repo)
 {
     this.repo             = repo;
     this.customerService  = new CustomerService(repo);
     this.createUserWizard = new CustomerCreateUserWizard(repo);
     this.loginWizard      = new CustomerLoginWizard(repo);
 }
 public CustomerOrderMenu(DBRepo repo)
 {
     this.repo             = repo;
     this.customerService  = new CustomerService(repo);
     this.orderConfirm     = new CustomerOrderConfirm();
     this.cartMenu         = new CustomerCartMenu(repo);
     this.orderHistoryMenu = new CustomerOrderHistoryMenu(repo);
 }
        public void GetAllManagersShouldGetAllManagers()
        {
            using var tester = new lacrosseContext();
            IManagerRepo   repo      = new DBRepo(tester);
            List <Manager> manResult = repo.GetAllManagers();

            Assert.NotNull(manResult);
        }
        public void GetAllCustomerShouldGetAllCustomers()
        {
            using var tester = new lacrosseContext();
            ICustomerRepo   custRepo   = new DBRepo(tester);
            List <Customer> custResult = custRepo.GetAllCustomers();

            Assert.NotNull(custResult);
        }
예제 #12
0
        void dialog_OnCreateContact(object sender, CreateContactEventArgs e)
        {
            Contact newContact = new Contact()
            {
                Name = e.Name, Bithday = e.Birthday
            };

            mContacts.Add(newContact);
            mAdapter.NotifyDataSetChanged();

            DBRepo dbr    = new DBRepo();
            string result = dbr.InsertContact(newContact);
        }
예제 #13
0
        public void AddOrderShouldAdd()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("AddOrderShouldAdd").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);

            // Act
            repo.AddOrder(testOrder);

            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(assertContext.Orders.Single(u => u.Orderdate == testOrder.orderDate));
        }
예제 #14
0
        public void AddLocationShouldAdd()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("AddLocationShouldAdd").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);

            // Act
            repo.AddLocation(testLocation);

            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(assertContext.Locations.Single(u => u.Street == testLocation.street));
        }
        public void AddCustomerShouldAdd()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <entities.GameKingdomContext>().UseInMemoryDatabase("AddCustomerShouldAdd").Options;

            using var testcontext = new entities.GameKingdomContext(options);
            repo = new DBRepo(testcontext, mapper);

            // Act
            repo.AddACustomer(testCustomer);

            // Assert
            using var assertContext = new entities.GameKingdomContext(options);
            Assert.NotNull(assertContext.Customer.Single(c => c.Name == testCustomer.Name));
        }
        public void AddCustomerShouldAddCustomer()
        {
            using var tester = new lacrosseContext();
            ICustomerRepo custRepo = new DBRepo(tester);
            Customer      newCust  = new Customer();

            newCust.FirstName  = "NewCustFirst";
            newCust.LastName   = "NewCustLast";
            newCust.email      = "*****@*****.**";
            newCust.LocationId = 2;

            custRepo.AddCustomer(newCust);
            Assert.NotNull(tester.Customer.Single(c => c.email == newCust.email));
            custRepo.DeleteACustomer(newCust);
        }
예제 #17
0
        public void AddHeroShouldAdd()
        {
            //Arranging necessary artifacts
            var options = new DbContextOptionsBuilder <HeroContext>().UseInMemoryDatabase("AddHeroesShouldAdd").Options;

            using var testContext = new HeroContext(options);
            repo = new DBRepo(testContext, mapper);

            //Act
            repo.AddAHeroAsync(testHero);

            //Assert
            using var assertContext = new HeroContext(options);
            Assert.NotNull(assertContext.Superpeople.Single(h => h.Workname == testHero.Alias));
        }
예제 #18
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));
        }
예제 #19
0
        public void AddInventoryItemShouldAdd()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("AddInventoryItemShouldAdd").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);

            // Act
            repo.AddInventoryItem(testInventoryItem);

            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(assertContext.Inventoryitems.Single(u => u.Id == testInventoryItem.id));
        }
예제 #20
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));
        }
예제 #21
0
        public void IsBooked_CarWithoutDatesAndUserDates_ReturnsFalse()
        {
            //arrange
            ICarRepository carRepository = new DBRepo();
            CarManager     cm            = new CarManager(carRepository);
            var            testCar       = new Car(1, "testCar");

            carRepository.AddCarToList(testCar);
            List <DateTime> dateFromUser = new List <DateTime>();

            dateFromUser.Add(DateTime.Now);

            //act
            bool result = cm.IsBooked()
        }
예제 #22
0
        public void GetAllLocationsShouldGet()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("GetAllLocationsShouldGet").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);

            // Act
            repo.AddLocation(testLocation);
            List <Location> newLocation = repo.GetAllLocations();

            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(newLocation);
        }
예제 #23
0
        public void GetAllVideoGamesShouldGet()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("GetAllVideoGamesShouldGet").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);

            // Act
            repo.AddVideoGame(testGame);
            List <VideoGame> newGame = repo.GetAllVideoGames();

            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(newGame);
        }
예제 #24
0
        public void AddVideoGameShouldAdd()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("AddVideoGameShouldAdd").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);

            // Act
            repo.AddVideoGame(testGame);


            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(assertContext.Videogames.Single(u => u.Id == testGame.id));
        }
예제 #25
0
        public void GetLineItemByIdShouldGet()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("GetLineItemByIdShouldGet").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);

            // Act
            repo.AddLineItem(testLineItem);
            LineItem newItem = repo.GetLineItemById(testLineItem.id);

            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(assertContext.Lineitems.Single(u => u.Id == newItem.id));
        }
예제 #26
0
        public void GetAllLineItemsShouldGet()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("GetAllLineItemsShouldGet").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);

            // Act
            repo.AddLineItem(testLineItem);
            List <LineItem> newItem = repo.GetAllLineItems(testLineItem.orderId);

            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(newItem);
        }
예제 #27
0
        public void AddManagerShouldAdd()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <IceShopContext>().UseInMemoryDatabase("AddManagerShouldAdd").Options;

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

            //Act
            repo.AddManager(testManager);
            repo.SaveChanges();

            //Assert
            using var assertContext = new IceShopContext(options);
            Assert.NotNull(assertContext.Managers.Single(m => m.Id == testManager.Id));
        }
예제 #28
0
        public void GetAllInventoryItemsAtLocationShouldGet()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("GetAllInventoryItemsAtLocationShouldGet").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);

            // Act
            repo.AddInventoryItem(testInventoryItem);
            var newItem = repo.GetAllInventoryItemsAtLocation(testInventoryItem.locationId);

            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(newItem);
        }
예제 #29
0
        public void AddUserShouldAdd()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <GGsContext>().UseInMemoryDatabase("AddUserShouldAdd").Options;

            using var testContext = new GGsContext(options);
            repo = new DBRepo(testContext, mapper);
            testContext.Locations.AddRange(mapper.ParseLocation(testLocation));

            // Act
            repo.AddUser(testUser);

            // Assert
            using var assertContext = new GGsContext(options);
            Assert.NotNull(assertContext.Users.Single(u => u.Name == testUser.name));
        }
예제 #30
0
        public void GetHeroByNameShouldGetHeroByName()
        {
            //Arrange
            var options = new DbContextOptionsBuilder <HeroContext>().UseInMemoryDatabase("GetHeroByNameShouldGetHeroByName").Options;

            using var testContext = new HeroContext(options);
            Seed(testContext);

            //Act
            using var assertContext = new HeroContext(options);
            repo = new DBRepo(assertContext, mapper);
            var result = repo.GetHeroByName("Bob the builder");

            //Assert
            Assert.NotNull(result);
            Assert.Equal("Bob", result.RealName);
        }