public void SetSelectedGame(string selectedItem)
 {
     using (var db = new GameMarketContext())
     {
         GenreUpdate = db.Genres.Where(g => g.GenreName == selectedItem).FirstOrDefault();
     }
 }
        public void TearDown()
        {
            using (var db = new GameMarketContext())
            {
                var selectedDevs =
                    from c in db.Developers
                    where c.DeveloperName == "Bioware"
                    select c;

                var selectedDevs2 =
                    from c in db.Developers
                    where c.DeveloperName == "Bethesda Softworks"
                    select c;

                var selectedDevs3 =
                    from c in db.Developers
                    where c.DeveloperName == "Treyarch"
                    select c;

                db.Developers.RemoveRange(selectedDevs);
                db.Developers.RemoveRange(selectedDevs2);
                db.Developers.RemoveRange(selectedDevs3);
                db.SaveChanges();
            }
        }
Exemple #3
0
 public void SetSelectedGame(string selectedItem)
 {
     using (var db = new GameMarketContext())
     {
         developerUpdate = db.Developers.Where(g => g.DeveloperName == selectedItem).FirstOrDefault();
     }
 }
        public void TearDown()
        {
            using (var db = new GameMarketContext())
            {
                var selectedGenres =
                    from c in db.Genres
                    where c.GenreName == "VR"
                    select c;

                var selectedGenres2 =
                    from c in db.Genres
                    where c.GenreName == "Adventure"
                    select c;

                var selectedGenres3 =
                    from c in db.Genres
                    where c.GenreName == "Maze"
                    select c;

                var selectedGenres4 =
                    from c in db.Genres
                    where c.GenreName == "FPS"
                    select c;

                db.Genres.RemoveRange(selectedGenres);
                db.Genres.RemoveRange(selectedGenres2);
                db.Genres.RemoveRange(selectedGenres3);
                db.Genres.RemoveRange(selectedGenres4);

                db.SaveChanges();
            }
        }
 private void comboGenres_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     using (var db = new GameMarketContext())
     {
         ComboBox selectedBox = (ComboBox)sender;
         if (selectedBox.Name == "comboSelectedGenres" && comboSelectedGenres.SelectedValue != null)
         {
             var idQueryOld = db.Genres.Where(g => g.GenreName == comboSelectedGenres.SelectedValue.ToString()).FirstOrDefault();
             oldGenreID = idQueryOld.GenreId;
         }
         else if (selectedBox.Name == "comboGenres" && comboGenres.SelectedValue != null)
         {
             var idQueryNew = db.Genres.Where(g => g.GenreName == comboGenres.SelectedValue.ToString()).FirstOrDefault();
             newGenreID = idQueryNew.GenreId;
         }
         else if (selectedBox.Name == "comboSelectedDevs" && comboSelectedDevs.SelectedValue != null)
         {
             var idQueryOld = db.Developers.Where(g => g.DeveloperName == comboSelectedDevs.SelectedValue.ToString()).FirstOrDefault();
             oldDevID = idQueryOld.DeveloperId;
         }
         else if (selectedBox.Name == "comboDevs" && comboDevs.SelectedValue != null)
         {
             var idQueryNew = db.Developers.Where(g => g.DeveloperName == comboDevs.SelectedValue.ToString()).FirstOrDefault();
             newDevID = idQueryNew.DeveloperId;
         }
     }
 }
        public void Setup()
        {
            _crudMethods = new CRUD_GenreMethods();
            using (var db = new GameMarketContext())
            {
                var selectedGenres =
                    from c in db.Genres
                    where c.GenreName == "VR"
                    select c;

                var selectedGenres2 =
                    from c in db.Genres
                    where c.GenreName == "Adventure"
                    select c;

                var selectedGenres3 =
                    from c in db.Genres
                    where c.GenreName == "Maze"
                    select c;

                var selectedGenres4 =
                    from c in db.Genres
                    where c.GenreName == "FPS"
                    select c;

                db.Genres.RemoveRange(selectedGenres);
                db.Genres.RemoveRange(selectedGenres2);
                db.Genres.RemoveRange(selectedGenres3);
                db.Genres.RemoveRange(selectedGenres4);
            }
        }
        public User selectedUser()
        {
            User selected = new User();

            using (var db = new GameMarketContext())
                selected = db.Users.Where(u => u.Selected == true).FirstOrDefault();
            return(selected);
        }
 public void Delete(string genreName)
 {
     using (var db = new GameMarketContext())
     {
         GenreUpdate = db.Genres.Where(g => g.GenreName == genreName).FirstOrDefault();
         db.Genres.Remove(GenreUpdate);
         db.SaveChanges();
     }
 }
