Fix : 1v1 code smells

Popup_qui_marche_pas
Jade VAN BRABANDT 2 years ago
parent 313f69f1de
commit 5a8e48cc4f

@ -31,7 +31,7 @@ namespace Model
get => description; get => description;
private set private set
{ {
if (string.IsNullOrWhiteSpace(value)) return; if (string.IsNullOrWhiteSpace(value)) description="Defaut";
else else
{ {
description = value; description = value;
@ -47,7 +47,7 @@ namespace Model
get => year; get => year;
private set private set
{ {
if (value < 1957 || value > 2023) return; if (value < 1957 || value > 2023) year=2023;
else else
{ {
year = value; year = value;
@ -79,7 +79,7 @@ namespace Model
get => tags; get => tags;
private set private set
{ {
if (value == null || value.Count > 3) return; if (value == null || value.Count > 3) tags = new ObservableCollection<string>();
else else
{ {
tags = value; tags = value;
@ -104,7 +104,7 @@ namespace Model
get => lien; get => lien;
private set private set
{ {
if (string.IsNullOrWhiteSpace(value)) return; if (string.IsNullOrWhiteSpace(value)) lien = "Pas de lien";
else else
{ {
lien = value; lien = value;

@ -7,7 +7,7 @@ namespace Model
{ {
private readonly IPersistance mgrpersistance; private readonly IPersistance mgrpersistance;
public IReadOnlyList<Game> GameList => gameList.AsReadOnly(); public IReadOnlyList<Game> GameList => gameList.AsReadOnly();
private List<Game> gameList; private readonly List<Game> gameList;
public Game? SelectedGame { get; set; } public Game? SelectedGame { get; set; }
public User? CurrentUser { get; set; } public User? CurrentUser { get; set; }
public HashSet<User> Users { get; private set; } public HashSet<User> Users { get; private set; }

@ -120,6 +120,15 @@ namespace Model
if (string.IsNullOrWhiteSpace(Username)) return false; if (string.IsNullOrWhiteSpace(Username)) return false;
return other != null && Username.Equals(other.Username); return other != null && Username.Equals(other.Username);
} }
public override bool Equals(object? obj)
{
if (obj == null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return this.Equals((User)obj);
}
public override int GetHashCode() public override int GetHashCode()
{ {
if (Username!=null) return Username.GetHashCode(); if (Username!=null) return Username.GetHashCode();
@ -152,14 +161,6 @@ namespace Model
Followed_Games.Remove(game); Followed_Games.Remove(game);
} }
public override bool Equals(object? obj)
{
if (obj == null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return this.Equals((User)obj);
}
public override string ToString() public override string ToString()
{ {
StringBuilder builder = new(); StringBuilder builder = new();

@ -7,7 +7,12 @@ namespace StimStub
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
public class Stub : IPersistance public class Stub : IPersistance
{ {
public List<Game> Games = new(); public List<Game> Games
{
get { return games; }
set { games = value; }
}
private List<Game> games;
public Stub() public Stub()
{ {

Loading…
Cancel
Save