Пример #1
0
        public void GetTownByName()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "GetTownByNameDB")
                          .Options;

            var data = new List <Towns>()
            {
                new Towns {
                    Id = 1, Name = "Town1"
                },
                new Towns {
                    Id = 2, Name = "Town2"
                },
                new Towns {
                    Id = 3, Name = "Town3"
                },
            }.AsQueryable();

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                TownsBusiness business = new TownsBusiness(context);
                data.ToList().ForEach(t => business.AddTown(t));

                Towns t = business.GetTownByName("Town1");
                Assert.AreEqual("Town1", t.Name);
            }
        }
Пример #2
0
        public void DeleteTown()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "DeleteTownDB")
                          .Options;

            var data = new List <Towns>()
            {
                new Towns {
                    Id = 1, Name = "Town1"
                },
                new Towns {
                    Id = 2, Name = "Town2"
                },
                new Towns {
                    Id = 3, Name = "Town3"
                },
            }.AsQueryable();

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                TownsBusiness business = new TownsBusiness(context);
                data.ToList().ForEach(town => business.AddTown(town));

                business.DeleteTownById(2);

                Assert.AreEqual(2, business.GetAllTowns().Count);
            }
        }
Пример #3
0
        public void GetsAllTownsFromDatabase()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "GetsAllCompetitorsFromDatabaseDB")
                          .Options;

            var data = new List <Towns>()
            {
                new Towns {
                    Id = 1, Name = "Town1"
                },
                new Towns {
                    Id = 2, Name = "Town2"
                },
                new Towns {
                    Id = 3, Name = "Town3"
                },
            }.AsQueryable();

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                TownsBusiness business = new TownsBusiness(context);
                data.ToList().ForEach(c => business.AddTown(c));

                Assert.AreEqual(data.ToList(), business.GetAllTowns());
            }
        }
Пример #4
0
        public void TestUpdateTowns()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "TestUpdateTownsDB")
                          .Options;

            var data = new List <Towns>()
            {
                new Towns {
                    Id = 1, Name = "Town1"
                },
                new Towns {
                    Id = 2, Name = "Town2"
                },
                new Towns {
                    Id = 3, Name = "Town3"
                },
            }.AsQueryable();

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                TownsBusiness business = new TownsBusiness(context);
                data.ToList().ForEach(c => business.AddTown(c));

                Towns c = business.GetTownById(2); c.Name = "Town22";
                business.UpdateTown(c);

                Assert.AreEqual("Town22", business.GetTownById(2).Name);
            }
        }
Пример #5
0
        //Ъм тука имам въпорс - i az

        /// <summary>
        /// Constructor for CompetitorsDisplay class.
        /// </summary>
        /// <param name="context"></param>
        public CompetitorsDisplay(OlympicGamesDBContext context)
        {
            competitorsBusiness = new CompetitorsBusiness(context);
            coachesBusiness     = new CoachesBusiness(context);
            clubsBusiness       = new ClubsBusiness(context);
            townsBusiness       = new TownsBusiness(context);
            sportsBusiness      = new SportsBusiness(context);

            townsDisplay   = new TownsDisplay(context);
            clubsDisplay   = new ClubsDisplay(context);
            coachesDisplay = new CoachesDisplay(context);
        }
Пример #6
0
        public void GetTownById()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "GetTownByIdDB")
                          .Options;

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                TownsBusiness business = new TownsBusiness(context);
                business.AddTown(new Towns {
                    Id = 1, Name = "Town1"
                });
                business.AddTown(new Towns {
                    Id = 2, Name = "Town2"
                });
                business.AddTown(new Towns {
                    Id = 3, Name = "Town3"
                });

                Towns c = business.GetTownById(1);
                Assert.AreEqual(1, c.Id);
            }
        }
Пример #7
0
 /// <summary>
 /// Constructor for CountriesDisplay class.
 /// </summary>
 /// <param name="context"></param>
 public CountriesDisplay(OlympicGamesDBContext context)
 {
     countriesBusiness = new CountriesBusiness(context);
     towns             = new TownsBusiness(context);
 }