Exemple #9
0
 public void Delete(string devName)
 {
     using (var db = new GameMarketContext())
     {
         developerUpdate = db.Developers.Where(c => c.DeveloperName == devName).FirstOrDefault();
         db.Developers.Remove(developerUpdate);
         db.SaveChanges();
     }
 }
 public void Delete(int gameId, int devID)
 {
     using (var db = new GameMarketContext())
     {
         gameDevUpdate = db.GameDevelopers.Where(c => c.GameId == gameId && c.DeveloperId == devID).FirstOrDefault();
         db.GameDevelopers.Remove(gameDevUpdate);
         db.SaveChanges();
     }
 }
Exemple #11
0
 public void Delete(int gameId, int genreID)
 {
     using (var db = new GameMarketContext())
     {
         gameGenreUpdate = db.GameGenres.Where(c => c.GameId == gameId && c.GenreId == genreID).FirstOrDefault();
         db.GameGenres.Remove(gameGenreUpdate);
         db.SaveChanges();
     }
 }
 public void WhenIncorrectPasswordIsEntered_IsNotSetToTrue()
 {
     using (var db = new GameMarketContext())
     {
         userMethods.Create("unitTest", "unitTestUsername", "*****@*****.**", "unitTest");
         decimal loginUserID = login.emailCheck("*****@*****.**", "unitTestFail");
         Assert.AreEqual(loginUserID, 0m);
     }
 }
Exemple #13
0
 public void Delete(string username)
 {
     using (var db = new GameMarketContext())
     {
         userUpdate = db.Users.Where(c => c.Username == username).FirstOrDefault();
         db.Users.Remove(userUpdate);
         db.SaveChanges();
     }
 }
        public void WhenANewDevIsAdded_TheNumberOfDevsIncreasesBy1()
        {
            using (var db = new GameMarketContext())
            {
                var numberOfDevsBefore = db.Developers.Count();
                _crudMethods.Create("Bioware");
                var numberOfDevsAfter = db.Developers.Count();

                Assert.AreEqual(numberOfDevsBefore + 1, numberOfDevsAfter);
            }
        }
        public void WhenANewGenreIsAdded_TheNumberOfGamesIncreasesBy1()
        {
            using (var db = new GameMarketContext())
            {
                var numberOfGenresBefore = db.Genres.Count();
                _crudMethods.Create("Maze");
                var numberOfGenresAfter = db.Genres.Count();

                Assert.AreEqual(numberOfGenresBefore + 1, numberOfGenresAfter);
            }
        }
        public void WhenTheDevIsChanged_TheDatabaseIsUpdated()
        {
            using (var db = new GameMarketContext())
            {
                _crudMethods.Create(1, 1);
                _crudMethods.Update(1, 1, 3);

                var updatedGameDev = db.GameDevelopers.Where(bg => bg.GameId == 1 && bg.DeveloperId == 3).FirstOrDefault();
                Assert.AreEqual(3, updatedGameDev.DeveloperId);
            }
        }
        public void WhenANewRecordIsAdded_TheNumberOfRecordsIncreasesBy1()
        {
            using (var db = new GameMarketContext())
            {
                var numberOfGameDevsBefore = db.GameDevelopers.Count();
                _crudMethods.Create(1, 1);
                var numberOfGameDevsAfter = db.GameDevelopers.Count();

                Assert.AreEqual(numberOfGameDevsBefore + 1, numberOfGameDevsAfter);
            }
        }
 public void WhenCorrectLoginDetailsAreEntered_SelectedIsSetToTrue()
 {
     using (var db = new GameMarketContext())
     {
         userMethods.Create("unitTest", "unitTestUsername", "*****@*****.**", "unitTest");
         decimal loginUserID  = login.emailCheck("*****@*****.**", "unitTest");
         var     selectedUser = db.Users.Where(u => u.Selected == true).FirstOrDefault();
         Assert.AreNotEqual(loginUserID, 0);
         Assert.AreEqual("unitTestUsername", selectedUser.Username);
     }
 }
        public void WhenANewUserIsAdded_TheNumberOfUsersIncreasesBy1()
        {
            using (var db = new GameMarketContext())
            {
                var numberOfUsersBefore = db.Users.Count();
                _crudMethods.Create("Sam Pickard", "Beausy", "*****@*****.**", "test123");
                var numberOfUsersAfter = db.Users.Count();

                Assert.AreEqual(numberOfUsersBefore + 1, numberOfUsersAfter);
            }
        }
Exemple #20
0
 public void Update(string usernameOld, string usernameNew, string region, decimal wallet, string email, string password)
 {
     using (var db = new GameMarketContext())
     {
         userUpdate          = db.Users.Where(c => c.Username == usernameOld).FirstOrDefault();
         userUpdate.Username = usernameNew;
         userUpdate.Wallet   = wallet;
         userUpdate.Email    = email;
         userUpdate.Password = password;
         db.SaveChanges();
     }
 }
