diff --git a/Sources/Stim.Model/User.cs b/Sources/Stim.Model/User.cs index eb05410..d32de9f 100644 --- a/Sources/Stim.Model/User.cs +++ b/Sources/Stim.Model/User.cs @@ -24,7 +24,16 @@ namespace Model } private string username; - public string Biographie { get; set; } + public string Biographie + { + get { return Biographie;} + private set + { + if (value == null || value == "") return; + biographie = value; + } + } + private string? biographie; public string Email { @@ -53,7 +62,11 @@ namespace Model public int Role { get; } private int role; - public List Followed_Games { get; set; } + public List Followed_Games + { + get; + private init; + } public User(string username, string biographie, string email, string password) { diff --git a/Sources/TestProject1/TestUser.cs b/Sources/TestProject1/TestUser.cs index cbb5671..c867d81 100644 --- a/Sources/TestProject1/TestUser.cs +++ b/Sources/TestProject1/TestUser.cs @@ -25,5 +25,16 @@ namespace Test User user2 = new(null, "biographie", "adresse.mail@gmail.com", "Azerty123*"); Assert.Null(user.Username); } + [Fact] + public void AddingGameToFollowed() + { + User user = new("username", "biographie", "adresse.mail@gmail.com", "Azerty123*"); + Assert.Empty(user.Followed_Games); + + Game game = new("name", "description", 2012, new string[] {"1","2","3"}); + Assert.NotNull(game); + user.FollowAGame(game); + Assert.Single(user.Followed_Games); + } } }