Merge branch 'UnitTest' into developpement

pull/19/head
Matheo THIERRY 2 years ago
commit 5f68d68a9a

@ -4,7 +4,8 @@ name: pipelinefordeveloppement
trigger: trigger:
branch: branch:
- vSonar_test - developpement
- master
event: event:
- push - push

@ -3,96 +3,93 @@ using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.Design; using System.ComponentModel.Design;
using System.Linq; using System.Linq;
using System.Runtime.Serialization;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace Biblioteque_de_Class namespace Biblioteque_de_Class
{ {
[DataContract]
public class Database public class Database
{ {
private List<Logo> ListDefaultLogo; [DataMember]
private List<Theme> ListTheme; private List<Logo> DefaultLogoList;
private List<Utilisateur> ListUtilisateur; [DataMember]
private List<Theme> ThemeList;
[DataMember]
private List<User> UserList;
public Database() public Database()
{ {
ListDefaultLogo = new List<Logo>(); DefaultLogoList = new List<Logo>();
ListTheme = new List<Theme>(); ThemeList = new List<Theme>();
ListUtilisateur = new List<Utilisateur>(); UserList = new List<User>();
} }
public List<Logo> GetListDefaultLogo() { return ListDefaultLogo; } public List<Logo> GetDefaultLogoList() { return DefaultLogoList; }
public List<Theme> GetListTheme() { return ListTheme; } public List<Theme> GetThemeList() { return ThemeList; }
public List<Utilisateur> GetListUtilisateur() { return ListUtilisateur; } public List<User> GetUserList() { return UserList; }
/// <summary> /// <summary>
/// recherche un utilisateur dans la liste d'utilisateur /// recherche un utilisateur dans la liste d'utilisateur
/// </summary> /// </summary>
public List<Utilisateur> RechercherUtilisateur(string name) public List<User> SearchUser(string name)
{ {
List<Utilisateur> ListUserSearch = new List<Utilisateur>(); List<User> searchedUsers = new List<User>();
string search = name.ToLower(); string search = name.ToLower();
foreach (Utilisateur user in ListUtilisateur) foreach (User user in UserList)
{ {
if (user.GetPseudo().ToLower().Contains(search)) { ListUserSearch.Add(user); } if (user.GetUsername().ToLower().Contains(search)) { searchedUsers.Add(user); }
} }
return ListUserSearch; return searchedUsers;
} }
/// <summary> /// <summary>
/// récupérer le lien d'un logo /// récupérer le lien d'un logo
/// </summary> /// </summary>
public string GetLinkLogo(string Name) public string GetLogoLink(string name)
{ {
foreach (Logo logo in ListDefaultLogo) foreach (Logo logo in DefaultLogoList)
{ {
if (logo.GetNom() == Name) { return logo.GetNom(); } if (logo.GetName() == name) { return logo.GetLogoLink(); }
}throw new Exception("no logo link find"); }
throw new Exception("No logo link found.");
} }
/// <summary> /// <summary>
/// récupérer un utilisateur /// récupérer un utilisateur
/// </summary> /// </summary>
public Utilisateur GetUtilisateur(string Name) public User GetUser(string name)
{
foreach (User user in UserList)
{ {
foreach(Utilisateur user in ListUtilisateur){ if (user.GetUsername() == name)
if(user.GetPseudo() == Name)
{ {
return user; return user;
} }
}throw new Exception("no user find with this pseudo"); }
throw new Exception("No user found with this username.");
} }
/// <summary> /// <summary>
/// comparer le mot de passe entré avec celui de l'utilisateur /// comparer le mot de passe entré avec celui de l'utilisateur
/// </summary> /// </summary>
public bool CorrespondPassword(Utilisateur user, string Psd) public bool ComparePassword(User user, string password)
{ {
if (user.GetPassword() == Psd) return user.GetPassword() == password;
{
return true;
}
else
{
return false;
}
} }
/// <summary> /// <summary>
/// rechercher un mail dans la liste d'utilisateur /// rechercher un mail dans la liste d'utilisateur
/// </summary> /// </summary>
public bool TrouverMail(string mail) public bool FindEmail(string email)
{ {
foreach (Utilisateur Mail in ListUtilisateur) foreach (User user in UserList)
{ {
if (string.Equals(mail,Mail)) if (string.Equals(user.GetEmail(), email))
{ {
return true; return true;
} }
else
{
return false;
}
} }
return false; return false;
} }
@ -100,137 +97,115 @@ namespace Biblioteque_de_Class
/// <summary> /// <summary>
/// ajouter un utilisateur dans la liste d'utilisateur /// ajouter un utilisateur dans la liste d'utilisateur
/// </summary> /// </summary>
public void AjouterUtilisateur(Utilisateur user) public void AddUser(User user)
{
foreach (Utilisateur user1 in ListUtilisateur)
{ {
if (user1.GetPseudo() == user.GetPseudo()) foreach (User existingUser in UserList)
{ {
throw new Exception("Pseudo déjà utilisé"); if (existingUser.GetUsername() == user.GetUsername())
}
else if (user1.GetMail() == user.GetMail())
{ {
throw new Exception("Mail déjà utilisé"); throw new Exception("Username already used.");
} }
else else if (existingUser.GetEmail() == user.GetEmail())
{ {
ListUtilisateur.Add(user); throw new Exception("Email already used.");
} }
} }
UserList.Add(user);
} }
/// <summary> /// <summary>
/// supprimer un utilisateur dans la liste d'utilisateur /// supprimer un utilisateur dans la liste d'utilisateur
/// </summary> /// </summary>
public void SupUtilisateur(Utilisateur user) public void RemoveUser(User user)
{ {
foreach (Utilisateur user1 in ListUtilisateur) if (UserList.Contains(user))
{ {
if (user1.GetPseudo() == user.GetPseudo()) UserList.Remove(user);
{
ListUtilisateur.Remove(user);
} }
else else
{ {
throw new Exception("Utilisateur non trouvé"); throw new Exception("User not found.");
}
} }
} }
/// <summary> /// <summary>
/// ajouter un theme dans la liste de theme /// ajouter un theme dans la liste de theme
/// </summary> /// </summary>
public void AjouterTheme(Theme stheme) public void AddTheme(Theme theme)
{ {
List<Theme> ListTheme = GetListTheme(); foreach (Theme existingTheme in ThemeList)
foreach (Theme theme in ListTheme)
{ {
if (theme.GetNom() == stheme.GetNom()) if (existingTheme.GetName() == theme.GetName())
{
throw new Exception("Theme déjà utilisé");
}
else
{ {
ListTheme.Add(stheme); throw new Exception("Theme already used.");
} }
} }
ThemeList.Add(theme);
} }
/// <summary> /// <summary>
/// supprimer un theme dans la liste de theme /// supprimer un theme dans la liste de theme
/// </summary> /// </summary>
public void SupTheme(Theme stheme) public void RemoveTheme(Theme theme)
{
List<Theme> ListTheme = GetListTheme();
foreach (Theme theme in ListTheme)
{ {
if (theme.GetNom() == stheme.GetNom()) if (ThemeList.Contains(theme))
{ {
ListTheme.Remove(theme); ThemeList.Remove(theme);
} }
else else
{ {
throw new Exception("Theme non trouvé"); throw new Exception("Theme not found.");
}
} }
} }
/// <summary> /// <summary>
/// récupérer un theme /// récupérer un theme
/// </summary> /// </summary>
public Theme GetTheme(string Name) public Theme GetTheme(string name)
{ {
List<Theme> ListTheme = GetListTheme(); foreach (Theme theme in ThemeList)
foreach (Theme theme in ListTheme)
{ {
if (theme.GetNom() == Name) if (theme.GetName() == name)
{ {
return theme; return theme;
} }
} }
throw new Exception("no theme find with this name"); throw new Exception("No theme found with this name.");
} }
/// <summary> /// <summary>
/// modifier le nom d'un theme /// modifier le nom d'un theme
/// </summary> /// </summary>
public void ModifierNomTheme( Theme stheme, string NewName) public void ModifyThemeName(Theme theme, string newName)
{
foreach (Theme theme1 in ListTheme)
{ {
if (theme1.GetNom() == stheme.GetNom()) foreach (Theme existingTheme in ThemeList)
{ {
theme1.SetNom(NewName); if (existingTheme.GetName() == theme.GetName())
}
else
{ {
throw new Exception("Theme non trouvé"); existingTheme.SetName(newName);
return;
} }
} }
throw new Exception("Theme not found.");
} }
/// <summary> /// <summary>
/// modifier la liste de couleur d'un theme /// modifier la liste de couleur d'un theme
/// </summary> /// </summary>
public void ModifierColorListTheme(Theme stheme, List<string> NewColorList) public void ModifyThemeColorList(Theme theme, List<string> newColorList)
{ {
foreach (Theme theme1 in ListTheme) foreach (Theme existingTheme in ThemeList)
{ {
if (theme1.GetNom() == stheme.GetNom()) if (existingTheme.GetName() == theme.GetName())
{ {
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
theme1.ChangeColor(theme1.GetColor(i), NewColorList[i]); existingTheme.ChangeColor(existingTheme.GetColor(i), newColorList[i]);
} }
} return;
else
{
throw new Exception("Theme non trouvé");
} }
} }
throw new Exception("Theme not found.");
} }
} }
} }

