public ManagerCreateBeerWizard(string breweryId, string breweryName, DBRepo repo) { this.BreweryID = breweryId; this.BreweryName = breweryName; this.repo = repo; this.managerService = new ManagerService(repo); }
private void CreateContactsTable() { DBRepo dbr = new DBRepo(); var result = dbr.CreateTable(); Toast.MakeText(this, result, ToastLength.Short).Show(); }
private void GetAllDBContacts() { DBRepo dbr = new DBRepo(); mContacts.AddRange(dbr.GetAllContacts()); mAdapter.NotifyDataSetChanged(); }
private void CreateDatabse() { DBRepo dbr = new DBRepo(); var result = dbr.CreateDB(); Toast.MakeText(this, result, ToastLength.Short).Show(); }
public ManagerRefillMenu(string breweryId, string breweryName, DBRepo repo) { this.BreweryID = breweryId; this.BreweryName = breweryName; this.repo = repo; this.managerService = new ManagerService(repo); }
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); }
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); }
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); }
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)); }
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); }
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)); }
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 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)); }
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)); }
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() }
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); }
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); }
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)); }
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)); }
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); }
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)); }
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); }
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)); }
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); }