Exemple #1
0
 public ParentalControlsConfiguration(string filename)
 {
     this.filename = filename;
     maxGameRating = GameRating.AdultPlayers;
     maxMoveRating = MovieRating.NC17;
     timeLimit     = new TimeSpan(2, 0, 0);
 }
        public async Task <IActionResult> RatePost(int id, int rating)
        {
            if (rating <= 10 && rating > 0)
            {
                var currentUser = await userManager.FindByNameAsync(User.Identity.Name);

                var newRating = new GameRating()
                {
                    GameId = id,
                    UserId = currentUser.Id,
                    Rating = rating,
                };

                var obj = _db.GameRating.Where(gr => gr.GameId == id).FirstOrDefault(gr => gr.UserId == currentUser.Id);

                if (obj != null)
                {
                    _db.GameRating.Remove(obj);
                }

                _db.GameRating.Add(newRating);
                _db.SaveChanges();
            }

            return(Redirect(Request.Headers["Referer"].ToString()));
        }
Exemple #3
0
        public void GameRatingTestConstructorTest()
        {
            var gameRating = new GameRating();

            Assert.AreEqual(gameRating.Id, 0);
            Assert.AreEqual(gameRating.GameId, 0);
            Assert.AreEqual(gameRating.RatingId, 0);
        }
Exemple #4
0
        public void SaveGameRating(GameRating gameRating)
        {
            List <GameRating> gameRatings = GetGameRatings();

            gameRatings.Add(gameRating);

            File.WriteAllText(Path.Combine(BaseDirectory, fileName), JsonConvert.SerializeObject(gameRatings));
        }
Exemple #5
0
        public void GameRatingGenerateDeleteStatementTest()
        {
            var gameRating = new GameRating(
                1,
                2,
                3, "Notes");

            Assert.AreEqual(gameRating.GenerateDeleteStatement(), "DELETE FROM GameRating WHERE Id = 1");
        }
Exemple #6
0
        public void GameRatingGenerateUpdateStatementTest()
        {
            var gameRating = new GameRating(
                1,
                2,
                3, "Notes");

            Assert.AreEqual(gameRating.GenerateUpdateStatement(), "UPDATE GameRating SET GameId = 2, RatingId = 3 WHERE Id = 1");
        }
Exemple #7
0
        public void GameRatingGenerateExistsQueryTest()
        {
            var gameRating = new GameRating(
                1,
                2,
                3, "Notes");

            Assert.AreEqual(gameRating.GenerateExistsQuery(), "SELECT Id FROM GameRating WHERE Id = 1");
        }
Exemple #8
0
        public async Task <IActionResult> Seeding()
        {
            try
            {
                var mongodb = GetMongoCollection();
                await mongodb.DeleteManyAsync(new BsonDocument { });

                await mongodb.Indexes.DropAllAsync();

                var lmyRating = new GameRating();
                lmyRating.Rating    = 5;
                lmyRating.UserName  = "******";
                lmyRating.Reason    = "Mnie League of Legends absolutnie oczarowało. To świetna, dopracowana gra multiplayerowa i każdy, komu podobało się Diablo, lubi orać expy i killować monstery (oraz innych graczy) powinien być zachwycony.";
                lmyRating.AddedDate = DateTime.Now;
                var defaultGameRating = new List <GameRating>();
                defaultGameRating.Add(lmyRating);

                var vmyRating = new GameRating();
                vmyRating.Rating    = 5;
                vmyRating.UserName  = "******";
                vmyRating.Reason    = "Valorant bezkompromisowo uderza tam, gdzie powinien - w serca graczy tęskniących za wielogodzinnymi sesjami, kończonymi satysfakcją z rozegranych meczów.";
                vmyRating.AddedDate = DateTime.Now;
                var defaultGameRating2 = new List <GameRating>();
                defaultGameRating2.Add(vmyRating);

                var leaugeOfLegends = new Game
                {
                    Id            = new ObjectId(),
                    ImageUrl      = "https://static.antyweb.pl/uploads/2013/09/League-of-legends-Champions-1420x670.jpg",
                    Description   = "Sieciowa gra komputerowa z gatunku multiplayer online battle arena. Powstała na bazie modyfikacji Defense of the Ancients do Warcraft III: The Frozen Throne. Została wyprodukowana i wydana przez studio Riot Games, początkowo tylko dla systemu Windows.",
                    Name          = "Leauge of Legends",
                    Ratings       = defaultGameRating,
                    AverageRating = 5
                };

                var valorant = new Game
                {
                    Id            = new ObjectId(),
                    ImageUrl      = "https://esportlife.pl/wp-content/uploads/2020/04/valo-1024x576.jpg",
                    Description   = "Sieciowa strzelanka pierwszoosobowa oparta na modelu free-to-play. Zapowiedziana 15 października 2019 jako „Project A”, ostatecznie ukazała się pod obecną nazwą 2 marca 2020. Zamknięta beta rozpoczęła się 7 kwietnia 2020 w rejonach Europy i Ameryki Północnej. Premiera odbyła się 2 czerwca 2020.",
                    Name          = "Valorant",
                    Ratings       = defaultGameRating2,
                    AverageRating = 5
                };

                await mongodb.InsertOneAsync(leaugeOfLegends);

                await mongodb.InsertOneAsync(valorant);

                return(Ok("Seeding successfully completed."));
            }
            catch (Exception ex)
            {
                return(BadRequest());
            }
        }
Exemple #9
0
        public void Be_TypeOfInt()
        {
            var vote = new GameRating();

            vote.Value = 1;

            var result = vote.Value.GetType();

            Assert.True(result == typeof(int));
        }
Exemple #10
0
        public void GameRatingGenerateInsertStatementTest()
        {
            var gameRating = new GameRating(
                1,
                2,
                3,
                "Notes");

            Assert.AreEqual(gameRating.GenerateInsertStatement(), "INSERT INTO GameRating (GameId, RatingId) VALUES (2, 3)");
        }
        public void PushGameRatingTest()
        {
            int        newRatingId;
            GameRating test = new GameRating();

            newRatingId = dao.PushGameRating(9000, 51, 23, 55);
            test        = dao.PullGameRating(newRatingId);
            Assert.AreEqual(rtingID + 1, test.Rating_Id);
            Assert.AreEqual(51, test.Game_popularity);
        }
        public void RatingsAddToSQLTest() //Testing is limited due to the values always changing
        {
            IList <GameInfo> testList = new List <GameInfo>();

            testList = mediator.GetGames("Halo", false);
            GameRating testRating = new GameRating();

            testRating = daoGameRatings.PullGameRating(testList[0].ratingId);
            Assert.AreEqual(0, testRating.Game_Hype);
        }
        public void PullGameRatingTest()
        {
            GameRating test = new GameRating();

            test = dao.PullGameRating(rtingID);
            Assert.AreEqual(100, test.Game_popularity);
            Assert.AreEqual(200, test.Game_Hype);
            Assert.AreEqual(5, test.Game_Total_Rating);
            Assert.AreEqual(7, test.Game_Total_Rating_Count);
        }