@ -8,18 +8,21 @@ namespace Biblioteque_de_Class
{ {
public class Logo public class Logo
{ {
private string Nom { get; set; } private string Name { get; set; }
private string LinkLogo { get; set; } private string LogoLink { get; set; }
public Logo(string nom, string linklogo) public Logo(string name, string logoLink)
{ {
Nom = nom; Name = name;
LinkLogo = linklogo; LogoLink = logoLink;
} }
public string GetNom() { return Nom; } public string GetName() { return Name; }
public string GetLinkLogo() { return LinkLogo; } public string GetLogoLink() { return LogoLink; }
public override string ToString() => $"logo -> nom : {Nom}\nlink : {LinkLogo}"; public void SetName(string name) { Name = name; }
public void SetLogoLink(string logoLink) { LogoLink = logoLink; }
public override string ToString() => $"Logo -> Name: {Name}\nLink: {LogoLink}";
} }
} }

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Biblioteque_de_Class
{
public class Manager
{
public Manager(Persistence
}
}

@ -8,130 +8,130 @@ namespace Biblioteque_de_Class
{ {
public class Note public class Note
{ {
private string Nom private string Name
{ {
get { return Nom; } get { return Name; }
set { if (value == null) { Nom = "Note sans nom"; } else { Nom = value; } } set { if (value == null) { Name = "Unnamed Note"; } else { Name = value; } }
} }
///private string Text { get; set; } Attribut pour le texte de la note ///private string Text { get; set; } Attribut pour le texte de la note
private string LogoPATH private string LogoPath
{ {
get { return LogoPATH; } get { return LogoPath; }
set { if (value == null) { LogoPATH = "PATH TO DEFAULT LOGO"; } else { LogoPATH = value; } } set { if (value == null) { LogoPath = "PATH TO DEFAULT LOGO"; } else { LogoPath = value; } }
} }
private DateOnly DateCreation { get;}
private DateOnly DateModif { get; set; }
private List<NoteImage> listeImage;
private List<String> listeLigneTexte;
private List<Utilisateur> cooperateurs;
private List<Utilisateur> editeurs;
private Utilisateur owner;
public Note(string nom, string logoPATH, Utilisateur uOwner) private DateOnly CreationDate { get; }
private DateOnly ModificationDate { get; set; }
private List<NoteImage> ImageList;
private List<string> TextLineList;
private List<User> Collaborators;
private List<User> Editors;
private User Owner;
public Note(string name, string logoPath, User owner)
{ {
Nom = nom; Name = name;
LogoPATH = logoPATH; LogoPath = logoPath;
DateCreation = DateOnly.FromDateTime(DateTime.Now); CreationDate = DateOnly.FromDateTime(DateTime.Now);
DateModif = DateOnly.FromDateTime(DateTime.Now); ModificationDate = DateOnly.FromDateTime(DateTime.Now);
listeImage = new List<NoteImage>(); ImageList = new List<NoteImage>();
listeLigneTexte = new List<String>(); TextLineList = new List<string>();
cooperateurs = new List<Utilisateur>(); Collaborators = new List<User>();
editeurs = new List<Utilisateur>(); Editors = new List<User>();
owner = uOwner; Owner = owner;
} }
public string GetNom() { return Nom; } public string GetName() { return Name; }
public string GetLogoPATH() { return LogoPATH; } public string GetLogoPath() { return LogoPath; }
public DateOnly GetDateCreation() { return DateCreation; } public DateOnly GetCreationDate() { return CreationDate; }
public DateOnly GetDateModif() { return DateModif; } public DateOnly GetModificationDate() { return ModificationDate; }
public List<NoteImage> GetListeImage() { return listeImage; } public List<NoteImage> GetImageList() { return ImageList; }
public List<string> GetListeLigneTexte() { return listeLigneTexte; } public List<string> GetTextLineList() { return TextLineList; }
public List<Utilisateur> GetCooperateurs() { return cooperateurs; } public List<User> GetCollaborators() { return Collaborators; }
public List<Utilisateur> GetEditeurs() { return editeurs; } public List<User> GetEditors() { return Editors; }
public Utilisateur GetOwner() { return owner; } public User GetOwner() { return Owner; }
public override string ToString() => $"note -> nom : {Nom}\nlogoPATH : {LogoPATH}\nhow many line : {listeLigneTexte.Count()}"; public override string ToString() => $"Note -> Name: {Name}\nLogoPath: {LogoPath}\nNumber of lines: {TextLineList.Count()}";
public void ModifNom(string nom) { Nom = nom; } public void SetName(string name) { Name = name; }
public void ModifLogoPATH(string logoPATH) { LogoPATH = logoPATH; } public void SetLogoPath(string logoPath) { LogoPath = logoPath; }
public void ModifDateModif() { DateModif = DateOnly.FromDateTime(DateTime.Now); } public void SetModificationDate() { ModificationDate = DateOnly.FromDateTime(DateTime.Now); }
/// <summary> /// <summary>
/// vérifier si l'utilisateur est le propriétaire de la note /// vérifier si l'utilisateur est le propriétaire de la note
/// </summary> /// </summary>
public bool VerifOwner(Utilisateur user) public bool VerifyOwner(User user)
{ {
if (user == owner) { return true; } return user == Owner;
else { return false; }
} }
public void AjouterImage(string linkImage, string position) public void AddImage(string imageLink, string position)
{ {
foreach (NoteImage image in this.GetListeImage()) foreach (NoteImage image in ImageList)
{ {
if (image.GetLinkImage() == linkImage) if (image.GetImageLink() == imageLink)
{ {
/// Do something
} }
} }
} }
public void SuppImage(string image) public void RemoveImage(string image)
{ {
/// il faut une nouvelle structure pour pouvoir stocker les images /// Need a new data structure to store images
} }
/// <summary> /// <summary>
/// vérifier si l'utilisateur est un éditeur de la note /// vérifier si l'utilisateur est un éditeur de la note
/// </summary> /// </summary>
public bool VerifPriviledge(Utilisateur user) public bool VerifyPrivilege(User user)
{ {
if (editeurs.Contains(user)) if (Editors.Contains(user))
{ {
return true; return true;
} }
else else
{ {
throw new Exception("user is not editeur"); throw new Exception("User is not an editor");
} }
} }
/// <summary> /// <summary>
/// ajouter un utilisateur en tant que coopérateur /// ajouter un utilisateur en tant que coopérateur
/// </summary> /// </summary>
public void AjouterCoop(Utilisateur owner, Utilisateur user) public void AddCollaborator(User owner, User user)
{ {
if (VerifOwner(owner)) { cooperateurs.Add(user); } if (VerifyOwner(owner)) { Collaborators.Add(user); }
else { throw new Exception("user is not owner"); } else { throw new Exception("User is not the owner"); }
} }
/// <summary> /// <summary>
/// supprimer un utilisateur en tant que coopérateur /// supprimer un utilisateur en tant que coopérateur
/// </summary> /// </summary>
public void SupCoop(Utilisateur owner, Utilisateur user) public void RemoveCollaborator(User owner, User user)
{ {
if (VerifOwner(owner)) { cooperateurs.Remove(user); } if (VerifyOwner(owner)) { Collaborators.Remove(user); }
else { throw new Exception("user is not owner"); } else { throw new Exception("User is not the owner"); }
} }
/// <summary> /// <summary>
/// passer un coopérateur en tant qu'éditeur /// passer un coopérateur en tant qu'éditeur
/// </summary> /// </summary>
public void AjouterEdit(Utilisateur owner, Utilisateur user) public void AddEditor(User owner, User user)
{ {
if (VerifOwner(owner)) { editeurs.Add(user); } if (VerifyOwner(owner)) { Editors.Add(user); }
else { throw new Exception("user is not owner"); } else { throw new Exception("User is not the owner"); }
} }
/// <summary> /// <summary>
/// supprimer un coopérateur de la liste des éditeurs /// supprimer un coopérateur de la liste des éditeurs
/// </summary> /// </summary>
public void SupEdit(Utilisateur owner, Utilisateur user) public void RemoveEditor(User owner, User user)
{ {
if (VerifOwner(owner)) { editeurs.Remove(user); } if (VerifyOwner(owner)) { Editors.Remove(user); }
else { throw new Exception("user is not owner"); } else { throw new Exception("User is not the owner"); }
} }
} }
} }

@ -8,22 +8,25 @@ namespace Biblioteque_de_Class
{ {
public class NoteImage public class NoteImage
{ {
private string Nom { get; set; } private string Name { get; set; }
private string LinkImage { get; set; } private string ImageLink { get; set; }
private string Position { get; set; } private string Position { get; set; }
public NoteImage(string nom, string linkimage, string position) public NoteImage(string name, string imageLink, string position)
{ {
Nom = nom; Name = name;
LinkImage = linkimage; ImageLink = imageLink;
Position = position; Position = position;
} }
public string GetNom() { return Nom; } public string GetName() { return Name; }
public string GetLinkImage() { return LinkImage; } public string GetImageLink() { return ImageLink; }
public string GetPosition() { return Position; } public string GetPosition() { return Position; }
public override string ToString() => $"image -> nom : {Nom}\nlink : {LinkImage}"; public void SetName(string name) { Name = name; }
public void SetImageLink(string imageLink) { ImageLink = imageLink; }
public void SetPosition(string position) { Position = position; }
public override string ToString() => $"image -> name: {Name}\nlink: {ImageLink}";
} }
} }

@ -8,19 +8,20 @@ namespace Biblioteque_de_Class
{ {
public class Tags public class Tags
{ {
private string Nom { get; set; } private string Name { get; set; }
private string Couleur { get; set; } private string Color { get; set; }
public Tags(string nom, string couleur) public Tags(string name, string color)
{ {
Nom = nom; Name = name;
Couleur = couleur; Color = color;
} }
public string GetNom() { return Nom; } public string GetName() { return Name; }
public string GetCouleur() { return Couleur; } public string GetColor() { return Color; }
public void SetName(string name) { Name = name; }
public override string ToString() => $"tag -> nom : {Nom}\ncouleur : {Couleur}"; public void SetColor(string color) { Color = color; }
public override string ToString() => $"tag -> name: {Name}\ncolor: {Color}";
} }
} }

@ -8,32 +8,32 @@ namespace Biblioteque_de_Class
{ {
public class Theme public class Theme
{ {
private string Nom { get; set; } private string Name { get; set; }
private List<string> ListCouleur; private List<string> ColorList;
public Theme(string nom, List<string> listCouleur) public Theme(string name, List<string> colorList)
{ {
Nom = nom; Name = name;
ListCouleur = listCouleur; ColorList = colorList;
} }
public string GetNom() { return Nom; } public string GetName() { return Name; }
public void SetNom(string nom) { Nom = nom; } public void SetName(string name) { Name = name; }
public List<string> GetColorList() { return ListCouleur; } public List<string> GetColorList() { return ColorList; }
public string GetColor(int code) { return ListCouleur[code]; } public string GetColor(int index) { return ColorList[index]; }
public override string ToString() => $"nom : {Nom} color 1: {ListCouleur[0]}\ncolor 2: {ListCouleur[1]}\ncolor 3: {ListCouleur[2]}\n"; public override string ToString() => $"name: {Name}\ncolor 1: {ColorList[0]}\ncolor 2: {ColorList[1]}\ncolor 3: {ColorList[2]}\n";
/// <summary> /// <summary>
/// changer la couleur spécifique d'un theme /// Change a specific color of the theme.
/// </summary> /// </summary>
public void ChangeColor(string color, string newColor) public void ChangeColor(string color, string newColor)
{ {
for (int i = 0; i < ListCouleur.Count; i++) for (int i = 0; i < ColorList.Count; i++)
{ {
if (ListCouleur[i] == color) if (ColorList[i] == color)
{ {
ListCouleur[i] = newColor; ColorList[i] = newColor;
} }
} }
} }

@ -0,0 +1,245 @@
using Microsoft.VisualBasic.FileIO;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
using System.Runtime.Serialization;
namespace Biblioteque_de_Class
{
[DataContract]
public class User
{
[DataMember]
private string Username { get; set; }
[DataMember]
private string Email { get; set; }
[DataMember]
private string Password { get; set; }
[DataMember]
private List<Note> NoteList;
[DataMember]
private List<Tags> TagList;
[DataMember]
private List<Note> FavList;
[DataMember]
private bool IsConnected { get; set; }
[DataMember]
private Dictionary<Note, List<Tags>> NoteTagged;
public User(string username, string email, string password)
{
Username = username;
Email = email;
Password = password;
NoteList = new List<Note>();
TagList = new List<Tags>();
FavList = new List<Note>();
NoteTagged = new Dictionary<Note, List<Tags>>();
}
public string GetUsername() { return Username; }
public string GetEmail() { return Email; }
public string GetPassword() { return Password; }
public List<Note> GetNoteList() { return NoteList; }
public List<Tags> GetTagList() { return TagList; }
public List<Note> GetFavList() { return FavList; }
public bool GetIsConnected() { return IsConnected; }
public Dictionary<Note, List<Tags>> GetNoteTagged() { return NoteTagged; }
public void SetUsername(string username) { Username = username; }
public void SetEmail(string email) { Email = email; }
public void SetPassword(string password) { Password = password; }
public void SetIsConnected(bool isConnected) { IsConnected = isConnected; }
public override string ToString() => $"username: {Username}\nemail: {Email}\npassword: {Password}\nOwned notes: {NoteList.Count}";
/// <summary>
/// rechercher une note dans la liste de note de l'utilisateur
/// </summary>
public List<Note> SearchNoteByName(string name)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in NoteList)
{
if (note.GetName().ToLower().Contains(search))
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
/// <summary>
/// rechercher une note dans la liste de note favoris de l'utilisateur
/// </summary>
public List<Note> SearchFavoriteNoteByName(string name)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in FavList)
{
if (note.GetName().ToLower().Contains(search))
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
/// <summary>
/// rechercher un tag dans la liste de tag de l'utilisateur
/// </summary>
public List<Tags> SearchTagByName(string name)
{
List<Tags> searchedTags = new List<Tags>();
string search = name.ToLower();
foreach (Tags tag in TagList)
{
if (tag.GetName().ToLower().Contains(search))
{
searchedTags.Add(tag);
}
}
return searchedTags;
}
/// <summary>
/// ajouter une note dans la liste de note favorite de l'utilisateur
/// </summary>
public void AddFavorite(Note note)
{
if (FavList.Contains(note))
{
throw new Exception("Note already in favorites");
}
FavList.Add(note);
}
/// <summary>
/// supprimer une note dans la liste de note favorite de l'utilisateur
/// </summary>
public void RemoveFavorite(Note note)
{
if (FavList.Contains(note))
{
FavList.Remove(note);
}
else
{
throw new Exception("Note not found");
}
}
/// <summary>
///creer une note
/// </summary>
public void CreateNote(string name, string imagePath)
{
foreach (Note existingNote in NoteList)
{
if (existingNote.GetName() == name)
{
throw new Exception("Note already exists");
}
}
Note note = new Note(name, imagePath, this);
NoteList.Add(note);
NoteTagged.Add(note, new List<Tags>());
}
/// <summary>
/// supprimer une note
/// </summary>
public void DeleteNote(Note note)
{
if (NoteList.Contains(note))
{
NoteList.Remove(note);
NoteTagged.Remove(note);
}
else
{
throw new Exception("Note not found");
}
}
/// <summary>
/// creer un tag
/// </summary>
public void CreateTag(string name, string color)
{
foreach (Tags tag in TagList)
{
if (tag.GetName() == name)
{
throw new Exception("Tag already exists");
}
}
TagList.Add(new Tags(name, color));
}
/// <summary>
/// supprimer un tag
/// </summary>
public void DeleteTag(string name)
{
foreach (Tags tag in TagList)
{
if (tag.GetName() == name)
{
TagList.Remove(tag);
return;
}
}
}
/// <summary>
/// ajouter un tag a une note
/// </summary>
public void AddTagToNoteList(Note note, Tags tagToAdd)
{
if (!TagList.Contains(tagToAdd))
{
throw new Exception("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new Exception("Note not found");
}
NoteTagged[note].Add(tagToAdd);
}
/// <summary>
/// supprimer un tag a une note
/// </summary>
public void RemoveTagFromNoteList(Note note, Tags tagToRemove)
{
if (!TagList.Contains(tagToRemove))
{
throw new Exception("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new Exception("Note not found");
}
NoteTagged[note].Remove(tagToRemove);
}
/// <summary>
/// ajouter plusieur tag a une note
/// </summary>
public void AddTagsToNoteList(Note note, List<Tags> tags)
{
NoteTagged.Add(note, tags);
}
/// <summary>
///supprimer tout les tags d'une note
/// </summary>
public void RemoveTagsFromNoteList(Note note)
{
NoteTagged.Remove(note);
}
}
}

@ -1,202 +0,0 @@
using Microsoft.VisualBasic.FileIO;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations.Schema;
namespace Biblioteque_de_Class
{
public class Utilisateur
{
private string Pseudo { get; set; }
private string Mail { get; set; }
private string Password { get; set; }
private List<Note> NoteList;
private List<Tags> TagList;
private List<Note> FavList;
private bool connecte { get; set; }
private Dictionary<Note, List<Tags>> NoteTaged;
public Utilisateur(string Upseudo, string Umail, string Upassword)
{
Pseudo = Upseudo;
Mail = Umail;
Password = Upassword;
NoteList = new List<Note>();
TagList = new List<Tags>();
FavList = new List<Note>();
NoteTaged = new Dictionary<Note, List<Tags>>();
}
public string GetPseudo() { return Pseudo; }
public string GetMail() { return Mail; }
public string GetPassword() { return Password; }
public List<Note> GetNoteList() { return NoteList; }
public List<Tags> GetTagList() { return TagList; }
public List<Note> GetFavList() { return FavList; }
public bool GetConnecte() { return connecte; }
public Dictionary<Note, List<Tags>> GetNoteTaged() { return NoteTaged; }
public override string ToString() => $"pseudo : {Pseudo}\nmail : {Mail}\npassword : {Password}\nNote possédé : {NoteList.Count}";
/// <summary>
/// rechercher une note dans la liste de note de l'utilisateur
/// </summary>
public List<Note> RechercherNote(string name)
{
List<Note> ListNotesearch = new List<Note>();
string search = name.ToLower();
foreach(Note note in NoteList){
if(note.GetNom().ToLower().Contains(search)) { ListNotesearch.Add(note); }
}return ListNotesearch;
}
/// <summary>
/// rechercher une note dans la liste de note favoris de l'utilisateur
/// </summary>
public List<Note> RechercherNoteFav(string name)
{
List<Note> ListNotesearch = new List<Note>();
string search = name.ToLower();
foreach(Note note in FavList){
if(note.GetNom().ToLower().Contains(search)) { ListNotesearch.Add(note); }
}return ListNotesearch;
}
/// <summary>
/// rechercher un tag dans la liste de tag de l'utilisateur
/// </summary>
public List<Tags> RechercherTags(string name)
{
List<Tags> ListTagssearch = new List<Tags>();
string search = name.ToLower();
foreach(Tags tag in TagList){
if(tag.GetNom().ToLower().Contains(search)) { ListTagssearch.Add(tag); }
}
return ListTagssearch;
}
/// <summary>
/// ajouter une note dans la liste de note favorite de l'utilisateur
/// </summary>
public void AddFav(Note note)
{
foreach(Note notefav in FavList)
{
if (notefav.Equals(note))
{
throw new Exception("Note already in favorite");
}
}
FavList.Add(note);
}
/// <summary>
/// supprimer une note dans la liste de note favorite de l'utilisateur
/// </summary>
public void SupFav(Note note)
{
foreach(Note notefav in FavList)
{
if (notefav.Equals(note))
{
FavList.Remove(note);
}
}
throw new Exception("Note not found");
}
/// <summary>
///creer une note
/// </summary>
public void CreateNote(string nom, string LogoPath)
{
foreach (Note eachnote in NoteList)
{
if (eachnote.GetNom() == nom)
{
throw new Exception("Note already exist");
}
}
Note note = new Note(nom, LogoPath,this);
NoteList.Add(note);
NoteTaged.Add(note, new List<Tags>());
}
/// <summary>
/// supprimer une note
/// </summary>
public void DeleteNote(Note note)
{
if (NoteList.Contains(note))
{
NoteList.Remove(note);
NoteTaged.Remove(note);
}
else
throw new Exception("Note not found");
}
/// <summary>
/// creer un tag
/// </summary>
public void CreateTag(string name, string color)
{
foreach(Tags tag in TagList){
if(tag.GetNom() == name) { throw new Exception("Tag already exist"); }
}
TagList.Add(new Tags(name, color));
}
/// <summary>
/// supprimer un tag
/// </summary>
public void DeleteTag(string name)
{
foreach(Tags tag in TagList){
if(tag.GetNom() == name) { TagList.Remove(tag); }
}
}
/// <summary>
/// ajouter un tag a une note
/// </summary>
public void AddOneTagToNoteList(Note note, Tags tagtoadd)
{
if (TagList.Contains(tagtoadd) == false) { throw new Exception("Tag not found"); }
if(NoteList.Contains(note) == false) { throw new Exception("Note not found"); }
else
{
NoteTaged[note].Add(tagtoadd);
}
}
/// <summary>
/// supprimer un tag a une note
/// </summary>
public void SupOneTagToNoteList(Note note, Tags tagtosup)
{
if (TagList.Contains(tagtosup) == false) { throw new Exception("Tag not found"); }
if(NoteList.Contains(note) == false) { throw new Exception("Note not found"); }
else
{
NoteTaged[note].Remove(tagtosup);
}
}
/// <summary>
/// ajouter plusieur tag a une note
/// </summary>
public void AddTagToNoteList(Note note, List<Tags> listTags)
{
NoteTaged.Add(note, listTags);
}
/// <summary>
///supprimer tout les tags d'une note
/// </summary>
public void SupTagToNoteList(Note note)
{
NoteTaged.Remove(note);
}
}
}

@ -0,0 +1,18 @@
using Notus_Persistance;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_Console
{
public class Manager
{
PersistenceManager pers { get; set; }
public Manager(PersistenceManager pers)
{
this.pers = pers;
}
}
}

@ -9,6 +9,7 @@
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Biblioteque_de_Class\Biblioteque_de_Class.csproj" /> <ProjectReference Include="..\Biblioteque_de_Class\Biblioteque_de_Class.csproj" />
<ProjectReference Include="..\Notus_Persistence\Notus_Persistance.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -25,10 +25,10 @@ string linkimage = "u";
List <string> NewColorList; List <string> NewColorList;
List <string> listCouleurs; List <string> listCouleurs;
Utilisateur user = new Utilisateur(Upseudo, Umail, Upassword); User user = new User(Upseudo, Umail, Upassword);
NoteImage image = new NoteImage(nom2, linkimage, position); NoteImage image = new NoteImage(nom2, linkimage, position);
Database db= new Database(); Database db= new Database();
Utilisateur u = new Utilisateur(Upseudo, Umail, Upassword); User u = new User(Upseudo, Umail, Upassword);
Note n = new Note(nom, logoPath, u); Note n = new Note(nom, logoPath, u);
Tags t = new Tags(name, couleur); Tags t = new Tags(name, couleur);
@ -100,7 +100,7 @@ while (boucle == 0){
Umail = Console.ReadLine(); Umail = Console.ReadLine();
Console.WriteLine("Saisissez un mot de passe"); Console.WriteLine("Saisissez un mot de passe");
Upassword = Console.ReadLine(); Upassword = Console.ReadLine();
Utilisateur u1 = new Utilisateur(Upseudo, Umail, Upassword); User u1 = new User(Upseudo, Umail, Upassword);
db.AjouterUtilisateur(u1); db.AjouterUtilisateur(u1);
break; break;

@ -0,0 +1,14 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_Persistance
{
public class Manager : PersistenceManager
{
PersistenceManager pers { get; set; }
}
}

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Biblioteque_de_Class\Biblioteque_de_Class.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,33 @@
using Biblioteque_de_Class;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Xml;
using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Notus_Persistance
{
public static class PersistenceManager
{
public static void SaveDatabaseData(Database database)
{
ToJSON.SaveDatabaseData(database);
}
public static Database LoadDatabaseData()
{
return ToJSON.LoadDatabaseData();
}
public static void SaveUserData(User user)
{
ToJSON.SaveUserData(user);
}
public static User LoadUserData()
{
return ToJSON.LoadUserData();
}
}
}

@ -0,0 +1,34 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
namespace Notus_Persistance
{
public class Stub
{
public static void SaveDatabaseData(Database database)
{
}
public static Database LoadDatabaseData()
{
}
public static void SaveUserData(User user)
{
}
public static User LoadUserData()
{
}
}
}

@ -0,0 +1,99 @@
using Biblioteque_de_Class;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Text.Json;
namespace Notus_Persistance
{
public static class ToJSON
{
private const string DatabaseDataFilePath = "data.json";
private const string UserDataFilePath = "userdata.json";
private static DataContractJsonSerializer DatabasejsonSerializer = new DataContractJsonSerializer(typeof(Database));
private static DataContractJsonSerializer UserjsonSerializer = new DataContractJsonSerializer(typeof(User));
public static void SaveDatabaseData(Database database)
{
using (FileStream fileStream = File.Create(DatabaseDataFilePath))
{
using (var writer = JsonReaderWriterFactory.CreateJsonWriter(
fileStream,
System.Text.Encoding.UTF8,
false,
true))//<- this boolean says that we sant indentation
{
DatabasejsonSerializer.WriteObject(writer, database);
}
}
}
public static Database LoadDatabaseData()
{
if (File.Exists(DatabaseDataFilePath))
{
Database database1;
using (FileStream fileStream = File.OpenRead(DatabaseDataFilePath))
{
Database? database = (Database?)DatabasejsonSerializer.ReadObject(fileStream);
if (database == null)
{
throw new Exception("Failed to load database. The loaded object is null.");
}
else
{
return database1 = database;
}
}
}
else
{
throw new Exception("No data file found.");
}
}
public static void SaveUserData(User user)
{
using (FileStream fileStream = File.Create(UserDataFilePath))
{
using (var writer = JsonReaderWriterFactory.CreateJsonWriter(
fileStream,
System.Text.Encoding.UTF8,
false,
true))//<- this boolean says that we sant indentation
{
UserjsonSerializer.WriteObject(writer, user);
}
}
}
public static User LoadUserData()
{
if (File.Exists(UserDataFilePath))
{
User user1;
using (FileStream fileStream = File.OpenRead(UserDataFilePath))
{
User? user = (User?)UserjsonSerializer.ReadObject(fileStream);
if (user == null)
{
throw new Exception("Failed to load database. The loaded object is null.");
}
else
{
return user1 = user;
}
}
}
else
{
throw new Exception("No userfile find");
}
}
}
}

@ -0,0 +1,38 @@
using Biblioteque_de_Class;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Xml;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_Persistance
{
public static class ToXML
{
private const string DataFilePath = "data.xml";
private const string XmlDataFilePath = "userdata.xml";
public static void SaveDatabaseData(Database database)
{
}
public static Database LoadDatabaseData()
{
}
public static void SaveUserData(User user)
{
}
public static User LoadUserData()
{
}
}
}

@ -1,68 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8DCE500B-E01F-44CA-933E-DDE95111899B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Notus_UnitTest</RootNamespace>
<AssemblyName>Notus_UnitTest</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">15.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\MSTest.TestFramework.2.2.10\lib\net45\Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.props'))" />
<Error Condition="!Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets'))" />
</Target>
<Import Project="..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets" Condition="Exists('..\packages\MSTest.TestAdapter.2.2.10\build\net46\MSTest.TestAdapter.targets')" />
</Project>

@ -1,20 +0,0 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Notus_UnitTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("workgroup")]
[assembly: AssemblyProduct("Notus_UnitTest")]
[assembly: AssemblyCopyright("Copyright © workgroup 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("8dce500b-e01f-44ca-933e-dde95111899b")]
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

@ -1,14 +0,0 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Notus_UnitTest
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
}
}
}

@ -0,0 +1,96 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
namespace Notus_UnitTest
{
[TestFixture]
public class UserSearchTests
{
private UserSearch userSearch;
[SetUp]
public void Setup()
{
// Initialize the class under test
userSearch = new UserSearch();
}
[Test]
public void SearchUser_EmptyUserList_ReturnsEmptyList()
{
// Arrange
List<User> userList = new List<User>();
userSearch.SetUserList(userList);
string searchName = "John";
// Act
List<User> result = userSearch.SearchUser(searchName);
// Assert
Assert.IsEmpty(result);
}
[Test]
public void SearchUser_MatchingUsername_ReturnsMatchingUser()
{
// Arrange
List<User> userList = new List<User>()
{
new User("John"),
new User("Jane"),
new User("Robert")
};
userSearch.SetUserList(userList);
string searchName = "Jane";
// Act
List<User> result = userSearch.SearchUser(searchName);
// Assert
Assert.AreEqual(1, result.Count);
Assert.AreEqual("Jane", result[0].GetUsername());
}
[Test]
public void SearchUser_NoMatchingUsername_ReturnsEmptyList()
{
// Arrange
List<User> userList = new List<User>()
{
new User("John"),
new User("Jane"),
new User("Robert")
};
userSearch.SetUserList(userList);
string searchName = "Alice";
// Act
List<User> result = userSearch.SearchUser(searchName);
// Assert
Assert.IsEmpty(result);
}
[Test]
public void SearchUser_PartiallyMatchingUsername_ReturnsMatchingUsers()
{
// Arrange
List<User> userList = new List<User>()
{
new User("John Doe"),
new User("Jane Smith"),
new User("Robert Johnson")
};
userSearch.SetUserList(userList);
string searchName = "Jo";
// Act
List<User> result = userSearch.SearchUser(searchName);
// Assert
Assert.AreEqual(2, result.Count);
Assert.AreEqual("John Doe", result[0].GetUsername());
Assert.AreEqual("Robert Johnson", result[1].GetUsername());
}
}
}

@ -1,5 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="MSTest.TestAdapter" version="2.2.10" targetFramework="net472" />
<package id="MSTest.TestFramework" version="2.2.10" targetFramework="net472" />
</packages>

@ -0,0 +1,39 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
namespace Notus_UnitTest_Database
{
public class AddThemeTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
}
[Test]
public void AddTheme_NewTheme_ThemeAddedToList()
{
List<string> listcolor = new List<string>() { "Blue", "Dark", "Grey" };
Theme theme = new Theme("ocean", listcolor);
database.AddTheme(theme);
CollectionAssert.Contains(database.GetThemeList(), theme);
}
[Test]
public void AddTheme_ExistingTheme_ThrowsException()
{
List<string> listcolor = new();
Theme theme = new Theme("ocean", listcolor);
database.AddTheme(theme);
Assert.Throws<Exception>(() => database.AddTheme(theme), "Theme already used.");
}
}
}

@ -0,0 +1,51 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_UnitTest_Database
{
public class AddUserTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
}
[Test]
public void AddUser_ValidUser_UserAddedToList()
{
User user = new User("John", "rien", "choco") ;
user.SetEmail("john@example.com");
database.AddUser(user);
CollectionAssert.Contains(database.GetUserList(), user);
}
[Test]
public void AddUser_DuplicateUsername_ThrowsException()
{
User existingUser = new User("John1", "rien", "choco");
existingUser.SetEmail("john1@example.com");
database.GetUserList().Add(existingUser);
User newUser = new User("John1", "rien", "choco");
newUser.SetEmail("Jane@example.com");
Assert.Throws<Exception>(() => database.AddUser(newUser), "Username already used.");
}
[Test]
public void AddUser_DuplicateEmail_ThrowsException()
{
User existingUser = new User("John2", "rien", "choco");
existingUser.SetEmail("john2@example.com");
database.GetUserList().Add(existingUser);
User newUser = new User("Jane", "rien", "choco");
newUser.SetEmail("john2@example.com");
Assert.Throws<Exception>(() => database.AddUser(newUser), "Email already used.");
}
}
}

@ -0,0 +1,42 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_UnitTest_Database
{
[TestFixture]
public class ComparePasswordTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
User user = new User("John","rien","choco");
user.SetPassword("password123");
database.GetUserList().Add(user);
}
[Test]
public void ComparePassword_CorrectPassword_ReturnsTrue()
{
User user = database.GetUserList()[0];
string password = "password123";
bool result = database.ComparePassword(user, password);
Assert.IsTrue(result);
}
[Test]
public void ComparePassword_IncorrectPassword_ReturnsFalse()
{
User user = database.GetUserList()[0];
string password = "incorrectPassword";
bool result = database.ComparePassword(user, password);
Assert.IsFalse(result);
}
}
}

