Example #1
0
        public void DeleteClub()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "DeleteClubDB")
                          .Options;

            IQueryable <Clubs> data = new List <Clubs>()
            {
                new Clubs {
                    Id = 1, Name = "Club1"
                },
                new Clubs {
                    Id = 2, Name = "Club2"
                },
                new Clubs {
                    Id = 3, Name = "Club3"
                },
                new Clubs {
                    Id = 22, Name = "SektantiVegani"
                },
            }.AsQueryable();

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                ClubsBusiness business = new ClubsBusiness(context);
                data.ToList().ForEach(club1 => business.AddClub(club1));

                business.DeleteClubById(22);

                Assert.AreEqual(3, business.GetAllClubs().Count);
            }
        }
Example #2
0
        public void GetClubByName()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "GetClubByNameDB")
                          .Options;

            var data = new List <Clubs>()
            {
                new Clubs {
                    Id = 1, Name = "Club1"
                },
                new Clubs {
                    Id = 2, Name = "Club2"
                },
                new Clubs {
                    Id = 3, Name = "Club3"
                },
            }.AsQueryable();

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

                Clubs c = business.GetClubByName("Club1");
                Assert.AreEqual("Club1", c.Name);
            }
        }
Example #3
0
        public void TestAddClub()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "TestAddClubDB")
                          .Options;

            var data = new List <Clubs>()
            {
                new Clubs {
                    Id = 1, Name = "Club1"
                },
                new Clubs {
                    Id = 2, Name = "Club2"
                },
                new Clubs {
                    Id = 3, Name = "Club3"
                },
            }.AsQueryable();

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

                Assert.AreEqual(data.ToList(), business.GetAllClubs());
            }
        }
Example #4
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);
        }
Example #5
0
        public void GetClubById()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "GetClubByIdDB")
                          .Options;

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                ClubsBusiness business = new ClubsBusiness(context);
                business.AddClub(new Clubs {
                    Id = 1, Name = "Club1"
                });
                business.AddClub(new Clubs {
                    Id = 2, Name = "Club2"
                });
                business.AddClub(new Clubs {
                    Id = 3, Name = "Club3"
                });

                Clubs c = business.GetClubById(1);
                Assert.AreEqual(1, c.Id);
            }
        }
 /// <summary>
 /// Constructor for ClubsDisplay class.
 /// </summary>
 /// <param name="context"></param>
 public ClubsDisplay(OlympicGamesDBContext context)
 {
     clubsBusiness = new ClubsBusiness(context);
 }