Exemple #14
0
        public void GameRatingGeneratePrimaryKeyWhereClauseTest()
        {
            var gameRating = new GameRating();

            Assert.AreEqual(gameRating.GeneratePrimaryKeyWhereClause(), "");

            gameRating = new GameRating(
                1,
                2,
                3, "Notes");

            Assert.AreEqual(gameRating.GeneratePrimaryKeyWhereClause(), "Id = 1");
        }
Exemple #15
0
        public void GameRatingGenerateSelectQueryTest()
        {
            var gameRating = new GameRating();

            Assert.AreEqual(gameRating.GenerateSelectQuery(), "SELECT Id, GameId, RatingId FROM GameRating");

            gameRating = new GameRating(
                1,
                2,
                3, "Notes");

            Assert.AreEqual(gameRating.GenerateSelectQuery(), "SELECT Id, GameId, RatingId FROM GameRating WHERE Id = 1");
        }
Exemple #16
0
        public void GameRatingXmlCloneTest()
        {
            var gameRating1 = new GameRating(
                1,
                2,
                3, "Notes");

            var gameRating2 = CloneUtility.XmlClone(gameRating1, null);

            Assert.AreNotSame(gameRating1, gameRating2);

            Assert.AreEqual(gameRating1.Id, gameRating2.Id);
            Assert.AreEqual(gameRating1.GameId, gameRating2.GameId);
            Assert.AreEqual(gameRating1.RatingId, gameRating2.RatingId);
        }
Exemple #17
0
        public void GameRatingPropertiesTest()
        {
            var gameRating = new GameRating();

            Assert.AreEqual(gameRating.Id, 0);
            gameRating.Id = 1;
            Assert.AreEqual(gameRating.Id, 1);

            Assert.AreEqual(gameRating.GameId, 0);
            gameRating.GameId = 2;
            Assert.AreEqual(gameRating.GameId, 2);

            Assert.AreEqual(gameRating.RatingId, 0);
            gameRating.RatingId = 3;
            Assert.AreEqual(gameRating.RatingId, 3);
        }
Exemple #18
0
        public void GameRatingJsonTest()
        {
            var gameRating1 = new GameRating(
                1,
                2,
                3, "Notes");

            var jsonText = CloneUtility.ToJson(gameRating1);

            Assert.IsFalse(string.IsNullOrEmpty(jsonText));

            var gameRating2 = CloneUtility.FromJson <GameRating>(jsonText);

            Assert.AreNotSame(gameRating1, gameRating2);

            Assert.AreEqual(gameRating1.Id, gameRating2.Id);
            Assert.AreEqual(gameRating1.GameId, gameRating2.GameId);
            Assert.AreEqual(gameRating1.RatingId, gameRating2.RatingId);
        }
Exemple #19
0
        public void GameRatingDictionaryTest()
        {
            var gameRating1 = new GameRating(
                1,
                2,
                3, "Notes");

            var dictionary = GameRating.ToDictionary(gameRating1);

            Assert.IsNotNull(dictionary);

            var gameRating2 = GameRating.FromDictionary(dictionary);

            Assert.AreNotSame(gameRating1, gameRating2);

            Assert.AreEqual(gameRating1.Id, gameRating2.Id);
            Assert.AreEqual(gameRating1.GameId, gameRating2.GameId);
            Assert.AreEqual(gameRating1.RatingId, gameRating2.RatingId);
        }
Exemple #20
0
        public JsonResult AddRating(GameRating newRating)
        {
            CVGSAppEntities db = new CVGSAppEntities();

            var userId = User.Identity.GetUserId();

            var existingRatingByUser = db.GameRatings.FirstOrDefault(rating => rating.GameId == newRating.GameId && rating.UserId == userId);

            if (existingRatingByUser != null)
            {
                existingRatingByUser.Rating = newRating.Rating;
            }
            else
            {
                GameRating gameRating = new GameRating
                {
                    Id     = Guid.NewGuid().ToString(),
                    UserId = userId,
                    Rating = newRating.Rating,
                    GameId = newRating.GameId
                };

                db.GameRatings.Add(gameRating);
            }

            db.SaveChanges();

            // Get new average
            var ratings = db.GameRatings.Where(rating => rating.GameId == newRating.GameId);

            decimal averageRating = Convert.ToDecimal(ratings.Average(r => r.Rating));

            var game = db.Games.FirstOrDefault(g => g.Id == newRating.GameId);

            if (game != null)
            {
                game.Rating = averageRating;
                db.SaveChanges();
            }
            return(Json(new { Success = true, Rating = averageRating }, JsonRequestBehavior.AllowGet));
        }
Exemple #21
0
        public GameRating PullGameRating(int rating_Id)
        {
            //Pulls Rating info based on the id
            GameRating pulledGameRating = new GameRating();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = @"select * from Ratings 
                where rating_id = @ratingId";
                cmd.Parameters.AddWithValue("@ratingId", rating_Id);
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    pulledGameRating.Game_Hype               = (int)reader["hype"];
                    pulledGameRating.Game_popularity         = (int)reader["popularity"];
                    pulledGameRating.Rating_Id               = rating_Id;
                    pulledGameRating.Game_Total_Rating       = (int)reader["rating"];
                    pulledGameRating.Game_Total_Rating_Count = (int)reader["rating_count"];
                }
            }
            return(pulledGameRating);
        }
            public void LoadRatedGames(IList list,
						    GameRating aboveThis)
            {
                Query query = db.Query ();
                query.Constrain (typeof (PGNGameDetails));
                Query ratingQuery = query.Descend ("rating");
                ratingQuery.Constrain (aboveThis).Greater ();
                ratingQuery.OrderDescending ();

                ObjectSet res = query.Execute ();
                while (res.HasNext ())
                  {
                      PGNGameDetails details
                          =
                          (PGNGameDetails) res.
                          Next ();
                      list.Add (details);
                  }
            }
            public void AddGame(ChessGame game,
					     GameRating rating,
					     out PGNGameDetails updated)
            {
                FindOrCreateGame (game, out updated);
                if (updated.Rating != rating)
                  {
                      updated.Rating = rating;
                      SaveGame (updated);
                  }
            }