@ -0,0 +1,39 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_UnitTest_Database
{
public class FindMailTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
User user = new User("John");
user.SetEmail("john@example.com");
database.GetUserList().Add(user);
}
[Test]
public void FindEmail_ExistingEmail_ReturnsTrue()
{
string email = "john@example.com";
bool result = database.FindEmail(email);
Assert.IsTrue(result);
}
[Test]
public void FindEmail_NonExistingEmail_ReturnsFalse()
{
string email = "jane@example.com";
bool result = database.FindEmail(email);
Assert.IsFalse(result);
}
}
}

@ -0,0 +1,34 @@
using Biblioteque_de_Class;
namespace Notus_UnitTest_Database
{
[TestFixture]
public class GetLogoLinksTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
database.GetDefaultLogoList().Add(new Logo("Logo1", "link1"));
database.GetDefaultLogoList().Add(new Logo("Logo2", "link2"));
database.GetDefaultLogoList().Add(new Logo("Logo3", "link3"));
}
[Test]
public void GetLogoLink_LogoExists_ReturnsLogoLink()
{
string logoName = "Logo2";
string logoLink = database.GetLogoLink(logoName);
Assert.That(logoLink, Is.EqualTo("link2"));
}
[Test]
public void GetLogoLink_LogoDoesNotExist_ThrowsException()
{
string logoName = "Logo4";
Assert.Throws<Exception>(() => database.GetLogoLink(logoName));
}
}
}

