private SystemRepository CreateSystemTestRepo(string dbName, bool games = false)
        {
            var options = new DbContextOptionsBuilder <VideogamesContext>()
                          .UseInMemoryDatabase(databaseName: dbName)
                          .Options;

            VideogamesContext SystemContext = new VideogamesContext(options);
            Systems           testsystem    = new Systems();

            //Check to see if we need to add a game relation to the database
            if (games == true)
            {
                Games testgame = new Games()
                {
                    Title      = "TestGameTitle",
                    Id         = 0,
                    SystemName = _SystemName + (_SystemNumber - 1).ToString()
                };
                SystemContext.Games.Add(testgame);
                SystemContext.SaveChanges();
            }

            for (int i = 0; i < _SystemNumber; i++)
            {
                testsystem.SystemName = _SystemName + i.ToString();
                testsystem.Id         = i;
                SystemContext.Systems.Add(testsystem);
                SystemContext.SaveChanges();
            }

            return(new SystemRepository(SystemContext));
        }
示例#2
0
        private YearRepository CreateYearTestRepo(string dbName, bool games = false)
        {
            var options = new DbContextOptionsBuilder <VideogamesContext>()
                          .UseInMemoryDatabase(databaseName: dbName)
                          .Options;

            VideogamesContext YearContext = new VideogamesContext(options);
            Years             testyear    = new Years();

            //Check to see if we need to add a game relation to the database
            if (games == true)
            {
                Games testgame = new Games()
                {
                    Title = "TestGameTitle",
                    Id    = 0,
                    Year  = _YearName + (_YearNumber - 1).ToString()
                };
                YearContext.Games.Add(testgame);
                YearContext.SaveChanges();
            }

            for (int i = 0; i < _YearNumber; i++)
            {
                testyear.Year = _YearName + i.ToString();
                testyear.Id   = i;
                YearContext.Years.Add(testyear);
                YearContext.SaveChanges();
            }

            return(new YearRepository(YearContext));
        }
示例#3
0
        private ManufacturerRepository CreateManufacturerTestRepo(string dbName)
        {
            var options = new DbContextOptionsBuilder <VideogamesContext>()
                          .UseInMemoryDatabase(databaseName: dbName)
                          .Options;

            VideogamesContext ManufacturerContext = new VideogamesContext(options);
            Manufacturers     testmanufacturer    = new Manufacturers();

            for (int i = 0; i < _ManufacturerNumber; i++)
            {
                testmanufacturer.Name = _ManufacturerName + i.ToString();
                testmanufacturer.Id   = i;
                ManufacturerContext.Manufacturers.Add(testmanufacturer);
                ManufacturerContext.SaveChanges();
            }

            return(new ManufacturerRepository(ManufacturerContext));
        }
示例#4
0
        private RatingRepository CreateRatingTestRepo(string dbName)
        {
            var options = new DbContextOptionsBuilder <VideogamesContext>()
                          .UseInMemoryDatabase(databaseName: dbName)
                          .Options;

            VideogamesContext RatingContext = new VideogamesContext(options);
            Ratings           testrating    = new Ratings();

            for (int i = 0; i < _RatingNumber; i++)
            {
                testrating.Rating = _RatingName + i.ToString();
                testrating.Id     = i;
                RatingContext.Ratings.Add(testrating);
                RatingContext.SaveChanges();
            }

            return(new RatingRepository(RatingContext));
        }
示例#5
0
        private GameRepository CreateGameTestRepo(string dbName)
        {
            var options = new DbContextOptionsBuilder <VideogamesContext>()
                          .UseInMemoryDatabase(databaseName: dbName)
                          .Options;

            VideogamesContext GameContext = new VideogamesContext(options);
            Games             testgame    = new Games();

            for (int i = 0; i < _GameNumber; i++)
            {
                testgame.Title         = _GameTitle + i.ToString();
                testgame.Id            = i;
                testgame.Description   = _GameDescription + i.ToString();
                testgame.DeveloperName = _GameDeveloper + i.ToString();
                GameContext.Games.Add(testgame);
                GameContext.SaveChanges();
            }

            return(new GameRepository(GameContext));
        }
示例#6
0
 public DeveloperRepository(VideogamesContext context)
 {
     _context = context;
 }
示例#7
0
 public SystemRepository(VideogamesContext context)
 {
     _context = context;
 }
 public RatingRepository(VideogamesContext context)
 {
     _context = context;
 }
 public YearRepository(VideogamesContext context)
 {
     _context = context;
 }
 public ManufacturerRepository(VideogamesContext context)
 {
     _context = context;
 }
示例#11
0
 public GameRepository(VideogamesContext context)
 {
     _context = context;
 }
 public PublisherRepository(VideogamesContext context)
 {
     _context = context;
 }