From 803e9c08ce0c8c81d5c1463f3c76d328c9f5f39e Mon Sep 17 00:00:00 2001 From: "Jade.VAN_BRABANDT" Date: Sat, 13 May 2023 11:32:37 +0200 Subject: [PATCH] Feat : Follow Game Test --- Sources/Stim.Model/User.cs | 17 +++++++++++++++-- Sources/TestProject1/TestUser.cs | 11 +++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) 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); + } } }