@ -0,0 +1,36 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_UnitTest_Database
{
public class GetThemeTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
}
[Test]
public void GetTheme_ExistingTheme_ReturnsTheme()
{
List<string> listcolor = new List<string>() { "Blue", "Dark", "Grey" };
Theme theme = new Theme("ocean", listcolor);
database.GetThemeList().Add(theme);
Theme retrievedTheme = database.GetTheme("Dark");
Assert.That(retrievedTheme, Is.EqualTo(theme));
}
[Test]
public void GetTheme_NonExistingTheme_ThrowsException()
{
Assert.Throws<Exception>(() => database.GetTheme("NonExistingTheme"), "No theme found with this name.");
}
}
}

@ -0,0 +1,36 @@
using Biblioteque_de_Class;
namespace Notus_UnitTest_Database
{
[TestFixture]
public class GetUserTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
database.GetUserList().Add(new User("John","rien","choco"));
database.GetUserList().Add(new User("Alice", "rien", "choco"));
database.GetUserList().Add(new User("Bob", "rien", "choco"));
}
[Test]
public void GetUser_UserExists_ReturnsUser()
{
string userName = "Alice";
User user = database.GetUser(userName);
Assert.IsNotNull(user);
Assert.That(user.GetUsername(), Is.EqualTo(userName));
}
[Test]
public void GetUser_UserDoesNotExist_ThrowsException()
{
string userName = "Eve";
Assert.Throws<Exception>(() => database.GetUser(userName));
}
}
}

