Ejemplo n.º 1
0
        public void DeleteCoach()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "DeleteCoachDB")
                          .Options;

            var data = new List <Coaches>()
            {
                new Coaches {
                    Id = 1, Name = "Coach1"
                },
                new Coaches {
                    Id = 2, Name = "Coach2"
                },
                new Coaches {
                    Id = 3, Name = "Coach3"
                },
            }.AsQueryable();

            //да не забравяш options
            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                CoachesBusiness business = new CoachesBusiness(context);
                data.ToList().ForEach(c => business.AddCoach(c));

                business.DeleteCoachById(2);
                Assert.AreEqual(2, business.GetAllCoaches().Count);
            }
        }
Ejemplo n.º 2
0
        public void GetCoachByName()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "GetCoachByNameDB")
                          .Options;

            var data = new List <Coaches>()
            {
                new Coaches {
                    Id = 1, Name = "Coach1"
                },
                new Coaches {
                    Id = 2, Name = "Coach2"
                },
                new Coaches {
                    Id = 3, Name = "Coach3"
                },
            }.AsQueryable();

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

                Coaches c = business.GetCoachByName("Coach1");
                Assert.AreEqual("Coach1", c.Name);
            }
        }
Ejemplo n.º 3
0
        public void TestAddCoach()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "TestAddCoachDB")
                          .Options;

            var data = new List <Coaches>()
            {
                new Coaches {
                    Id = 1, Name = "Coach1"
                },
                new Coaches {
                    Id = 2, Name = "Coach2"
                },
                new Coaches {
                    Id = 3, Name = "Coach3"
                },
            }.AsQueryable();

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

                Assert.AreEqual(data.ToList(), business.GetAllCoaches());
            }
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 5
0
        public void GetCoachById()
        {
            var options = new DbContextOptionsBuilder <OlympicGamesDBContext>()
                          .UseInMemoryDatabase(databaseName: "GetCoachByIdDB")
                          .Options;

            using (OlympicGamesDBContext context = new OlympicGamesDBContext(options))
            {
                CoachesBusiness business = new CoachesBusiness(context);
                business.AddCoach(new Coaches {
                    Id = 1, Name = "Coach1"
                });
                business.AddCoach(new Coaches {
                    Id = 2, Name = "Coach2"
                });
                business.AddCoach(new Coaches {
                    Id = 3, Name = "Coach3"
                });

                Coaches c = business.GetCoachById(1);
                Assert.AreEqual(1, c.Id);
            }
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Makes the connection between Coaches's display and business layer.
 /// </summary>
 /// <param name="context"></param>
 public CoachesDisplay(OlympicGamesDBContext context)
 {
     coachesBusiness = new CoachesBusiness(context);
     sportsBusiness  = new SportsBusiness(context);
 }