Tried to initiate the user's password and put some constraint to it
continuous-integration/drone/push Build is failing Details

pull/35/head^2
Roxane ROSSETTO 2 years ago
parent df9577d690
commit e9c2c4ff7b

@ -14,7 +14,7 @@ foreach (User user in users)
{
Console.WriteLine(user.Name);
Console.WriteLine(user.Priorities[0].ToString());
} catch (ArgumentNullException erreurNomVide)
} catch (ArgumentException erreurNomVide)
{
Console.WriteLine(erreurNomVide.Message);
}

@ -4,6 +4,7 @@ using System.Collections;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
namespace MCTGLib
{
@ -15,29 +16,22 @@ namespace MCTGLib
{
#region Private Attributes
private string name;
private string surname;
private string mail;
private string name="";
private string surname="";
private string mail = "";
private string picture = "";
private string password = "";
//private bool isAdmin;
private string defaultUserSavePath = "";
private List<Priority> priorities;
#endregion
#region Properties
private string picture;
/// <summary>
/// For now, we define the ProfilPict as a string which is "PhotoParDefaut"
/// when the value is null.
/// </summary>
public string ProfilPict
{
get => picture;
set => picture = value;
}
/// <summary>
/// Property to get Name of users and a setter
/// </summary>
/// <exception cref="ArgumentNullException" >Setter have Exception which is trigger when Name is null</exception>
/// <exception cref="ArgumentException" >Setter have Exception which is trigger when Name is null</exception>
public string Name
{
get { return name; }
@ -45,15 +39,16 @@ namespace MCTGLib
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentNullException("Il y a une erreur de Nom d'utilisateur!");
throw new ArgumentException("Impossible d'avoir un champ Nom vide!");
}
name = value;
}
}
/// <summary>
/// Property to get Surname of users and a setter
/// </summary>
/// <exception cref="ArgumentNullException" >Setter have Exception which is trigger when Surname is null</exception>
/// <exception cref="ArgumentException" >Setter have Exception which is trigger when Surname is null</exception>
public string Surname
{
get { return surname; }
@ -61,15 +56,16 @@ namespace MCTGLib
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentNullException("Il y a une erreur de Prénom d'utilisateur.");
throw new ArgumentException("Impossible d'avoir un champ Prénom vide!");
}
surname = value;
}
}
/// <summary>
/// Property to get mail of users and a setter
/// </summary>
/// <exception cref="ArgumentNullException" >User's mail will serve to log the user. So there's no setter, just an init. User will enter one time his email at his
/// <exception cref="ArgumentException" >User's mail will serve to log the user. So there's no setter, just an init. User will enter one time his email at his
/// account creation.</exception>
public string Mail
{
@ -78,14 +74,46 @@ namespace MCTGLib
{
if (string.IsNullOrWhiteSpace(value))
{
throw new ArgumentNullException("Il y a une erreur de Mail d'utilisateur.");
throw new ArgumentException("Impossible d'avoir un champ Email vide!");
}
mail = value;
}
}
/// <summary>
/// For now, we define the ProfilPict as a string which is "PhotoParDefaut"
/// when the value is null.
/// </summary>
public string ProfilPict
{
get => picture;
set => picture = value;
}
///<summary>
///Password property
/// </summary>
public string Password
{
get => password;
private set
{
string modelPassword = @"[a-z]*[A-Z]+$" ;
if (!string.IsNullOrWhiteSpace(value))
{
throw new ArgumentException("Le mot de passe ne doit pas etre vide ");
}
// if (Regex.IsMatch(value, modelPassword, RegexOptions. )
}
}
/// <summary>
/// This is the list of priorities specific tu the user. This list is initiate
/// by default. User could change it at will.
/// </summary>
private List<Priority> priorities;
public List<Priority> Priorities
{
get => priorities;
@ -109,6 +137,7 @@ namespace MCTGLib
Name = name;
Surname = surname;
Mail = mail;
Password = password;
priorities = new List<Priority> {
Priority.Gourmet,
Priority.Economic,

Loading…
Cancel
Save