@ -0,0 +1,43 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_UnitTest_Database
{
public class ModifyThemeColorListTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
}
[Test]
public void ModifyThemeColorList_ExistingTheme_ModifiesColors()
{
List<string> listcolor = new List<string>() { "Blue", "Dark", "Grey" };
Theme theme = new Theme("ocean", listcolor);
database.GetThemeList().Add(theme);
List<string> newColorList = new List<string> { "Red", "Green", "Blue" };
database.ModifyThemeColorList(theme, newColorList);
Assert.That(theme.GetColor(0), Is.EqualTo(newColorList[0]));
Assert.That(theme.GetColor(1), Is.EqualTo(newColorList[1]));
Assert.That(theme.GetColor(2), Is.EqualTo(newColorList[2]));
}
[Test]
public void ModifyThemeColorList_NonExistingTheme_ThrowsException()
{
List<string> listcolor = new List<string>() { "Blue", "Dark", "Grey" };
Theme theme = new Theme("ocean", listcolor);
// no add :)
List<string> newColorList = new List<string> { "Red", "Green", "Blue" };
Assert.Throws<Exception>(() => database.ModifyThemeColorList(theme, newColorList), "Theme not found.");
}
}
}

@ -0,0 +1,36 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_UnitTest_Database
{
public class ModifyThemeNameTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
}
[Test]
public void GetTheme_ExistingTheme_ReturnsTheme()
{
List<string> listcolor = new List<string>() { "Blue", "Dark", "Grey" };
Theme theme = new Theme("ocean", listcolor);
database.GetThemeList().Add(theme);
Theme retrievedTheme = database.GetTheme("Dark");
Assert.That(retrievedTheme, Is.EqualTo(theme));
}
[Test]
public void GetTheme_NonExistingTheme_ThrowsException()
{
Assert.Throws<Exception>(() => database.GetTheme("NonExistingTheme"), "No theme found with this name.");
}
}
}

