Exemplo n.º 1
0
        public override void Setup()
        {
            base.Setup();
            dao = new UserGameInfoSQLDAO(ConnectionString);
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                connection.Open();
                SqlCommand cmd = connection.CreateCommand();
                cmd.CommandText = @"
                insert into Franchises (franchise_id,franchise_name) values(0,'No Franchise')
                insert into Covers (cover_id,cover_url) values(0,'testurl.com')
                insert into Genres (genre_id,genre_name) values(0,'Test Genre')
                insert into Platforms (platform_id,platform_name) values (0,'PizzaPiGameRunner')
                insert into Ratings (popularity,hype,rating,rating_count) values (100,200,5,7)
                select scope_identity()";

                rtingID         = Convert.ToInt32(cmd.ExecuteScalar());
                cmd.CommandText = @"insert into Games(game_id, game_name, rating_id, platform_id_array, cover_id, genre_id_array, franchise_id, game_description)
                values(200, 'CW 01', @ratingId, 0, 0, 0, 0, 'Coder wars the start!'),(300,'Faja',@ratingId,0,0,0,0,'Mr Taco presents')";
                cmd.Parameters.AddWithValue("@ratingId", rtingID);
                cmd.ExecuteNonQuery();
                cmd.CommandText = @"insert into UserInfo (userName,password,salt) values ('testUser','password','salt')";
                cmd.ExecuteNonQuery();
                cmd.CommandText = @"insert into UserGameInfo (userName,game_id,progress,owned,wishlist)
                 values ('testUser',200,0,1,0)";
                cmd.ExecuteNonQuery();
            }
        }
 public DataBaseMediator()
 {
     platformsSQLDAO      = new PlatformsSQLDAO(ConnectionString);
     coverSQLDAO          = new CoversSQLDAO(ConnectionString);
     franchiseSQLDAO      = new FranchisesSQLDAO(ConnectionString);
     gameInfoSQLDAO       = new GameInfoSQLDAO(ConnectionString);
     gameRatingSQLDAO     = new GameRatingSQLDAO(ConnectionString);
     genresSQLDAO         = new GenresSQLDAO(ConnectionString);
     userGameInfoSQLDAO   = new UserGameInfoSQLDAO(ConnectionString);
     userLoginSQLDAO      = new UserLoginSqlDao(ConnectionString, hash);
     genresIGDBDAO        = new GenresIGDBDAO(UserApiKey);
     platformsInfoIGDBDAO = new PlatformsIGDBDAO(UserApiKey);
     gameInfoIGDBDAO      = new GameInfoIGDBDAO(UserApiKey, ConnectionString);
     coversIGDBDAO        = new CoversIGDBDAO(UserApiKey);
     franchisesIGDBDAO    = new FranchisesIGDBDAO(UserApiKey);
 }