Feat : Des tests et rework des reviews mais sous com à fix.
continuous-integration/drone/push Build is passing Details

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent 803e9c08ce
commit c0401ff660

@ -52,7 +52,7 @@ namespace Model
}
private string[]? tags;
public List<Review> Reviews { get; }
public List<Review> Reviews { get; private init; }
public Game(string name, string description, int year, string[] tags)
{

@ -43,8 +43,9 @@ namespace Model
}
private string authorName;
public Review(float rate, string text)
public Review(/*string username,*/ float rate, string text)
{
//AuthorName = username;
AuthorName = authorName;
Rate = rate;
Text = text;

@ -79,23 +79,25 @@ namespace Model
Password = password;
Followed_Games = new List<Game>();
}
public void AddReview(Game game, Review review)
public void AddReview(Game game, float rate, string text)
{
game.AddReview(review);
game.AddReview(new Review(/*username,*/ rate, text));
}
public void RemoveSelfReview(Game game, Review review)
public void RemoveSelfReview(Game game, float rate, string text)
{
if (review.AuthorName == username)
foreach (Review review in game.Reviews)
{
game.RemoveReview(review);
if (review.Rate == rate && review.Text == text && review.AuthorName == username) game.RemoveReview(review);
}
}
public void FollowAGame(Game game)
{
if (Followed_Games.Contains(game)) return;
Followed_Games.Add(game);
}
public void RemoveAGame(Game game)
{
if (!Followed_Games.Contains(game)) return;
Followed_Games.Remove(game);
}
}

@ -26,15 +26,35 @@ namespace Test
Assert.Null(user.Username);
}
[Fact]
public void AddingGameToFollowed()
public void AddingAndAddingGameToFollowed()
{
User user = new("username", "biographie", "adresse.mail@gmail.com", "Azerty123*");
Assert.NotNull(user);
Assert.Empty(user.Followed_Games);
Game game = new("name", "description", 2012, new string[] {"1","2","3"});
Game game = new("name", "description", 2012, new string[] { "1", "2", "3" });
Assert.NotNull(game);
user.FollowAGame(game);
Assert.Single(user.Followed_Games);
user.RemoveAGame(game);
Assert.Empty(user.Followed_Games);
}
/*
[Fact]
public void ReviewAddingAndRemovingFromAGameViaUser()
{
User user = new("username", "biographie", "adresse.mail@gmail.com", "Azerty123*");
Game game = new("name", "description", 2012, new string[] { "1", "2", "3" });
Assert.NotNull(user);
Assert.NotNull(game);
user.AddReview(game, 2.5f,"UwU");
Assert.Single(game.Reviews);
user.RemoveSelfReview(game, 2.5f, "UwU");
Assert.Empty(game.Reviews);
}
*/
}
}

Loading…
Cancel
Save