setup to start upgrade persistance and adding correct stub
continuous-integration/drone/push Build is failing Details

pull/19/head
Matheo THIERRY 2 years ago
commit 9a79b6a8b2

@ -6,6 +6,7 @@ trigger:
branch:
- developpement
- master
- refonte_program
event:
- push

@ -37,14 +37,14 @@ namespace Biblioteque_de_Class
{
List<User> searchedUsers = new List<User>();
string search = name.ToLower();
searchedUsers.AddRange(UserList.Where(user => user.GetUsername().ToLower().Contains(search)));
searchedUsers.AddRange(UserList.Where( user => user.GetUsername().ToLower().Contains(search)));
return searchedUsers;
}
/// <summary>
/// récupérer le lien d'un logo
/// </summary>
public string GetLogoLink(string name)
public string? GetLogoLink(string name)
{
foreach (Logo logo in DefaultLogoList)
{
@ -71,7 +71,7 @@ namespace Biblioteque_de_Class
/// <summary>
/// comparer le mot de passe entré avec celui de l'utilisateur
/// </summary>
public static bool ComparePassword(User user, string password) => user.GetPassword() == password;
public static bool ComparePassword(User user, string? password) => user.GetPassword() == password;
/// <summary>
/// rechercher un mail dans la liste d'utilisateur
@ -142,8 +142,12 @@ namespace Biblioteque_de_Class
/// </summary>
public void RemoveTheme(Theme theme)
{
if (ThemeList.Contains(theme))
if (ThemeList.Contains(theme))
{
if (theme.GetName().Length > 6 && theme.GetName()[..6] != "Static" )
{
throw new AlreadyUsedException("This theme is used a default theme.");
}
ThemeList.Remove(theme);
}
else
@ -199,7 +203,6 @@ namespace Biblioteque_de_Class
return;
}
}
throw new NotFoundException("Theme not found.");
}
}
}

@ -11,30 +11,5 @@ namespace Biblioteque_de_Class
public void SaveDatabaseData(Database database);
public Database LoadDatabaseData();
public void SaveUserData(User user);
public List<User> LoadUserData();
public List<Note> LoadNote();
public void SaveNote(Note note);
public List<Theme> LoadTheme();
public void SaveTheme(Theme theme);
public List<Logo> LoadLogo();
public void SaveLogo(Logo logo);
public List<Tags> LoadTags();
public void SaveTags(Tags tag);
public List<NoteImage> LoadNoteImage();
public void SaveNoteImage(NoteImage noteImage);
}
}

@ -15,7 +15,8 @@ namespace Biblioteque_de_Class
private set { if (value == null) { name = "Unnamed Note"; } else { name = value; } }
}
///private string Text { get; set; } Attribut pour le texte de la note <summary>
private string Text { get; set; } = "";
private string logoPath;
public string LogoPath
{
@ -26,7 +27,6 @@ namespace Biblioteque_de_Class
private DateOnly CreationDate { get; }
private DateOnly ModificationDate { get; set; }
private readonly List<NoteImage> ImageList;
private string TextLine;
private readonly List<User> Collaborators;
private readonly List<User> Editors;
private readonly User Owner;
@ -45,10 +45,10 @@ namespace Biblioteque_de_Class
public string GetName() { return Name; }
public string GetLogoPath() { return LogoPath; }
public string GetText() { return Text; }
public DateOnly GetCreationDate() { return CreationDate; }
public DateOnly GetModificationDate() { return ModificationDate; }
public List<NoteImage> GetImageList() { return ImageList; }
public string GetTextLine() { return TextLine; }
public List<User> GetCollaborators() { return Collaborators; }
public List<User> GetEditors() { return Editors; }
public User GetOwner() { return Owner; }
@ -58,7 +58,6 @@ namespace Biblioteque_de_Class
public void SetName(string name) { Name = name; }
public void SetLogoPath(string logoPath) { LogoPath = logoPath; }
public void SetModificationDate() { ModificationDate = DateOnly.FromDateTime(DateTime.Now); }
public void SetTextLine(string texte) { TextLine = texte; }
/// <summary>
/// vérifier si l'utilisateur est le propriétaire de la note
@ -87,6 +86,11 @@ namespace Biblioteque_de_Class
throw new NotFoundException("Image not found");
}
public void AddText(string text)
{
Text = Text + "\n" + text;
}
/// <summary>
/// vérifier si l'utilisateur est un éditeur de la note
/// </summary>