@ -0,0 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="3.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Biblioteque_de_Class\Biblioteque_de_Class.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,38 @@
using Biblioteque_de_Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Notus_UnitTest_Database
{
public class RemoveUserTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
}
[Test]
public void RemoveUser_ExistingUser_UserRemovedFromList()
{
User user = new User("John","rien","choco");
user.SetEmail("john@example.com");
database.GetUserList().Add(user);
database.RemoveUser(user);
CollectionAssert.DoesNotContain(database.GetUserList(), user);
}
[Test]
public void RemoveUser_NonExistingUser_ThrowsException()
{
User user = new User("John", "rien", "choco");
user.SetEmail("john@example.com");
Assert.Throws<Exception>(() => database.RemoveUser(user), "User not found.");
}
}
}

@ -0,0 +1,54 @@
using Biblioteque_de_Class;
namespace Notus_UnitTest_Database
{
[TestFixture]
public class SearchUserTests
{
private Database database;
[SetUp]
public void Setup()
{
database = new Database();
database.GetUserList().Add(new User("John", "john@example.com", "choco"));
database.GetUserList().Add(new User("Jane", "jane@example.com", "choco"));
database.GetUserList().Add(new User("Alice", "alice@example.com", "choco"));
}
[Test]
public void SearchUser_UserExists_ReturnsMatchingUsers()
{
string searchName = "Jo";
List<User> searchedUsers = database.SearchUser(searchName);
Assert.That(searchedUsers.Count, Is.EqualTo(1));
Assert.That(searchedUsers[0].GetUsername(), Is.EqualTo("John"));
}
[Test]
public void SearchUser_UserDoesNotExist_ReturnsEmptyList()
{
string searchName = "Bob";
List<User> searchedUsers = database.SearchUser(searchName);
Assert.IsEmpty(searchedUsers);
}
[Test]
public void SearchUser_CaseInsensitiveSearch_ReturnsMatchingUsers()
{
string searchName = "ALICE";
List<User> searchedUsers = database.SearchUser(searchName);
Assert.That(searchedUsers.Count, Is.EqualTo(1));
Assert.That(searchedUsers[0].GetUsername(), Is.EqualTo("Alice"));
}
[Test]
public void SearchUser_PartialMatch_ReturnsMatchingUsers()
{
string searchName = "ane";
List<User> searchedUsers = database.SearchUser(searchName);
Assert.That(searchedUsers.Count, Is.EqualTo(1));
Assert.That(searchedUsers[0].GetUsername(), Is.EqualTo("Jane"));
}
}
}