Exemple #24
0
        public void GameLibrarygRpcClientTests()
        {
            // Startup the singleton for the ModelAssembler
            GameLibraryAgent.Startup(ConnectionString);

            // Startup the gRPC Web Services server.
            var gameLibraryServer = new Grpc.Core.Server
            {
                Services = { Gamelibrary.GameLibrary.BindService(new GameLibraryServer()) },
                Ports    = { new ServerPort(GrpcHostName, GrpcPort, ServerCredentials.Insecure) }
            };

            gameLibraryServer.Start();

            Assert.IsTrue(true);


            // Create a gRPC Web Services client.

            var channel = new Channel($"{GrpcHost}:{GrpcPort}", ChannelCredentials.Insecure);
            var client  = new GameLibraryClient(new Gamelibrary.GameLibrary.GameLibraryClient(channel));


            #region GameTest
            // Get all games

            var games = client.SearchGames(0, "");

            Assert.IsNotNull(games);
            Assert.AreEqual(games.List.Count, 0);


            // Add a game

            var game = new Game(0, "Qbert", "A silly penguin");

            var errorMessage = "";
            var result       = client.AddGame(game, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(game.Id > 0);


            // Get the new game by id.

            games = client.SearchGames(game.Id, "");

            Assert.IsNotNull(games);
            Assert.AreEqual(games.List.Count, 1);

            var foundGame = games.List[0];

            Assert.IsNotNull(foundGame);
            Assert.AreEqual(foundGame.Id, game.Id);


            // Get the new game by name.

            games = client.SearchGames(0, game.Name);

            Assert.IsNotNull(games);
            Assert.AreEqual(games.List.Count, 1);

            foundGame = games.List[0];

            Assert.IsNotNull(foundGame);
            Assert.AreEqual(foundGame.Name, game.Name);


            // Edit a game

            var editGame = new Game(game.Id, "Bilbo Baggins", "A silly hobbit who finds a ring");

            errorMessage = "";
            result       = client.EditGame(editGame, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editGame.Id > 0);


            // Get the new game by name.

            games = client.SearchGames(0, editGame.Name);

            Assert.IsNotNull(games);
            Assert.AreEqual(games.List.Count, 1);

            foundGame = games.List[0];

            Assert.IsNotNull(foundGame);
            Assert.AreEqual(foundGame.Name, "Bilbo Baggins");
            Assert.AreEqual(foundGame.Description, "A silly hobbit who finds a ring");


            // Get all games

            games = client.SearchGames(0, "");

            Assert.IsNotNull(games);
            Assert.AreEqual(games.List.Count, 1);


            // Delete a game

            errorMessage = "";
            result       = client.DeleteGame(foundGame.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));


            // Get all games

            games = client.SearchGames(0, "");

            Assert.IsNotNull(games);
            Assert.AreEqual(games.List.Count, 0);

            #endregion GameTest

            #region GenreTest

            // Get all genres

            var genres = client.SearchGenres(0, "");

            Assert.IsNotNull(genres);
            Assert.AreEqual(genres.List.Count, 0);


            // Add a genre

            var genre = new Genre(0, "Qbert", "A silly penguin");

            errorMessage = "";
            result       = client.AddGenre(genre, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(genre.Id > 0);


            // Get the new genre by id.

            genres = client.SearchGenres(genre.Id, "");

            Assert.IsNotNull(genres);
            Assert.AreEqual(genres.List.Count, 1);

            var foundGenre = genres.List[0];

            Assert.IsNotNull(foundGenre);
            Assert.AreEqual(foundGenre.Id, genre.Id);


            // Get the new genre by name.

            genres = client.SearchGenres(0, genre.Name);

            Assert.IsNotNull(genres);
            Assert.AreEqual(genres.List.Count, 1);

            foundGenre = genres.List[0];

            Assert.IsNotNull(foundGenre);
            Assert.AreEqual(foundGenre.Name, genre.Name);


            // Edit a genre

            var editGenre = new Genre(genre.Id, "Bilbo Baggins", "A silly hobbit who finds a ring");

            errorMessage = "";
            result       = client.EditGenre(editGenre, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editGenre.Id > 0);


            // Get the new genre by name.

            genres = client.SearchGenres(0, editGenre.Name);

            Assert.IsNotNull(genres);
            Assert.AreEqual(genres.List.Count, 1);

            foundGenre = genres.List[0];

            Assert.IsNotNull(foundGenre);
            Assert.AreEqual(foundGenre.Name, "Bilbo Baggins");
            Assert.AreEqual(foundGenre.Description, "A silly hobbit who finds a ring");


            // Get all genres

            genres = client.SearchGenres(0, "");

            Assert.IsNotNull(genres);
            Assert.AreEqual(genres.List.Count, 1);


            // Delete a genre

            errorMessage = "";
            result       = client.DeleteGenre(foundGenre.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));


            // Get all genres

            genres = client.SearchGenres(0, "");

            Assert.IsNotNull(genres);
            Assert.AreEqual(genres.List.Count, 0);

            #endregion GenreTest

            #region RatingTest

            // Get all ratings

            var ratings = client.SearchRatings(0, "");

            Assert.IsNotNull(ratings);
            Assert.AreEqual(ratings.List.Count, 0);


            // Add a rating

            var rating = new Rating(0, "Qbert", "A silly penguin", "Symbol");

            errorMessage = "";
            result       = client.AddRating(rating, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(rating.Id > 0);


            // Get the new rating by id.

            ratings = client.SearchRatings(rating.Id, "");

            Assert.IsNotNull(rating);
            Assert.AreEqual(ratings.List.Count, 1);

            var foundRating = ratings.List[0];

            Assert.IsNotNull(foundRating);
            Assert.AreEqual(foundRating.Id, rating.Id);


            // Get the new rating by name.

            ratings = client.SearchRatings(0, rating.Name);

            Assert.IsNotNull(ratings);
            Assert.AreEqual(ratings.List.Count, 1);

            foundRating = ratings.List[0];

            Assert.IsNotNull(foundRating);
            Assert.AreEqual(foundRating.Name, rating.Name);


            // Edit a rating

            var editRating = new Rating(rating.Id, "Bilbo Baggins", "A silly hobbit who finds a ring", "5");

            errorMessage = "";
            result       = client.EditRating(editRating, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editRating.Id > 0);


            // Get the new rating by name.

            ratings = client.SearchRatings(0, editRating.Name);

            Assert.IsNotNull(ratings);
            Assert.AreEqual(ratings.List.Count, 1);

            foundRating = ratings.List[0];

            Assert.IsNotNull(foundRating);
            Assert.AreEqual(foundRating.Name, "Bilbo Baggins");
            Assert.AreEqual(foundRating.Description, "A silly hobbit who finds a ring");


            // Get all ratings

            ratings = client.SearchRatings(0, "");

            Assert.IsNotNull(ratings);
            Assert.AreEqual(ratings.List.Count, 1);


            // Delete a rating

            errorMessage = "";
            result       = client.DeleteRating(foundRating.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));


            // Get all ratings

            ratings = client.SearchRatings(0, "");

            Assert.IsNotNull(ratings);
            Assert.AreEqual(ratings.List.Count, 0);

            #endregion RatingTest

            #region ReviewTest

            // Get all reviews

            var reviews = client.SearchReview(0, "");

            Assert.IsNotNull(reviews);
            Assert.AreEqual(reviews.List.Count, 0);


            // Add a review

            var review = new Review(0, "Qbert", "A silly penguin", 5);

            errorMessage = "";
            result       = client.AddReview(review, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(review.Id > 0);


            // Get the new review by id.

            reviews = client.SearchReview(review.Id, "");

            Assert.IsNotNull(review);
            Assert.AreEqual(reviews.List.Count, 1);

            var foundReview = reviews.List[0];

            Assert.IsNotNull(foundReview);
            Assert.AreEqual(foundReview.Id, review.Id);


            // Get the new review by name.

            reviews = client.SearchReview(0, review.Name);

            Assert.IsNotNull(reviews);
            Assert.AreEqual(reviews.List.Count, 1);

            foundReview = reviews.List[0];

            Assert.IsNotNull(foundReview);
            Assert.AreEqual(foundReview.Name, review.Name);


            // Edit a review

            var editReview = new Review(review.Id, "Bilbo Baggins", "A silly hobbit who finds a ring", 6);

            errorMessage = "";
            result       = client.EditReview(editReview, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editReview.Id > 0);


            // Get the new review by name.

            reviews = client.SearchReview(0, editReview.Name);

            Assert.IsNotNull(reviews);
            Assert.AreEqual(reviews.List.Count, 1);

            foundReview = reviews.List[0];

            Assert.IsNotNull(foundReview);
            Assert.AreEqual(foundReview.Name, "Bilbo Baggins");
            Assert.AreEqual(foundReview.Description, "A silly hobbit who finds a ring");


            // Get all reviews

            reviews = client.SearchReview(0, "");

            Assert.IsNotNull(reviews);
            Assert.AreEqual(reviews.List.Count, 1);


            // Delete a review

            errorMessage = "";
            result       = client.DeleteReview(foundReview.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));


            // Get all reviews

            reviews = client.SearchReview(0, "");

            Assert.IsNotNull(reviews);
            Assert.AreEqual(reviews.List.Count, 0);

            #endregion ReviewTest

            #region PlatformTest

            // Get all platforms

            var platforms = client.SearchPlatforms(0, "");

            Assert.IsNotNull(platforms);
            Assert.AreEqual(platforms.List.Count, 0);


            // Add a platform

            var platform = new Platform(0, "Qbert", "A silly penguin");

            errorMessage = "";
            result       = client.AddPlatform(platform, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(platform.Id > 0);


            // Get the new platform by id.

            platforms = client.SearchPlatforms(platform.Id, "");

            Assert.IsNotNull(platform);
            Assert.AreEqual(platforms.List.Count, 1);

            var foundPlatform = platforms.List[0];

            Assert.IsNotNull(foundPlatform);
            Assert.AreEqual(foundPlatform.Id, platform.Id);


            // Get the new platfrom by name.

            platforms = client.SearchPlatforms(0, platform.Name);

            Assert.IsNotNull(platforms);
            Assert.AreEqual(platforms.List.Count, 1);

            foundPlatform = platforms.List[0];

            Assert.IsNotNull(foundPlatform);
            Assert.AreEqual(foundPlatform.Name, platform.Name);


            // Edit a platform

            var editPlatfrom = new Platform(platform.Id, "Bilbo Baggins", "A silly hobbit who finds a ring");

            errorMessage = "";
            result       = client.EditPlatform(editPlatfrom, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editPlatfrom.Id > 0);


            // Get the new platform by name.

            platforms = client.SearchPlatforms(0, editPlatfrom.Name);

            Assert.IsNotNull(platforms);
            Assert.AreEqual(platforms.List.Count, 1);

            foundPlatform = platforms.List[0];

            Assert.IsNotNull(foundPlatform);
            Assert.AreEqual(foundPlatform.Name, "Bilbo Baggins");
            Assert.AreEqual(foundPlatform.Maker, "A silly hobbit who finds a ring");


            // Get all platforms

            platforms = client.SearchPlatforms(0, "");

            Assert.IsNotNull(platforms);
            Assert.AreEqual(platforms.List.Count, 1);


            // Delete a platform

            errorMessage = "";
            result       = client.DeletePlatform(foundPlatform.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));


            // Get all platforms

            platforms = client.SearchPlatforms(0, "");

            Assert.IsNotNull(platforms);
            Assert.AreEqual(platforms.List.Count, 0);

            #endregion PlatformTest

            #region GameGenreTest

            // Get all GameGenres

            var gameGenres = client.SearchGameGenres(0);

            Assert.IsNotNull(gameGenres);
            Assert.AreEqual(gameGenres.List.Count, 0);


            // Add a game

            game = new Game(0, "Qbert", "A silly penguin");

            errorMessage = "";
            result       = client.AddGame(game, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(game.Id > 0);

            // Add a edited game

            var editedgame = new Game(0, "Bob", "A silly duck");

            errorMessage = "";
            result       = client.AddGame(editedgame, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editedgame.Id > 0);

            // Add a genre

            genre = new Genre(0, "Qbert", "A silly penguin");

            errorMessage = "";
            result       = client.AddGenre(genre, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(genre.Id > 0);

            // Add a edited genre

            var editedgenre = new Genre(0, "joe", "A silly hobo");

            errorMessage = "";
            result       = client.AddGenre(editedgenre, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editedgenre.Id > 0);

            // Add a GameGenre

            var gameGenre = new GameGenre(0, game.Id, genre.Id);

            errorMessage = "";
            result       = client.AddGameGenre(gameGenre, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(gameGenre.Id > 0);


            // Get the GameGenre by id.


            gameGenres = client.SearchGameGenres(gameGenre.Id);

            Assert.IsNotNull(gameGenre);
            Assert.AreEqual(gameGenres.List.Count, 1);

            var foundgameGenre = gameGenres.List[0];

            Assert.IsNotNull(foundgameGenre);
            Assert.AreEqual(foundgameGenre.Id, gameGenre.Id);

            // Get the GameReview by GameId

            gameGenres = client.SearchGameGenreByGameId(gameGenre.GameId);

            Assert.IsNotNull(gameGenre);
            Assert.AreEqual(gameGenres.List.Count, 1);

            Assert.IsNotNull(foundgameGenre);
            Assert.AreEqual(foundgameGenre.GameId, foundgameGenre.GameId);

            // Get the GameReview by GenreId

            gameGenres = client.SearchGameGenreByGenreId(gameGenre.GenreId);

            Assert.IsNotNull(gameGenre);

            Assert.IsNotNull(foundgameGenre);
            Assert.AreEqual(foundgameGenre.GenreId, foundgameGenre.GenreId);

            // Edit a GameGenre

            var editgamegenre = new GameGenre(gameGenre.Id, editedgame.Id, editedgenre.Id);

            errorMessage = "";
            result       = client.EditGameGenre(editgamegenre, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editPlatfrom.Id > 0);

            // Get all GameGenres

            gameGenres = client.SearchGameGenres(0);

            Assert.IsNotNull(gameGenres);
            Assert.AreEqual(gameGenres.List.Count, 1);


            // Delete a GameGenre

            errorMessage = "";
            result       = client.DeleteGameGenre(foundgameGenre.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete a game

            errorMessage = "";
            result       = client.DeleteGame(game.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete edited game

            errorMessage = "";
            result       = client.DeleteGame(editedgame.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete a genre

            errorMessage = "";
            result       = client.DeleteGenre(genre.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete edited genre

            errorMessage = "";
            result       = client.DeleteGenre(editedgenre.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));


            // Get all Game Genres

            gameGenres = client.SearchGameGenres(0);

            Assert.IsNotNull(gameGenres);
            Assert.AreEqual(gameGenres.List.Count, 0);

            #endregion PlatformTest

            #region GamePlatformTest

            // Get all GamePlatform

            var gamePlatforms = client.SearchGamePlatforms(0);

            Assert.IsNotNull(gamePlatforms);
            Assert.AreEqual(gamePlatforms.List.Count, 0);


            // Add a game

            game = new Game(0, "Qbert", "A silly penguin");

            errorMessage = "";
            result       = client.AddGame(game, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(game.Id > 0);

            // Add a edited game

            editedgame = new Game(0, "Bob", "A silly duck");

            errorMessage = "";
            result       = client.AddGame(editedgame, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editedgame.Id > 0);

            // Add a platform

            platform = new Platform(0, "Qbert", "A silly penguin");

            errorMessage = "";
            result       = client.AddPlatform(platform, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(platform.Id > 0);

            // Add a edited platform

            var editedplatform = new Platform(0, "joe", "A silly hobo");

            errorMessage = "";
            result       = client.AddPlatform(editedplatform, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editedplatform.Id > 0);

            // Add a GamePlattform

            var gamePlatform = new GamePlatform(0, game.Id, platform.Id);

            errorMessage = "";
            result       = client.AddGamePlatform(gamePlatform, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(gamePlatform.Id > 0);


            // Get the GamePlatform by id.


            gamePlatforms = client.SearchGamePlatforms(gamePlatform.Id);

            Assert.IsNotNull(gamePlatform);
            Assert.AreEqual(gamePlatforms.List.Count, 1);

            var foundgamePlatform = gamePlatforms.List[0];

            Assert.IsNotNull(foundgamePlatform);
            Assert.AreEqual(foundgamePlatform.Id, gamePlatform.Id);

            // Get GamePlatform by game id

            gamePlatforms = client.SearchGamePlatformByGameId(gamePlatform.GameId);

            Assert.IsNotNull(gamePlatform);

            Assert.IsNotNull(foundgamePlatform);
            Assert.AreEqual(foundgamePlatform.GameId, gamePlatform.GameId);

            // Get GamePlatform by platform id

            gamePlatforms = client.SearchGamePlatformByPlatformId(gamePlatform.PlatformId);

            Assert.IsNotNull(gamePlatform);

            Assert.IsNotNull(foundgamePlatform);
            Assert.AreEqual(foundgamePlatform.PlatformId, gamePlatform.PlatformId);

            // Edit a GamePlatform

            var editgameplatform = new GamePlatform(gamePlatform.Id, editedgame.Id, editedplatform.Id);

            errorMessage = "";
            result       = client.EditGamePlatform(editgameplatform, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editPlatfrom.Id > 0);

            // Get all GamePlatform

            gamePlatforms = client.SearchGamePlatforms(0);

            Assert.IsNotNull(gamePlatforms);
            Assert.AreEqual(gamePlatforms.List.Count, 1);


            // Delete a GamePlatform

            errorMessage = "";
            result       = client.DeleteGamePlatform(foundgamePlatform.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete a game

            errorMessage = "";
            result       = client.DeleteGame(game.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete edited game

            errorMessage = "";
            result       = client.DeleteGame(editedgame.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete a platform

            errorMessage = "";
            result       = client.DeletePlatform(platform.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete edited platform

            errorMessage = "";
            result       = client.DeletePlatform(editedplatform.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));


            // Get all Game Platforms

            gamePlatforms = client.SearchGamePlatforms(0);

            Assert.IsNotNull(gamePlatforms);
            Assert.AreEqual(gamePlatforms.List.Count, 0);

            #endregion PlatformTest

            #region GameReviewTest

            // Get all GameReview

            var gameReviews = client.SearchGameReviews(0);

            Assert.IsNotNull(gameReviews);
            Assert.AreEqual(gameReviews.List.Count, 0);


            // Add a game

            game = new Game(0, "Qbert", "A silly penguin");

            errorMessage = "";
            result       = client.AddGame(game, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(game.Id > 0);

            // Add a edited game

            editedgame = new Game(0, "Bob", "A silly duck");

            errorMessage = "";
            result       = client.AddGame(editedgame, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editedgame.Id > 0);

            // Add a review

            review = new Review(0, "Qbert", "A silly penguin", 5);

            errorMessage = "";
            result       = client.AddReview(review, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(review.Id > 0);

            // Add a edited review

            var editedreview = new Review(0, "joe", "A silly hobo", 6);

            errorMessage = "";
            result       = client.AddReview(editedreview, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editedreview.Id > 0);

            // Add a GameReview

            var gameReview = new GameReview(0, game.Id, review.Id);

            errorMessage = "";
            result       = client.AddGameReview(gameReview, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(gameReview.Id > 0);

            // Get the GameReview by id.

            gameReviews = client.SearchGameReviews(gameReview.Id);

            Assert.IsNotNull(gameReview);
            Assert.AreEqual(gameReviews.List.Count, 1);

            var foundgameReview = gameReviews.List[0];

            Assert.IsNotNull(foundgameReview);
            Assert.AreEqual(foundgameReview.Id, gameReview.Id);


            // Get the GameReview by GameId

            gameReviews = client.SearchGameReviewsByGameId(gameReview.GameId);

            Assert.IsNotNull(gameReview);
            Assert.AreEqual(gameReviews.List.Count, 0);

            Assert.IsNotNull(foundgameReview);
            Assert.AreEqual(foundgameReview.GameId, gameReview.GameId);

            // Get the GameReview by ReviewId

            gameReviews = client.SearchGameReviewsByReviewId(gameReview.ReviewId);

            Assert.IsNotNull(gameReview);
            Assert.AreEqual(gameReviews.List.Count, 0);

            Assert.IsNotNull(foundgameReview);
            Assert.AreEqual(foundgameReview.ReviewId, gameReview.ReviewId);

            // Edit a GameReview

            var editgamereview = new GameReview(gameReview.Id, editedgame.Id, editedreview.Id);

            errorMessage = "";
            result       = client.EditGameReview(editgamereview, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editgamereview.Id > 0);

            // Get all GameReview

            gameReviews = client.SearchGameReviews(0);

            Assert.IsNotNull(gameReviews);
            Assert.AreEqual(gameReviews.List.Count, 1);


            // Delete a GameReview

            errorMessage = "";
            result       = client.DeleteGameReview(foundgameReview.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete a game

            errorMessage = "";
            result       = client.DeleteGame(game.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete edited game

            errorMessage = "";
            result       = client.DeleteGame(editedgame.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete a review

            errorMessage = "";
            result       = client.DeleteReview(review.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete edited review

            errorMessage = "";
            result       = client.DeleteReview(editedreview.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));


            // Get all Game Reviews

            gameReviews = client.SearchGameReviews(0);

            Assert.IsNotNull(gameReviews);
            Assert.AreEqual(gameReviews.List.Count, 0);

            #endregion GameReviewTest

            #region GameRatingTest

            // Get all GameRating

            var gameRatings = client.SearchGameRatings(0);

            Assert.IsNotNull(gameReviews);
            Assert.AreEqual(gameReviews.List.Count, 0);


            // Add a game

            game = new Game(0, "Qbert", "A silly penguin");

            errorMessage = "";
            result       = client.AddGame(game, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(game.Id > 0);

            // Add a edited game

            editedgame = new Game(0, "Bob", "A silly duck");

            errorMessage = "";
            result       = client.AddGame(editedgame, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editedgame.Id > 0);

            // Add a rating

            rating = new Rating(0, "Qbert", "A silly penguin", "joe");

            errorMessage = "";
            result       = client.AddRating(rating, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(rating.Id > 0);

            // Add a edited review

            var editedrating = new Rating(0, "joe", "A silly hobo", "6");

            errorMessage = "";
            result       = client.AddRating(editedrating, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editedreview.Id > 0);

            // Add a GameRating

            var gameRating = new GameRating(0, game.Id, rating.Id, "note");

            errorMessage = "";
            result       = client.AddGameRating(gameRating, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(gameRating.Id > 0);

            // Get the GameRating by id.

            gameRatings = client.SearchGameRatings(gameRating.Id);

            Assert.IsNotNull(gameRating);
            Assert.AreEqual(gameRatings.List.Count, 1);

            var foundgameRating = gameRatings.List[0];

            Assert.IsNotNull(foundgameRating);
            Assert.AreEqual(foundgameRating.Id, gameRating.Id);

            // Get the GameRating by game id.

            gameRatings = client.SearchGameRatingByGameId(gameRating.GameId);

            Assert.IsNotNull(gameRating);

            Assert.IsNotNull(foundgameRating);
            Assert.AreEqual(foundgameRating.GameId, gameRating.GameId);

            // Get the GameRating by game id.

            gameRatings = client.SearchGameRatingByRatingId(gameRating.RatingId);

            Assert.IsNotNull(gameRating);

            Assert.IsNotNull(foundgameRating);
            Assert.AreEqual(foundgameRating.RatingId, gameRating.RatingId);

            // Edit a GameRating

            var editgamerating = new GameRating(gameRating.Id, editedgame.Id, editedrating.Id, "more notes");

            errorMessage = "";
            result       = client.EditGameRating(editgamerating, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editgamerating.Id > 0);

            // Get all GameRating

            gameRatings = client.SearchGameRatings(0);

            Assert.IsNotNull(gameRatings);
            Assert.AreEqual(gameRatings.List.Count, 1);


            // Delete a GameRating

            errorMessage = "";
            result       = client.DeleteGameRating(foundgameRating.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete a game

            errorMessage = "";
            result       = client.DeleteGame(game.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete edited game

            errorMessage = "";
            result       = client.DeleteGame(editedgame.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete a review

            errorMessage = "";
            result       = client.DeleteRating(rating.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete edited review

            errorMessage = "";
            result       = client.DeleteRating(editedrating.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));


            // Get all Game Ratings

            gameRatings = client.SearchGameRatings(0);

            Assert.IsNotNull(gameRatings);
            Assert.AreEqual(gameRatings.List.Count, 0);

            #endregion GameRatingTest

            #region GameImageTest

            // Get all GameImages

            var gameImages = client.SearchGameImages(0);

            Assert.IsNotNull(gameReviews);
            Assert.AreEqual(gameReviews.List.Count, 0);


            // Add a game

            game = new Game(0, "Qbert", "A silly penguin");

            errorMessage = "";
            result       = client.AddGame(game, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(game.Id > 0);

            // Add a edited game

            editedgame = new Game(0, "Bob", "A silly duck");

            errorMessage = "";
            result       = client.AddGame(editedgame, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editedgame.Id > 0);

            // Add a GameImage

            var gameImage = new GameImage(0, game.Id, null);

            errorMessage = "";
            result       = client.AddGameImage(gameImage, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(gameImage.Id > 0);

            // Get the GameImage by id.

            gameImages = client.SearchGameImages(gameImage.Id);

            Assert.IsNotNull(gameImage);
            Assert.AreEqual(gameImages.List.Count, 1);

            var foundgameImage = gameImages.List[0];

            Assert.IsNotNull(foundgameImage);
            Assert.AreEqual(foundgameImage.Id, gameImage.Id);

            // Get the GameImage by game id.

            gameImages = client.SearchGameImageByGameId(gameImage.GameId);

            Assert.IsNotNull(gameImage);
            Assert.AreEqual(gameImages.List.Count, 1);

            foundgameImage = gameImages.List[0];

            Assert.IsNotNull(foundgameImage);
            Assert.AreEqual(foundgameImage.GameId, gameImage.GameId);

            // Edit a GameImage

            var editgameImage = new GameImage(gameImage.Id, editedgame.Id, null);

            errorMessage = "";
            result       = client.EditGameImage(editgameImage, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));
            Assert.IsTrue(editgameImage.Id > 0);

            // Get all GameImages

            gameImages = client.SearchGameImages(0);

            Assert.IsNotNull(gameImages);
            Assert.AreEqual(gameImages.List.Count, 1);

            // Delete a GameImage

            errorMessage = "";
            result       = client.DeleteGameImage(foundgameImage.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete a game

            errorMessage = "";
            result       = client.DeleteGame(game.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Delete edited game

            errorMessage = "";
            result       = client.DeleteGame(editedgame.Id, ref errorMessage);

            Assert.IsTrue(result);
            Assert.IsTrue(string.IsNullOrEmpty(errorMessage));

            // Get all Game Ratings

            gameImages = client.SearchGameImages(0);

            Assert.IsNotNull(gameImages);
            Assert.AreEqual(gameImages.List.Count, 0);

            #endregion GameImageTest

            // Shutdown the gRPC Web Services server.
            gameLibraryServer.ShutdownAsync().Wait();
        }
Exemple #25
0
        public void GameRatingDatabaseCommandsTest()
        {
            var connection = new SqlServerConnection();

            Assert.AreEqual(connection.IsConnected, false);

            var result = connection.Connect(ConnectionString, 0);

            Assert.AreEqual(result, true);


            // Add Games

            var game = new Game(
                0,
                "Name",
                "Description");

            var insertCommand = game.GenerateInsertStatement();

            Assert.IsFalse(string.IsNullOrEmpty(insertCommand));

            var errorMessage = "";
            var insertResult = connection.ExecuteCommand(insertCommand, ref errorMessage, out var newId);

            Assert.IsTrue(insertResult);
            Assert.IsTrue(newId > 0);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);

            game.Id = newId;

            var updateGame = new Game(
                0,
                "Name1",
                "Description1");

            insertCommand = updateGame.GenerateInsertStatement();

            Assert.IsFalse(string.IsNullOrEmpty(insertCommand));

            errorMessage = "";
            insertResult = connection.ExecuteCommand(insertCommand, ref errorMessage, out newId);

            Assert.IsTrue(insertResult);
            Assert.IsTrue(newId > 0);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);

            updateGame.Id = newId;


            // Add Ratings

            var rating = new Rating(0, "Name", "Description", "Symbol");

            insertCommand = rating.GenerateInsertStatment();
            Assert.IsFalse(string.IsNullOrEmpty(insertCommand));

            errorMessage = "";
            insertResult = connection.ExecuteCommand(insertCommand, ref errorMessage, out newId);

            Assert.IsTrue(insertResult);
            Assert.IsTrue(newId > 0);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);

            rating.Id = newId;

            var updateGenre = new Rating(0, "Name", "Description", "Symbol");

            insertCommand = updateGenre.GenerateInsertStatment();
            Assert.IsFalse(string.IsNullOrEmpty(insertCommand));

            errorMessage = "";
            insertResult = connection.ExecuteCommand(insertCommand, ref errorMessage, out newId);

            Assert.IsTrue(insertResult);
            Assert.IsTrue(newId > 0);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);

            updateGenre.Id = newId;


            // Select All

            var gameRating = new GameRating();

            var selectQuery = gameRating.GenerateSelectQuery();

            Assert.IsFalse(string.IsNullOrEmpty(selectQuery));

            errorMessage = "";
            var selectResult = connection.ExecuteQuery(selectQuery, ref errorMessage);

            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);
            Assert.IsNotNull(selectResult);

            var selectResultList = DataSetUtility.ToDictionaryList(selectResult.Tables[0]);

            if (selectResultList.Count > 0)
            {
                Assert.IsTrue(selectResultList.Count > 0);
            }


            // Insert

            gameRating = new GameRating(
                0,
                game.Id,
                rating.Id,
                "Notes");

            insertCommand = gameRating.GenerateInsertStatement();

            Assert.IsFalse(string.IsNullOrEmpty(insertCommand));

            errorMessage = "";

            insertResult = connection.ExecuteCommand(insertCommand, ref errorMessage, out newId);

            Assert.IsTrue(insertResult);
            Assert.IsTrue(newId > 0);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);

            gameRating.Id = newId;


            // Exists

            var existsQuery = gameRating.GenerateExistsQuery();

            Assert.IsFalse(string.IsNullOrEmpty(existsQuery));

            errorMessage = "";
            var existsResult = connection.ExecuteQuery(existsQuery, ref errorMessage);

            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);
            Assert.IsNotNull(existsResult);

            var existsResultList = DataSetUtility.ToDictionaryList(existsResult.Tables[0]);

            var recordExists = existsResultList.Any(dictionary => (dictionary != null) && (dictionary.Count > 0));

            Assert.AreEqual(recordExists, true);


            // Select

            selectQuery = gameRating.GenerateSelectQuery();

            Assert.IsFalse(string.IsNullOrEmpty(selectQuery));

            errorMessage = "";
            selectResult = connection.ExecuteQuery(selectQuery, ref errorMessage);

            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);
            Assert.IsNotNull(selectResult);

            selectResultList = DataSetUtility.ToDictionaryList(selectResult.Tables[0]);

            GameRating foundGameRating = null;

            if (selectResultList.Count > 0)
            {
                foreach (var dictionary in selectResultList.Where(dictionary => (dictionary != null) && (dictionary.Count > 0)))
                {
                    foundGameRating = GameRating.FromDictionary(dictionary);
                    break;
                }
            }

            Assert.IsNotNull(foundGameRating);

            Assert.AreNotSame(gameRating, foundGameRating);

            Assert.AreEqual(gameRating.Id, foundGameRating.Id);
            Assert.AreEqual(gameRating.GameId, foundGameRating.GameId);
            Assert.AreEqual(gameRating.RatingId, foundGameRating.RatingId);


            // Update

            var updateGameRating = new GameRating(
                newId,
                updateGame.Id,
                updateGenre.Id, "Notes");

            var updateCommand = updateGameRating.GenerateUpdateStatement();

            Assert.IsFalse(string.IsNullOrEmpty(updateCommand));

            errorMessage = "";
            var updateResult = connection.ExecuteCommand(updateCommand, ref errorMessage);

            Assert.AreEqual(updateResult, true);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);


            // Exists

            existsQuery = updateGameRating.GenerateExistsQuery();

            Assert.IsFalse(string.IsNullOrEmpty(existsQuery));

            errorMessage = "";
            existsResult = connection.ExecuteQuery(existsQuery, ref errorMessage);

            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);
            Assert.IsNotNull(existsResult);

            existsResultList = DataSetUtility.ToDictionaryList(existsResult.Tables[0]);

            recordExists = existsResultList.Any(dictionary => (dictionary != null) && (dictionary.Count > 0));

            Assert.AreEqual(recordExists, true);


            // Select

            selectQuery = updateGameRating.GenerateSelectQuery();

            Assert.IsFalse(string.IsNullOrEmpty(selectQuery));

            errorMessage = "";
            selectResult = connection.ExecuteQuery(selectQuery, ref errorMessage);

            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);
            Assert.IsNotNull(selectResult);

            selectResultList = DataSetUtility.ToDictionaryList(selectResult.Tables[0]);

            foundGameRating = null;

            if (selectResultList.Count > 0)
            {
                foreach (var dictionary in selectResultList.Where(dictionary => (dictionary != null) && (dictionary.Count > 0)))
                {
                    foundGameRating = GameRating.FromDictionary(dictionary);
                    break;
                }
            }

            Assert.IsNotNull(foundGameRating);

            Assert.AreNotSame(updateGameRating, foundGameRating);

            Assert.AreEqual(updateGameRating.Id, foundGameRating.Id);
            Assert.AreEqual(updateGameRating.GameId, foundGameRating.GameId);
            Assert.AreEqual(updateGameRating.RatingId, foundGameRating.RatingId);


            // Delete

            var deleteCommand = gameRating.GenerateDeleteStatement();

            var deleteGenre = rating.GenerateDeleteStatement();

            Assert.IsFalse(string.IsNullOrEmpty(deleteCommand));

            errorMessage = "";
            var deleteResult = connection.ExecuteCommand(deleteCommand, ref errorMessage);

            Assert.AreEqual(deleteResult, true);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);


            // Exists

            existsQuery = gameRating.GenerateExistsQuery();

            Assert.IsFalse(string.IsNullOrEmpty(existsQuery));

            errorMessage = "";
            existsResult = connection.ExecuteQuery(existsQuery, ref errorMessage);

            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);
            Assert.IsNotNull(existsResult);

            existsResultList = DataSetUtility.ToDictionaryList(existsResult.Tables[0]);

            recordExists = existsResultList.Any(dictionary => (dictionary != null) && (dictionary.Count > 0));

            Assert.IsFalse(recordExists);


            // Select

            selectQuery = gameRating.GenerateSelectQuery();

            Assert.IsFalse(string.IsNullOrEmpty(selectQuery));

            errorMessage = "";
            selectResult = connection.ExecuteQuery(selectQuery, ref errorMessage);

            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);
            Assert.IsNotNull(selectResult);

            selectResultList = DataSetUtility.ToDictionaryList(selectResult.Tables[0]);

            foundGameRating = null;

            if (selectResultList.Count > 0)
            {
                foreach (var dictionary in selectResultList.Where(dictionary => (dictionary != null) && (dictionary.Count > 0)))
                {
                    foundGameRating = GameRating.FromDictionary(dictionary);
                    break;
                }
            }

            Assert.IsNull(foundGameRating);


            // Delete Ratings

            deleteCommand = rating.GenerateDeleteStatement();

            Assert.IsFalse(string.IsNullOrEmpty(deleteCommand));

            errorMessage = "";
            deleteResult = connection.ExecuteCommand(deleteCommand, ref errorMessage);

            Assert.AreEqual(deleteResult, true);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);

            deleteCommand = updateGenre.GenerateDeleteStatement();

            Assert.IsFalse(string.IsNullOrEmpty(deleteCommand));

            errorMessage = "";
            deleteResult = connection.ExecuteCommand(deleteCommand, ref errorMessage);

            Assert.AreEqual(deleteResult, true);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);


            // Delete Games

            deleteCommand = game.GenerateDeleteStatement();

            Assert.IsFalse(string.IsNullOrEmpty(deleteCommand));

            errorMessage = "";
            deleteResult = connection.ExecuteCommand(deleteCommand, ref errorMessage);

            Assert.AreEqual(deleteResult, true);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);

            deleteCommand = updateGame.GenerateDeleteStatement();

            Assert.IsFalse(string.IsNullOrEmpty(deleteCommand));

            errorMessage = "";
            deleteResult = connection.ExecuteCommand(deleteCommand, ref errorMessage);

            Assert.AreEqual(deleteResult, true);
            Assert.AreEqual(string.IsNullOrEmpty(errorMessage), true);
        }
 public bool Update(GameRating entity)
 {
     throw new NotImplementedException();
 }
 public int Insert(GameRating entity)
 {
     throw new NotImplementedException();
 }