Exemple #21
0
 public void selectedReset()
 {
     using (var db = new GameMarketContext())
     {
         var selectedUsers = db.Users;
         foreach (var item in selectedUsers)
         {
             item.Selected = false;
         }
         db.SaveChanges();
     }
 }
        public void WhenANewGameIsAdded_TheNumberOfGamesIncreasesBy1()
        {
            using (var db = new GameMarketContext())
            {
                var numberOfGamesBefore = db.Games.Count();
                _crudMethods.Create("Yakuza 0", "SEGA’s legendary Japanese series finally comes to PC. Fight like hell through Tokyo and Osaka as junior yakuza Kiryu and Majima. Take a front row seat to 1980s life in Japan in an experience unlike anything else in video gaming, with uncapped framerates and 4K resolutions. A legend is born.",
                                    null, 14.99m, "SEGA", 2018, 08, 01);
                var numberOfGamesAfter = db.Games.Count();

                Assert.AreEqual(numberOfGamesBefore + 1, numberOfGamesAfter);
            }
        }
Exemple #23
0
 static void Main(string[] args)
 {
     using (var db = new GameMarketContext())
     {
         //db.Add(new GameGenre()
         //{
         //    GameId = 1,
         //    GenreId = 6
         //});
         db.SaveChanges();
     }
 }
        public void WhenANewGenreIsDeleted_TheNumberOfGenresDecreasesBy1()
        {
            using (var db = new GameMarketContext())
            {
                _crudMethods.Create("VR");
                var numberOfGenresBefore = db.Genres.Count();
                _crudMethods.Delete("VR");
                var numberOfGenresAfter = db.Genres.Count();

                Assert.AreEqual(numberOfGenresBefore - 1, numberOfGenresAfter);
            }
        }
        public void WhenAGenresIsChanged_TheDatabaseIsUpdated()
        {
            using (var db = new GameMarketContext())
            {
                _crudMethods.Create("FPS");

                _crudMethods.Update("FPS", "Adventure");

                var updatedGenre = db.Genres.Where(g => g.GenreName == "Adventure").FirstOrDefault();
                Assert.AreEqual("Adventure", updatedGenre.GenreName);
            }
        }
        public void WhenANewDevIsDeleted_TheNumberOfGamesDecreasesBy1()
        {
            using (var db = new GameMarketContext())
            {
                _crudMethods.Create("Treyarch");
                var numberOfUsersBefore = db.Developers.Count();
                _crudMethods.Delete("Treyarch");
                var numberOfUsersAfter = db.Developers.Count();

                Assert.AreEqual(numberOfUsersBefore - 1, numberOfUsersAfter);
            }
        }
        public void WhenADevsDetailsAreChanged_TheDatabaseIsUpdated()
        {
            using (var db = new GameMarketContext())
            {
                _crudMethods.Create("Bethesda");

                _crudMethods.Update("Bethesda", "Bethesda Softworks");

                var updatedCustomer = db.Developers.Where(d => d.DeveloperName == "Bethesda Softworks").FirstOrDefault();
                Assert.AreEqual("Bethesda Softworks", updatedCustomer.DeveloperName);
            }
        }
        public void WhenAUsersDetailsAreChanged_TheDatabaseIsUpdated()
        {
            using (var db = new GameMarketContext())
            {
                _crudMethods.Create("Sam Pickard", "Beausy", "*****@*****.**", "test123");

                _crudMethods.Update("Beausy", "Beausy2", "UK", 11.99m, "*****@*****.**", "test123");

                var updatedCustomer = db.Users.Where(u => u.Username == "Beausy2").FirstOrDefault();
                Assert.AreEqual("Beausy2", updatedCustomer.Username);
            }
        }
        public void WhenTheGameIDIsPassedInTheGameRecordIsDeleted()
        {
            using (var db = new GameMarketContext())
            {
                _crudMethods.Create(1, 1);
                var numberOfPurchasesBefore = db.GameDevelopers.Count();
                _crudMethods.Delete(1, 1);
                var numberOfPurchasesAfter = db.GameDevelopers.Count();

                Assert.AreEqual(numberOfPurchasesBefore - 1, numberOfPurchasesAfter);
            }
        }
Exemple #30
0
        public void Create(int gameID, int genreID)
        {
            GameGenre newGameGenre = new GameGenre()
            {
                GameId = gameID, GenreId = genreID
            };

            using (var db = new GameMarketContext())
            {
                db.GameGenres.Add(newGameGenre);
                db.SaveChanges();
            }
        }