@ -0,0 +1 @@
global using NUnit.Framework;

@ -3,11 +3,15 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.0.31611.283 VisualStudioVersion = 17.0.31611.283
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "notus_vue", "notus_vue\notus_vue.csproj", "{561264A1-4611-40FB-A662-3EF65550CA71}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Notus_Vue", "notus_vue\Notus_Vue.csproj", "{561264A1-4611-40FB-A662-3EF65550CA71}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Biblioteque_de_Class", "Biblioteque_de_Class\Biblioteque_de_Class.csproj", "{92DD50C5-EEAD-44ED-AEFF-E21935725477}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Biblioteque_de_Class", "Biblioteque_de_Class\Biblioteque_de_Class.csproj", "{92DD50C5-EEAD-44ED-AEFF-E21935725477}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notus_Console", "Notus_Console\Notus_Console.csproj", "{0A5E5F33-6B39-42BF-A46D-0752EDB666FB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Notus_Console", "Notus_Console\Notus_Console.csproj", "{0A5E5F33-6B39-42BF-A46D-0752EDB666FB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Notus_Persistance", "Notus_Persistence\Notus_Persistance.csproj", "{184478A9-E14F-42E0-B963-B3A4474C9C1C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Notus_UnitTest_Database", "Tests\Notus_UnitTest_Database\Notus_UnitTest_Database.csproj", "{EE443C17-B31D-4AD0-9141-920876E7DF79}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -29,6 +33,14 @@ Global
{0A5E5F33-6B39-42BF-A46D-0752EDB666FB}.Debug|Any CPU.Build.0 = Debug|Any CPU {0A5E5F33-6B39-42BF-A46D-0752EDB666FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A5E5F33-6B39-42BF-A46D-0752EDB666FB}.Release|Any CPU.ActiveCfg = Release|Any CPU {0A5E5F33-6B39-42BF-A46D-0752EDB666FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A5E5F33-6B39-42BF-A46D-0752EDB666FB}.Release|Any CPU.Build.0 = Release|Any CPU {0A5E5F33-6B39-42BF-A46D-0752EDB666FB}.Release|Any CPU.Build.0 = Release|Any CPU
{184478A9-E14F-42E0-B963-B3A4474C9C1C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{184478A9-E14F-42E0-B963-B3A4474C9C1C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{184478A9-E14F-42E0-B963-B3A4474C9C1C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{184478A9-E14F-42E0-B963-B3A4474C9C1C}.Release|Any CPU.Build.0 = Release|Any CPU
{EE443C17-B31D-4AD0-9141-920876E7DF79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EE443C17-B31D-4AD0-9141-920876E7DF79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EE443C17-B31D-4AD0-9141-920876E7DF79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EE443C17-B31D-4AD0-9141-920876E7DF79}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -6,7 +6,7 @@
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET --> <!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> --> <!-- <TargetFrameworks>$(TargetFrameworks);net7.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<RootNamespace>notus</RootNamespace> <RootNamespace>Notus_Vue</RootNamespace>
<UseMaui>true</UseMaui> <UseMaui>true</UseMaui>
<SingleProject>true</SingleProject> <SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>

Loading…
Cancel
Save