public void GetsAllSportsFromDatabase() { var options = new DbContextOptionsBuilder <OlympicGamesDBContext>() .UseInMemoryDatabase(databaseName: "GetsAllSportsFromDatabaseDB") .Options; var data = new List <Sports>() { new Sports { Id = 1, Name = "Sport1" }, new Sports { Id = 2, Name = "Sport2" }, new Sports { Id = 3, Name = "Sport3" }, }.AsQueryable(); using (OlympicGamesDBContext context = new OlympicGamesDBContext(options)) { SportsBusiness business = new SportsBusiness(context); data.ToList().ForEach(t => context.Sports.Add(t)); context.SaveChanges(); Assert.AreEqual(data.ToList(), business.GetAllSports()); } }
public void GetCountryByName() { var options = new DbContextOptionsBuilder <OlympicGamesDBContext>() .UseInMemoryDatabase(databaseName: "GetCountryByNameDB") .Options; var data = new List <Countries>() { new Countries { Id = 1, Name = "Country1" }, new Countries { Id = 2, Name = "Country2" }, new Countries { Id = 3, Name = "Country3" }, }.AsQueryable(); using (OlympicGamesDBContext context = new OlympicGamesDBContext(options)) { CountriesBusiness business = new CountriesBusiness(context); data.ToList().ForEach(t => context.Countries.Add(t)); context.SaveChanges(); Countries t = business.GetCountryByName("Country1"); Assert.AreEqual("Country1", t.Name); } }
public void AddTown(Towns town) { olympicGamesDBContext.Towns.Add(town); olympicGamesDBContext.SaveChanges(); }
/// <summary> /// Adds a coach in the database. /// </summary> /// <param name="coach">The coach that is being added.</param> public void AddCoach(Coaches coach) { olympicGamesDBContext.Coaches.Add(coach); olympicGamesDBContext.SaveChanges(); }
/// <summary> /// Adds a club in the database. /// </summary> /// <param name="club">The club that is being added.</param> public void AddClub(Clubs club) { olympicGamesDBContext.Clubs.Add(club); olympicGamesDBContext.SaveChanges(); }
/// <summary> /// Adds a competitor in the database. /// </summary> /// <param name="competitors">The competitor that is being added.</param> public void AddCompetitors(Competitors competitors) { olympicGamesDBContext.Competitors.Add(competitors); olympicGamesDBContext.SaveChanges(); }