@ -1,259 +1,271 @@
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;
}
public List<Note> SearchNoteByDate(List<Note> ToResearchIntoList, string name, DateOnly FirstDate, DateOnly SecondeDate)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in ToResearchIntoList)
{
if (note.GetName().ToLower().Contains(search) && note.GetCreationDate() >= FirstDate && note.GetCreationDate() <= SecondeDate)
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
/// <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 AlreadyExistException("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 NotFoundException("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 AlreadyExistException("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 NotFoundException("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 AlreadyExistException("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 NotFoundException("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new NotFoundException("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 NotFoundException("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new NotFoundException("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);
}
}
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; }
private Theme Theme;
[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 Theme GetTheme() { return Theme; }
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 List<Tags> GetNoteTaggedList(Note note) { return NoteTagged[note]; }
public void SetUsername(string username) { Username = username; }
public void SetEmail(string email) { Email = email; }
public void SetPassword(string password) { Password = password; }
public void SetTheme(Theme theme) { Theme = theme; }
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 et la liste de note favoris de l'utilisateur
/// </summary>
public List<Note> SearchNoteByName(List<Note> ToResearchIntoList, string name)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in ToResearchIntoList)
{
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(List<Tags> ToResearchIntoList, string name)
{
List<Tags> searchedTags = new List<Tags>();
string search = name.ToLower();
foreach (Tags tag in ToResearchIntoList)
{
if (tag.GetName().ToLower().Contains(search))
{
searchedTags.Add(tag);
}
}
return searchedTags;
}
public List<Note> SearchNoteByDate(List<Note> ToResearchIntoList, string name, DateOnly FirstDate, DateOnly SecondeDate)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in ToResearchIntoList)
{
if (note.GetName().ToLower().Contains(search) && note.GetCreationDate() >= FirstDate && note.GetCreationDate() <= SecondeDate || note.GetModificationDate() >= FirstDate && note.GetModificationDate() <= SecondeDate)
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
public Note GetNoteByName(string name)
{
foreach (Note note in NoteList)
{
if (note.GetName() == name)
{
return note;
}
}
throw new NotFoundException("Note not found");
}
public Tags GetTagByName(string name)
{
foreach (Tags tag in TagList)
{
if (tag.GetName() == name)
{
return tag;
}
}
throw new NotFoundException("Tag not found");
}
/// <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 AlreadyExistException("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 NotFoundException("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 AlreadyExistException("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(string note)
{
foreach (Note existingNote in NoteList)
{
if (existingNote.GetName() == note)
{
NoteList.Remove(existingNote);
NoteTagged.Remove(existingNote);
return;
}
}
throw new NotFoundException("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 AlreadyExistException("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 NotFoundException("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new NotFoundException("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 NotFoundException("Tag not found");
}
if (!NoteList.Contains(note))
{
throw new NotFoundException("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,361 +1,648 @@
using Biblioteque_de_Class;
using System.ComponentModel.DataAnnotations.Schema;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Runtime.InteropServices;
using Notus_Persistance;
using System.Collections;
using System.Security.Cryptography;
using System.Text;
// load database
PersistenceManager manager = new(new Stub());
Database db = manager.LoadDatabaseData();
foreach(User user in db.GetUserList())
{
user.SetPassword(GetSHA256Hash(user.GetPassword()));
}
string Upseudo = "u";
string Umail = "u";
string Upassword = "u";
int nomImage = 1;
string linkimage = "u";
string position = "u";
string nomNote = "u";
string logoPath = "u";
string NomTag = "u";
string nom = "u";
string choixNom;
string choixCouleur;
string choixModif;
int image_;
string choix;
string color = "u";
string color2;
string color3;
// initialization zone==============================================================================
bool continuerboucle = false;
bool menu = true, connection = false, inscription = false;
bool note=false, tags=false, para=false, paraCompte=false, theme=false;
User user = new User(Upseudo, Umail, Upassword);
NoteImage image = new NoteImage(nomImage, linkimage, position);
Database db = new Database();
User u = new User(Upseudo, Umail, Upassword);
Note n = new Note(nomNote, logoPath, u);
Tags t = new Tags(NomTag, color);
PersistenceManager managerPers = new PersistenceManager(new Stub());
// déclaration d'un user qui sera utiliser pour servir de personne connecté dans l'app
User u = new("", "", "");
User uvide = new("", "", "");
uvide.SetIsConnected(false);
List<string> NewColorList = new List<string> { };
List<string> listCouleurs = new List<string> { };
List<Note> _searchedNotes;
List<Note> NoteListe = managerPers.LoadNote();
List<Tags> _searchedTags;
List<User> UserListe = managerPers.LoadUserData();
// déclaration d'une note qui sera utiliser pour servir de note selectionnée
Note n = new("","",uvide);
List<Note> researchlist = new();
// factorisation
bool continuer()
>>>>>>> refonte_program
{
continuerboucle = false;
while(!continuerboucle)
{
Console.WriteLine("\nContinuer ? (O/n)");
switch (Console.ReadLine())
{
case "O":
return true;
case null:
return true;
case "o":
return true;
case "n":
return false;
default:
Console.WriteLine("\nEntrez un choix valide.\n");
continuerboucle = true;
break;
}
}
return false;
}
/*foreach (Note no in NoteListe) /// Test du stub
bool choix_note()
{
Console.WriteLine(no.GetName());
Console.WriteLine("\nChoisissez le nom de la note");
string? wantedModifyNote = Console.ReadLine();
wantedModifyNote??= "";
try
{
n = u.GetNoteByName(wantedModifyNote);
}catch (Exception ex) { Console.WriteLine(ex.Message); return false; }
return true;
}
void displayNote()
{
foreach (Note note in u.GetNoteList())
{
Console.WriteLine(note.GetName() + "\n");
}
}
void displayTag()
{
foreach (Tags tag in u.GetTagList())
{
Console.WriteLine(tag.GetName() + "\n");
}
}
return;*/
int boucle = 0;
while (boucle == 0)
void displayTheme()
{
Console.WriteLine("|--------------------------------------|");
foreach (Theme theme in db.GetThemeList())
{
Console.WriteLine(theme.GetName() + "\n");
}
}
List<string>? choix_couleur()
{
List<string> colorList = new();
Console.WriteLine("Fond : ");
string? wantedNewThemeFond = Console.ReadLine();
if(wantedNewThemeFond == null){ return null; }
else if(wantedNewThemeFond[0].ToString() != "#"){
Console.WriteLine("\nLa couleur doit être au format hexadécimal.\n");
return null;
}else if(wantedNewThemeFond.Length != 7)
{
string toadd="";
for(int i = 7- wantedNewThemeFond.Length; i!=0; i--){toadd += "0";}
wantedNewThemeFond += toadd;
return null;
}
Console.WriteLine("Texte : ");
string? wantedNewThemeTexte = Console.ReadLine();
if(wantedNewThemeTexte == null){ return null; }
else if(wantedNewThemeTexte[0].ToString() != "#"){
Console.WriteLine("\nLa couleur doit être au format hexadécimal.\n");
return null;
}else if(wantedNewThemeTexte.Length != 7)
{
string toadd="";
for(int i = 7- wantedNewThemeTexte.Length; i!=0; i--){toadd += "0";}
wantedNewThemeTexte += toadd;
return null;
}
Console.WriteLine("Bouton : ");
string? wantedNewThemeBouton = Console.ReadLine();
if(wantedNewThemeBouton == null){ return null; }
else if(wantedNewThemeBouton[0].ToString() != "#"){
Console.WriteLine("\nLa couleur doit être au format hexadécimal.\n");
return null;
}else if(wantedNewThemeBouton.Length != 7)
{
string toadd="";
for(int i = 7- wantedNewThemeBouton.Length; i!=0; i--){toadd += "0";}
wantedNewThemeBouton += toadd;
return null;
}
colorList.Add(wantedNewThemeFond);
colorList.Add(wantedNewThemeTexte);
colorList.Add(wantedNewThemeBouton);
return colorList;
}
static string GetSHA256Hash(string input)
{
using (SHA256 sha256Hash = SHA256.Create())
{
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
StringBuilder builder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
builder.Append(bytes[i].ToString("x2"));
}
return builder.ToString();
}
}
while (menu)
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
Console.WriteLine("| Menu pour lister les fonctionnalités |");
Console.WriteLine("| starting menu |");
Console.WriteLine("| |");
Console.WriteLine("|--------------------------------------|--------|");
Console.WriteLine("| |");
Console.WriteLine("| 1/se connecter |");
Console.WriteLine("| 2/se déconnecter |");
Console.WriteLine("| 3/créer un compte |");
Console.WriteLine("| 4/supprimer un compte |");
Console.WriteLine("| 5/créer note |");
Console.WriteLine("| 6/supprimer note |");
Console.WriteLine("| 7/créer tag |");
Console.WriteLine("| 8/ajouter tag |");
Console.WriteLine("| 9/supprimer tag |");
Console.WriteLine("| 10/ajouter image |");
Console.WriteLine("| 11/supprimer image |");
Console.WriteLine("| 12/déplacer image |");
Console.WriteLine("| 13/supprimer tag definitif |");
Console.WriteLine("| 14/Ajouter favori |");
Console.WriteLine("| 15/Supprimer favori |");
Console.WriteLine("| 16/créer un thème |");
Console.WriteLine("| 17/supprimer un thème |");
Console.WriteLine("| 18/modifier un thème |");
Console.WriteLine("| 19/rechercher une note |");
Console.WriteLine("| 20/rechercher une note avec tags |");
Console.WriteLine("| 21/rechercher une note avec date |");
Console.WriteLine("| 22/modifier tags |");
Console.WriteLine("| 23/modifier compte |");
Console.WriteLine("| 24/modifier note |");
Console.WriteLine("| 25/partage note |");
Console.WriteLine("| 26/modifier role (si proprietaire) |");
Console.WriteLine("| 27/supprimer cooperateur |");
Console.WriteLine("| 1 / - connection - |");
Console.WriteLine("| 2 / - inscription - |");
Console.WriteLine("| |");
Console.WriteLine("|-----------------------------------------------|");
Console.WriteLine("|-----------------------------------------------|\n");
Console.WriteLine("rentrez votre choix.");
switch (Console.ReadLine())
{
case "1": ///Connexion
Console.WriteLine("Entrez votre nom.");
nom = Console.ReadLine();
connection = true; break;
case "2":///Creer un compte
inscription = true; break;
default:
Console.WriteLine("\nEntrez un choix valide.\n");
break;
}
//connection
while (connection)
{
connection = false;
Console.WriteLine("\nEntrez un nom : ");
string? nom = Console.ReadLine();
if (nom == null) { continue; }
Console.WriteLine("\nEntrez un password :");
string? password = Console.ReadLine();
if (password == null) { continue; }
password = GetSHA256Hash(password);
try
{
u = db.GetUser(nom);
Umail = u.GetEmail();
Upassword = u.GetPassword();
db.FindEmail(Umail);
Database.ComparePassword(u,Upassword);
UserListe = db.GetUserList();
if (UserListe.Contains(u))
}
catch (AlreadyUsedException ex)
{
Console.WriteLine(ex.Message);
connection = true;
}
if (!connection)
{
if (Database.ComparePassword(u, password))
{
u.SetIsConnected(true);
Console.WriteLine("Connecté");
break;
Console.WriteLine("\nConnection réussie !\n");
menu = false;
}
else
{
Console.WriteLine("Utilisateur non trouvé.");
break;
Console.WriteLine("\nWrong PassWord !\n");
connection = true;
continuerboucle = true;
u = uvide;
}
}
while (continuerboucle) { connection = continuer(); }
}
case "2":///Deconnexion
u.SetIsConnected(false);
Console.WriteLine("Vous vous êtes déconnecté avec succès.");
break;
case "3":///Creer un compte
Console.WriteLine("Choisissez un pseudo");
Upseudo = Console.ReadLine();
Console.WriteLine("Entrez votre adresse mail");
Umail = Console.ReadLine();
Console.WriteLine("Saisissez un mot de passe");
Upassword = Console.ReadLine();
User u1 = new User(Upseudo, Umail, Upassword);
db.AddUser(u1);
break;
case "4":///Supprimer Compte
Console.WriteLine("Chercher utilisateur");
nom = Console.ReadLine();
//inscription
while (inscription)
{
Console.WriteLine("\nEntrez un nom :");
string? nom = Console.ReadLine();
if (nom == null) { continue; }
Console.WriteLine("\nEntrez un password :");
string? password = Console.ReadLine();
if (password == null) { continue; }
try
{
u = db.GetUser(nom);
Umail = u.GetEmail();
db.FindEmail(Umail);
Upassword = u.GetPassword();
Database.ComparePassword(u,Upassword);
UserListe = db.GetUserList();
if (UserListe.Contains(u))
{
db.RemoveUser(u);
Console.WriteLine("Compte supprimé avec succès.");
break;
}
Console.WriteLine("Utilisateur non trouvé.");
break;
case "5":///Creer une note
Console.WriteLine("Choisissez un nom");
nom = Console.ReadLine();
Console.WriteLine("Choisissez un logo");
logoPath = Console.ReadLine();
n = new Note(nom, logoPath, u);
u.CreateNote(nom, logoPath);
break;
case "6":///Supprimer une note
u.DeleteNote(n);
break;
case "7":///Creer un tag
Console.WriteLine("Choisissez un nom");
choixNom = Console.ReadLine();
Console.WriteLine("Choisissez une couleur");
choixCouleur = Console.ReadLine();
u.CreateTag(choixNom, choixCouleur);
}
catch (AlreadyUsedException)
{
password = GetSHA256Hash(password);
u = new User(nom, "", password);
db.AddUser(u);
db.GetUser(nom).SetIsConnected(true);
Console.WriteLine("\nConnection réussie !\n");
menu = false;
break;
}
Console.WriteLine("\nNom d'utilisateur déjà utilisé. \n");
while (continuerboucle) { inscription = continuer(); }
case "8":///Ajouter un tag a une note
Console.WriteLine("Cherchez une note");
nom = Console.ReadLine();
_searchedNotes = u.SearchNoteByName(nom);
Console.WriteLine("Cherchez un tag");
nom = Console.ReadLine();
Tags tagToAdd = new Tags(nom, color);
u.AddTagToNoteList(n, tagToAdd);
break;
case "9":///Supprimer un tag a une note
Console.WriteLine("Cherchez une note");
nom = Console.ReadLine();
_searchedNotes = u.SearchNoteByName(nom);
Console.WriteLine("Cherchez un tag");
nom = Console.ReadLine();
_searchedTags = u.SearchTagByName(nom); ///A voir pour faire correctement
Tags tagToSupp = new Tags(nom, color);
tagToSupp = _searchedTags[1];
u.RemoveTagFromNoteList(n, tagToSupp);
break;
case "10":///Ajouter une image
n.AddImage(linkimage, position);
break;
case "11":///Supprimer une image
Console.WriteLine("Saisir numero de la note");
image_ = Convert.ToInt32(Console.ReadLine());
n.RemoveImage(image_);
break;
case "12":///Deplacer une image
image.SetPosition(position);
break;
case "13":///Supprimer un tag definitivement
_searchedTags = u.SearchTagByName(nom);
u.RemoveTagFromNoteList(n, t);
break;
case "14":///AJouter une note en favori
u.AddFavorite(n);
break;
case "15":///Supprimer une note des favoris
u.RemoveFavorite(n);
break;
case "16":///Creer un theme
Console.WriteLine("Choisissez un nom pour votre theme");
nom = Console.ReadLine();
Console.WriteLine("Choisissez trois couleurs");
color = Console.ReadLine();
color2 = Console.ReadLine();
color3 = Console.ReadLine();
listCouleurs.Add(color);
listCouleurs.Add(color2);
listCouleurs.Add(color3);
Theme th = new Theme(nom, listCouleurs);
db.AddTheme(th);
listCouleurs.RemoveAt(1);
listCouleurs.RemoveAt(1);
listCouleurs.RemoveAt(1);
break;
case "17":///Supprimer un theme
th = db.GetTheme(nom);
db.RemoveTheme(th);
break;
case "18":///Modifier un theme
Console.WriteLine("Cherchez un theme a modifier");
nom = Console.ReadLine();
th = db.GetTheme(nom);
db.ModifyThemeName(th,nom);
Console.WriteLine("Choisissez trois couleurs");
color = Console.ReadLine();
color2 = Console.ReadLine();
color3 = Console.ReadLine();
NewColorList.Add(color);
NewColorList.Add(color2);
NewColorList.Add(color3);
db.ModifyThemeColorList(th, NewColorList);
NewColorList.RemoveAt(1);
NewColorList.RemoveAt(1);
NewColorList.RemoveAt(1);
}
}
//une fois connecté ou inscription fait
while (u.GetIsConnected())
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
Console.WriteLine("| menu |");
Console.WriteLine("| |");
Console.WriteLine("|--------------------------------------|--------|");
Console.WriteLine("| |");
Console.WriteLine("| 1/ - rechercher note - |");
Console.WriteLine("| 2/ - note - |");
Console.WriteLine("| 3/ - tags - |");
Console.WriteLine("| 4/ - paramêtres - |");
Console.WriteLine("| 5/ - se déconnecter - |");
Console.WriteLine("| |");
Console.WriteLine("|-----------------------------------------------|\n");
Console.WriteLine("rentrez votre choix.");
switch (Console.ReadLine())
{
case "1":
researchlist = u.GetNoteList();
Console.WriteLine("\nEntrez la note que vous cherchez. ");
string? wantedSearchNote = Console.ReadLine();
Console.WriteLine("\nChercher par tags ? (o/N) ");
Console.WriteLine("\nChercher par date ? (o/N) ");
break;
case "19":///Rechercher une note
Console.WriteLine("Cherchez une note");
nom = Console.ReadLine();
NoteListe = u.GetNoteList();
u.SearchNoteByName(nom);
case "2":
note = true;
break;
case "20":///Recherche note par tag
///u.;
case "3":
tags = true;
break;
case "21":///Recherche note par dateCreation
///u.;
case "4":
para = true;
break;
case "22":///Modifier un tag
Console.WriteLine("Cherchez un tag");
nom = Console.ReadLine();
Console.WriteLine("Choisisez une couleur");
color = Console.ReadLine();
t.SetName(nom);
t.SetColor(color);
case "5":
Console.WriteLine("\ndéconnecté! \n");
u.SetIsConnected(false);
u = uvide;
break;
case "23":///Modifier le compte
Console.WriteLine("Modifier pseudo ? Mot de passe ? Mail ? (0/1/2)");
choixModif = Console.ReadLine();
if (choixModif.Equals('0'))
{
Console.WriteLine("Entrez votre nouveau pseudo");
Upseudo = Console.ReadLine();
u.SetUsername(Upseudo);
}
if (choixModif.Equals('1'))
{
Console.WriteLine("Entrez votre nouveau mot de passe");
Upassword = Console.ReadLine();
u.SetPassword(Upassword);
}
if (choixModif.Equals('2'))
{
Console.WriteLine("Entrez votre nouvelle adresse mail");
Umail = Console.ReadLine();
u.SetEmail(Umail);
}
default:
Console.WriteLine("\nEntrez un choix valide.\n");
break;
}
case "24":///Modifier le texte de la note
n.VerifyPrivilege(u);
if (true)
{
string texte = Console.ReadLine();
n.SetTextLine(texte);
}
else
{
Console.WriteLine("Vous ne possedez pas les droits pour effectuer cette action.");
}
break;
while(note)
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
Console.WriteLine("| menu - note |");
Console.WriteLine("| |");
Console.WriteLine("|--------------------------------------|--------|");
Console.WriteLine("| |");
Console.WriteLine("| 1/ - afficher la liste des notes - |");
Console.WriteLine("| 2/ - afficher une note - |");
Console.WriteLine("| 3/ - modifier une note - |");
Console.WriteLine("| 4/ - écrire dans une note - |");
Console.WriteLine("| 5/ - créer note - |");
Console.WriteLine("| 6/ - supprimer note - |");
Console.WriteLine("| 7/ - retour - |");
Console.WriteLine("| |");
Console.WriteLine("|-----------------------------------------------|\n");
Console.WriteLine("note actuelle : " + n.GetName());
Console.WriteLine("rentrez votre choix.");
switch (Console.ReadLine())
{
case "1":
displayNote();
break;
case "2":
if (!choix_note()) { break; }
Console.WriteLine("\n" + n.GetName() + " :");
Console.WriteLine(n.GetText());
break;
case "3":
if (!choix_note()) { break;}
Console.WriteLine("\nChoisissez le nouveau nom de la note (entrer - nom par defaut)");
string? wantedNewNameNote = Console.ReadLine();
wantedNewNameNote??= "";
n.SetName(wantedNewNameNote);
break;
case "4":
if (!choix_note()) { break; }
Console.WriteLine(n.GetText());
Console.WriteLine("\nEntrez le texte à ajouter");
string? wantedTextNote = Console.ReadLine();
wantedTextNote??= "";
n.AddText(wantedTextNote);
break;
case "5":
Console.WriteLine("\nChoisissez le nom de la note (entrer - nom par defaut)");
string? wantedNameNote = Console.ReadLine();
wantedNameNote ??= "";
u.CreateNote(wantedNameNote, "");
break;
case "6":
Console.WriteLine("\nChoisissez le nom de la note");
string? wantedDeleteNote = Console.ReadLine();
wantedDeleteNote ??= "";
try
{
u.DeleteNote(wantedDeleteNote);
}
catch (Exception ex) { Console.WriteLine(ex.Message); }
break;
case "7":
note = false;
break;
default:
Console.WriteLine("\nEntrez un choix valide.\n");
break;
}
}
case "25":///Partager la note
n.VerifyPrivilege(u);
if (true)
{
Console.WriteLine("Saisissez un utilisateur");
nom = Console.ReadLine();
user = db.GetUser(nom);
n.AddCollaborator(u, user);
}
break;
while (tags)
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
Console.WriteLine("| menu - tags |");
Console.WriteLine("| |");
Console.WriteLine("|--------------------------------------|--------|");
Console.WriteLine("| |");
Console.WriteLine("| 1/ - créer tag - |");
Console.WriteLine("| 2/ - ajouter tag - |");
Console.WriteLine("| 3/ - supprimer tag - |");
Console.WriteLine("| 4/ - retour - |");
Console.WriteLine("| |");
Console.WriteLine("|-----------------------------------------------|\n");
Console.WriteLine("rentrez votre choix.");
switch (Console.ReadLine())
{
case "1":
Console.WriteLine("\nChoisissez le nom du tag.");
string? wantedNameTag = Console.ReadLine();
wantedNameTag??= "NoName" + u.GetTagList().Count.ToString();
Console.WriteLine("\nChoisissez la couleur du tag.");
string? wantedColorTag = Console.ReadLine();
wantedColorTag??= "#000000";
if (wantedColorTag[0] != '#') { wantedColorTag = "#" + wantedColorTag; }
else if (wantedColorTag.Length < 7) { string toadd=""; for(int i = 7-wantedColorTag.Length; i!=0; i--){toadd += "0";} wantedColorTag += toadd ;}
else if (wantedColorTag.Length > 7) { wantedColorTag = wantedColorTag[..7];}
u.CreateTag(wantedNameTag,wantedColorTag);
break;
case "2":
Note wantedAddNote;
Tags wantedAddTag;
Console.WriteLine("\n Plusieurs tags à ajouter ? (o/N)");
string? wantedAddMultipleTag = Console.ReadLine();
wantedAddMultipleTag ??= "N";
if(wantedAddMultipleTag == "o" || wantedAddMultipleTag == "O"){
displayNote();
Console.WriteLine("\nDonnez le nom de la note à laquelle ajouter des tags : ");
string? wantedAddNameNote = Console.ReadLine();
wantedAddNameNote??= "";
try{
wantedAddNote = u.GetNoteByName(wantedAddNameNote);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
displayTag();
Console.WriteLine("\nChoisissez les noms des tags séparés par des espaces.");
string? wantedAddNameTags = Console.ReadLine();
wantedAddNameTags??= "";
string[] wantedAddNameTagsList = wantedAddNameTags.Split(' ');
foreach(string wantedAddNameTag in wantedAddNameTagsList)
{
try
{
wantedAddTag = u.GetTagByName(wantedAddNameTag);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
try
{
u.AddTagToNoteList(wantedAddNote, wantedAddTag);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
}
}else if(wantedAddMultipleTag == "n" || wantedAddMultipleTag == "N"){
displayNote();
Console.WriteLine("\nChoisissez le nom de la note.");
string? wantedAddNameNote = Console.ReadLine();
wantedAddNameNote??= "";
displayTag();
Console.WriteLine("\nChoisissez le nom du tag.");
string? wantedAddNameTag = Console.ReadLine();
wantedAddNameTag??= "";
try
{
wantedAddNote = u.GetNoteByName(wantedAddNameNote);
wantedAddTag = u.GetTagByName(wantedAddNameTag);
u.AddTagToNoteList(wantedAddNote, wantedAddTag);
}catch (Exception ex) { Console.WriteLine(ex.Message); }
}else{
Console.WriteLine("\nEntrez un choix valide.\n");
}
break;
case "3":
displayNote();
Note wantedRemoveNote;
Tags wantedRemoveTag;
Console.WriteLine("\n Choisissez le nom de la note à laquelle supprimer des tags : ");
string? wantedRemoveNameNote = Console.ReadLine();
wantedRemoveNameNote??= "";
try{
wantedRemoveNote = u.GetNoteByName(wantedRemoveNameNote);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
foreach( Tags t in u.GetNoteTaggedList(wantedRemoveNote))
{
Console.WriteLine(t.GetName() + "\n");
}
Console.WriteLine("\nChoisissez le nom du tag à supprimer.");
string? wantedRemoveNameTag = Console.ReadLine();
wantedRemoveNameTag??= "";
try {
wantedRemoveTag = u.GetTagByName(wantedRemoveNameTag);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
try
{
u.RemoveTagFromNoteList(wantedRemoveNote, wantedRemoveTag);
}catch (Exception ex) { Console.WriteLine(ex.Message); }
break;
case "4":
tags = false;
break;
default:
Console.WriteLine("\nEntrez un choix valide.\n");
break;
}
}
case "26":///Modifier les editeurs
Console.WriteLine("Ajouter editeur ou supprimer editeur ? (0/1)");
choix = Console.ReadLine();
n.VerifyPrivilege(u);
if (true && choix.Equals('0'))
{
Console.WriteLine("Saisissez un utilisateur");
nom = Console.ReadLine();
user = db.GetUser(nom);
n.AddEditor(u, user);
}
if (true && choix.Equals('1'))
while(para)
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
Console.WriteLine("| menu - paramêtre |");
Console.WriteLine("| |");
Console.WriteLine("|--------------------------------------|--------|");
Console.WriteLine("| |");
Console.WriteLine("| 1/ - modifier compte - |");
Console.WriteLine("| 2/ - thèmes - |");
Console.WriteLine("| 3/ - supprimer un compte - |");
Console.WriteLine("| 4/ - retour - |");
Console.WriteLine("| |");
Console.WriteLine("|-----------------------------------------------|\n");
Console.WriteLine("rentrez votre choix.");
switch (Console.ReadLine())
{
case "1":
paraCompte = true;
break;
case "2":
theme = true;
break;
case "3":
Console.WriteLine("\nÊtes-vous sûr de vouloir supprimer votre compte ? (o/N)");
string? wantedDelete = Console.ReadLine();
wantedDelete??= "N";
if( wantedDelete == "o" || wantedDelete == "O"){
db.RemoveUser(u);
Console.WriteLine("\nVotre compte a bien été supprimé.\n");
para = false;
u = uvide;
break;
}else if( wantedDelete == "n" || wantedDelete == "N"){
break;
}
break;
case "4":
para = false;
break;
default:
Console.WriteLine("\nEntrez un choix valide.\n");
break;
}
while (paraCompte)
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
Console.WriteLine("| paramêtre - compte |");
Console.WriteLine("| |");
Console.WriteLine("|--------------------------------------|--------|");
Console.WriteLine("| |");
Console.WriteLine("| 1/ - modifier pseudo - |");
Console.WriteLine("| 2/ - modifier mot de passe - |");
Console.WriteLine("| 3/ - retour - |");
Console.WriteLine("| |");
Console.WriteLine("|-----------------------------------------------|\n");
Console.WriteLine("rentrez votre choix.");
switch (Console.ReadLine())
{
Console.WriteLine("Saisissez un utilisateur");
nom = Console.ReadLine();
user = db.GetUser(nom);
n.RemoveEditor(u, user);
case "1":
Console.WriteLine("\nChoisissez le nouveau pseudo.");
string? wantedNewPseudo = Console.ReadLine();
if(wantedNewPseudo == null){break;}
u.SetUsername(wantedNewPseudo);
break;
case "2":
Console.WriteLine("\nChoisissez le nouveau mot de passe.");
string? wantedNewPassword = Console.ReadLine();
if(wantedNewPassword == null){break;}
else if(wantedNewPassword.Length < 8){
Console.WriteLine("\nLe mot de passe doit contenir au moins 8 caractères.\n");
break;
}
wantedNewPassword = GetSHA256Hash(wantedNewPassword);
if(wantedNewPassword == u.GetPassword()){
Console.WriteLine("\nLe nouveau mot de passe doit être différent de l'ancien.\n");
break;
}
u.SetPassword(wantedNewPassword);
break;
case "3":
paraCompte = false;
break;
default:
Console.WriteLine("\nEntrez un choix valide.\n");
break;
}
break;
case "27":///Supprimer un cooperateur
n.VerifyPrivilege(u);
if (true)
}
while (theme)
{
Console.WriteLine("\n|--------------------------------------|");
Console.WriteLine("| |");
Console.WriteLine("| paramêtre - thèmes |");
Console.WriteLine("| |");
Console.WriteLine("|--------------------------------------|--------|");
Console.WriteLine("| |");
Console.WriteLine("| 1/ - choisir un thème - |");
Console.WriteLine("| 2/ - créer un thème - |");
Console.WriteLine("| 3/ - supprimer un thème - |");
Console.WriteLine("| 4/ - modifier un thème - |");
Console.WriteLine("| 5/ - retour - |");
Console.WriteLine("| |");
Console.WriteLine("|-----------------------------------------------|\n");
Console.WriteLine("rentrez votre choix.");
switch (Console.ReadLine())
{
Console.WriteLine("Saisissez un utilisateur");
nom = Console.ReadLine();
user = db.GetUser(nom);
n.RemoveCollaborator(u, user);
case "1":
Theme twantedTheme;
displayTheme();
Console.WriteLine("\nChoisissez le nom du thème.");
string? wantedTheme = Console.ReadLine();
if(wantedTheme==null){break;}
try
{
twantedTheme = db.GetTheme(wantedTheme);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
u.SetTheme(twantedTheme);
break;
case "2":
List<string>? themeList;
Console.WriteLine("\nChoisissez le nom du thème.");
string? wantedNewThemeName = Console.ReadLine();
if(wantedNewThemeName==null){break;}
Console.WriteLine("\nChoisissez la couleur du thème.");
themeList = choix_couleur();
if(themeList == null) { break;}
db.AddTheme(new Theme(wantedNewThemeName, themeList));
break;
case "3":
Theme t;
Console.WriteLine("\nChoisissez le nom du thème à supprimer.");
string? wantedRemoveTheme = Console.ReadLine();
if(wantedRemoveTheme == null) {break;}
try{
t = db.GetTheme(wantedRemoveTheme);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
try{
db.RemoveTheme(t);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
break;
case "4":
displayTheme();
Theme themeToModify;
Console.WriteLine("\nChoisissez le nom du thème à modifier.");
string? wantedModifyTheme = Console.ReadLine();
if(wantedModifyTheme == null){break;}
try{
themeToModify = db.GetTheme(wantedModifyTheme);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
Console.WriteLine("\nChoisissez le nouveau nom du thème.");
string? wantedNewNameTheme = Console.ReadLine();
if(wantedNewNameTheme == null) {break;}
try{
db.ModifyThemeName(themeToModify, wantedNewNameTheme);
}catch (Exception ex) { Console.WriteLine(ex.Message); break;}
Console.WriteLine("\nChoisissez les nouvelles couleurs du thème.");
List<string>? couleurlist = choix_couleur();
if(couleurlist == null) { break;}
db.ModifyThemeColorList(themeToModify, couleurlist);
break;
case "5":
theme = false;
break;
default:
Console.WriteLine("\nEntrez un choix valide.\n");
break;
}
break;
default:
Console.WriteLine("< Veuillez rentrer une des options proposées à l'ecran ! >");
break;
}
}
}

@ -10,10 +10,9 @@ namespace Notus_Persistance
{
public class Stub : IManager
{
void errorMess()
public void SaveDatabaseData(Database database)
{
Console.WriteLine("Pas d'enregistrement de données dans le stub.");
return;
throw new NotImplementedException();
}
//Loaders
@ -24,103 +23,15 @@ namespace Notus_Persistance
database.AddUser(new User("Benjamin", "labsent@gmail.com", "Moto2005"));
database.AddUser(new User("Liam", "liammonchanin@gmail.com", "Baguette"));
database.AddUser(new User("Brigitte", "Macroutte@gmail.com", "49Trois"));
foreach(User user in database.GetUserList().Where(x => x.GetUsername().Contains("m")))
{
user.CreateNote("Note 1", "");
user.CreateNote("Note 2", "");
user.CreateNote("Note 3", "");
}
return database;
}
List<User> IManager.LoadUserData()
{
List<User> users = new List<User>();
users.Add(new User("Nicolas", "leHeros@gmail.com", "Feur"));
users.Add(new User("Benjamin", "labsent@gmail.com", "Moto2005"));
users.Add(new User("Liam", "liammonchanin@gmail.com", "Baguette"));
users.Add(new User("Brigitte", "Macroutte@gmail.com", "49Trois"));
return users;
}
List<Note> IManager.LoadNote()
{
List<Note> notes = new List<Note>();
notes.Add(new Note("Note_1", "Logo_1", new User("Liam", "Liam@gmail.com", "Oui")));
notes.Add(new Note("Note_2", "Logo_3", new User("Liam", "Liam@gmail.com", "Oui")));
notes.Add(new Note("Note_3", "Logo_5", new User("Liam", "Liam@gmail.com", "Oui")));
notes.Add(new Note("Note_4", "Logo_7", new User("Liam", "Liam@gmail.com", "Oui")));
notes.Add(new Note("Note_5", "Logo_9", new User("Liam", "Liam@gmail.com", "Oui")));
return notes;
}
List<Theme> IManager.LoadTheme()
{
List<Theme> themes = new List<Theme>();
themes.Add(new Theme("Tropiques", new List<string> { }));
themes.Add(new Theme("Savane", new List<string> { }));
themes.Add(new Theme("Nuit", new List<string> { }));
return themes;
}
List<Logo> IManager.LoadLogo()
{
List<Logo> logos = new List<Logo>();
logos.Add(new Logo("pinguin", "pinguin.png"));
logos.Add(new Logo("ours", "ours.png"));
logos.Add(new Logo("caddie", "caddie.png"));
logos.Add(new Logo("croix", "croix.png"));
return logos;
}
List<Tags> IManager.LoadTags()
{
List<Tags> tags = new List<Tags>();
tags.Add(new Tags("courses", "vert"));
tags.Add(new Tags("urgent", "rouge"));
tags.Add(new Tags("enfants", "bleu"));
return tags;
}
List<NoteImage> IManager.LoadNoteImage()
{
List<NoteImage> noteImages = new List<NoteImage>();
noteImages.Add(new NoteImage(1, "soupe.png", "2.4"));
noteImages.Add(new NoteImage(2, "baguette.png", "5.2"));
noteImages.Add(new NoteImage(3, "cailloux.png", "3.10"));
return noteImages;
}
//Savers
void IManager.SaveNote(Note note)
{
errorMess();
}
void IManager.SaveDatabaseData(Database database)
{
errorMess();
}
void IManager.SaveUserData(User user)
{
errorMess();
}
void IManager.SaveTheme(Theme theme)
{
errorMess();
}
void IManager.SaveLogo(Logo logo)
{
errorMess();
}
void IManager.SaveTags(Tags tag)
{
errorMess();
}
void IManager.SaveNoteImage(NoteImage noteImage)
{
errorMess();
}
}
}

@ -19,9 +19,7 @@ namespace Notus_UnitTest_Database
[Test]
public void GetLogoLink_LogoExists_ReturnsLogoLink()
{
string logoName = "Logo2";
string logoLink = database.GetLogoLink(logoName);
Assert.That(logoLink, Is.EqualTo("link2"));
Assert.That(database.GetLogoLink("Logo2"), Is.EqualTo("link2"));
}
[Test]

@ -29,15 +29,5 @@ namespace Notus_UnitTest_Database
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<NotFoundException>(() => database.ModifyThemeColorList(theme, newColorList), "Theme not found.");
}
}
}

@ -5,34 +5,55 @@ namespace Notus_UnitTest_User
[TestFixture]
public class SearchNoteByNameTests
{
private User owner;
private string searchName;
[SetUp]
public void SetUp()
{
owner = new("Owner", "owner@example.com", "password");
owner.CreateNote("Note 1", "image1.png");
owner.CreateNote("Note 2", "image2.png");
owner.CreateNote("Another Note", "image3.png");
owner.AddFavorite(owner.GetNoteList()[0]);
owner.AddFavorite(owner.GetNoteList()[1]);
owner.AddFavorite(owner.GetNoteList()[2]);
searchName = "note";
}
[Test]
public void SearchNoteByName_WhenMatchingNotesExist_NotesReturned()
{
User user = new User("TestUser", "testuser@example.com", "password");
Note note1 = new Note("Note 1", "image1.png", user);
Note note2 = new Note("Note 2", "image2.png", user);
Note note3 = new Note("Another Note", "image3.png", user);
user.GetNoteList().Add(note1);
user.GetNoteList().Add(note2);
user.GetNoteList().Add(note3);
List<Note> result = user.SearchNoteByName("note");
Assert.That(result.Count, Is.EqualTo(3));
CollectionAssert.Contains(result, note1);
CollectionAssert.Contains(result, note2);
CollectionAssert.Contains(result, note3);
List<Note> result = owner.SearchNoteByName(owner.GetNoteList(),"note");
Assert.That(result, Has.Count.EqualTo(3));
CollectionAssert.Contains(result, owner.GetNoteList()[0]);
CollectionAssert.Contains(result, owner.GetNoteList()[1]);
CollectionAssert.Contains(result, owner.GetNoteList()[2]);
}
[Test]
public void SearchNoteByName_WhenNoMatchingNotesExist_EmptyListReturned()
{
User user = new User("TestUser", "testuser@example.com", "password");
Note note1 = new Note("Note 1", "image1.png", user);
Note note2 = new Note("Note 2", "image2.png", user);
user.GetNoteList().Add(note1);
user.GetNoteList().Add(note2);
List<Note> result = user.SearchNoteByName("test");
Assert.IsEmpty(result);
List<Note> result = owner.SearchNoteByName(owner.GetNoteList(), "test");
Assert.That(result, Is.Empty);
}
[Test]
public void SearchFavoriteNoteByName_ShouldReturnMatchingNotes()
{
List<Note> searchedNotes = owner.SearchNoteByName(owner.GetFavList(), searchName);
Assert.That(searchedNotes, Has.Count.EqualTo(3));
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[0]);
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[1]);
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[2]);
}
[Test]
public void SearchFavoriteNoteByName_ShouldReturnEmptyList_WhenNoMatchFound()
{
searchName = "nonexistent";
List<Note> searchedNotes = owner.SearchNoteByName(owner.GetFavList(), searchName);
Assert.That(searchedNotes, Is.Empty);
}
}
}
Loading…
Cancel
Save