Stub effectué avec données à l'interieur
continuous-integration/drone/push Build is passing Details

pull/19/head
Liam MONCHANIN 2 years ago
parent 6af577e2f2
commit a764c8283d

@ -16,6 +16,25 @@ namespace Biblioteque_de_Class
public List<User> LoadUserData();
//public List<Note> LoadNote();
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);
}
}

@ -9,18 +9,18 @@ namespace Biblioteque_de_Class
public class Note
{
private string name;
private string Name
public string Name
{
get { return name; }
set { if (value == null) { name = "Unnamed Note"; } else { name = value; } }
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 logoPath;
private string LogoPath
public string LogoPath
{
get { return logoPath; }
set { if (value == null) { logoPath = "PATH TO DEFAULT LOGO"; } else { logoPath = value; } }
private set { if (value == null) { logoPath = "PATH TO DEFAULT LOGO"; } else { logoPath = value; } }
}
private DateOnly CreationDate { get; }

@ -30,5 +30,44 @@ namespace Biblioteque_de_Class
{
return persistence.LoadUserData();
}
public void SaveNote(Note note)
{
persistence.SaveNote(note);
}
public List<Note> LoadNote()
{
return persistence.LoadNote();
}
public List<Logo> LoadLogo()
{
return persistence.LoadLogo();
}
public void SaveLogo(Logo logo)
{
persistence.SaveLogo(logo);
}
public List<Tags> LoadTags()
{
return persistence.LoadTags();
}
public void SaveTags(Tags tag)
{
persistence.SaveTags(tag);
}
public List<NoteImage> LoadNoteImage()
{
return persistence.LoadNoteImage();
}
public void SaveNoteImage(NoteImage noteImage)
{
persistence.SaveNoteImage(noteImage);
}
}
}

@ -31,21 +31,23 @@ 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());
List<string> NewColorList = new List<string> { };
List<string> listCouleurs = new List<string> { };
List<Note> _searchedNotes;
List<Note> NoteListe;
List<Note> NoteListe = managerPers.LoadNote();
List<Tags> _searchedTags;
List<User> UserListe; // = IManager.LoadUserData(); /// Essai de load via Imanager
List<User> UserListe = managerPers.LoadUserData();
foreach (User us in UserListe) /// Test du stub
/*foreach (Note no in NoteListe) /// Test du stub
{
Console.WriteLine("Coucou");
Console.WriteLine(no.GetName());
}
return;
return;*/
int boucle = 0;
while (boucle == 0)
{

@ -8,13 +8,15 @@ using System.Threading.Tasks;
namespace Notus_Persistance
{
internal class Stub : IManager
public class Stub : IManager
{
void IManager.SaveDatabaseData(Database database)
void errorMess()
{
throw new NotImplementedException();
Console.WriteLine("Pas d'enregistrement de données dans le stub.");
return;
}
//Loaders
Database IManager.LoadDatabaseData()
{
Database database = new Database();
@ -25,12 +27,7 @@ namespace Notus_Persistance
return database;
}
void IManager.SaveUserData(User user)
{
throw new NotImplementedException();
}
List <User> IManager.LoadUserData()
List<User> IManager.LoadUserData()
{
List<User> users = new List<User>();
users.Add(new User("Nicolas", "leHeros@gmail.com", "Feur"));
@ -40,16 +37,90 @@ namespace Notus_Persistance
return users;
}
/*List<Note> IManager.LoadNote()
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")));
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();
}
}
}

@ -16,8 +16,18 @@ namespace Notus_Persistance
{
private const string DatabaseDataFilePath = "data.json";
private const string UserDataFilePath = "userdata.json";
private const string NoteDataFilePath = "notedata.json";
private const string ThemeDataFilePath = "themedata.json";
private const string LogoDataFilePath = "logodata.json";
private const string TagsDataFilePath = "tagsdata.json";
private const string NoteImageDataFilePath = "noteImagedata.json";
private static DataContractJsonSerializer DatabasejsonSerializer = new DataContractJsonSerializer(typeof(Database));
private static DataContractJsonSerializer UserjsonSerializer = new DataContractJsonSerializer(typeof(User));
private static DataContractJsonSerializer NotejsonSerializer = new DataContractJsonSerializer(typeof(Note));
private static DataContractJsonSerializer ThemejsonSerializer = new DataContractJsonSerializer(typeof(Theme));
private static DataContractJsonSerializer LogojsonSerializer = new DataContractJsonSerializer(typeof(Logo));
private static DataContractJsonSerializer TagsjsonSerializer = new DataContractJsonSerializer(typeof(Tags));
private static DataContractJsonSerializer NoteImagejsonSerializer = new DataContractJsonSerializer(typeof(NoteImage));
public void SaveDatabaseData(Database database)
{
using (FileStream fileStream = File.Create(DatabaseDataFilePath))
@ -97,5 +107,215 @@ namespace Notus_Persistance
throw new FileException("No userfile find");
}
}
List<Note> IManager.LoadNote()
{
List<Note> notes = new List<Note>();
if (File.Exists(NoteDataFilePath))
{
Note note;
using (FileStream fileStream = File.OpenRead(UserDataFilePath))
{
Note? note1 = (Note?)NotejsonSerializer.ReadObject(fileStream);
if (note1 == null)
{
throw new FileException("Failed to load database. The loaded object is null.");
}
else
{
note = note1;
notes.Add(note);
return notes;
}
}
}
else
{
throw new FileException("No notefile find");
}
}
public void SaveNote(Note note)
{
using (FileStream fileStream = File.Create(NoteDataFilePath))
{
using (var writer = JsonReaderWriterFactory.CreateJsonWriter(
fileStream,
System.Text.Encoding.UTF8,
false,
true))//<- this boolean says that we sant indentation
{
NotejsonSerializer.WriteObject(writer, note);
}
}
}
List<Theme> IManager.LoadTheme()
{
List<Theme> themes = new List<Theme>();
if (File.Exists(ThemeDataFilePath))
{
Theme theme;
using (FileStream fileStream = File.OpenRead(UserDataFilePath))
{
Theme? theme1 = (Theme?)ThemejsonSerializer.ReadObject(fileStream);
if (theme1 == null)
{
throw new FileException("Failed to load database. The loaded object is null.");
}
else
{
theme = theme1;
themes.Add(theme);
return themes;
}
}
}
else
{
throw new FileException("No themefile find");
}
}
public void SaveTheme(Theme theme)
{
using (FileStream fileStream = File.Create(ThemeDataFilePath))
{
using (var writer = JsonReaderWriterFactory.CreateJsonWriter(
fileStream,
System.Text.Encoding.UTF8,
false,
true))//<- this boolean says that we sant indentation
{
ThemejsonSerializer.WriteObject(writer, theme);
}
}
}
List<Logo> IManager.LoadLogo()
{
List<Logo> logos = new List<Logo>();
if (File.Exists(LogoDataFilePath))
{
Logo logo;
using (FileStream fileStream = File.OpenRead(UserDataFilePath))
{
Logo? logo1 = (Logo?)LogojsonSerializer.ReadObject(fileStream);
if (logo1 == null)
{
throw new FileException("Failed to load database. The loaded object is null.");
}
else
{
logo = logo1;
logos.Add(logo);
return logos;
}
}
}
else
{
throw new FileException("No notefile find");
}
}
public void SaveLogo(Logo logo)
{
using (FileStream fileStream = File.Create(LogoDataFilePath))
{
using (var writer = JsonReaderWriterFactory.CreateJsonWriter(
fileStream,
System.Text.Encoding.UTF8,
false,
true))//<- this boolean says that we sant indentation
{
LogojsonSerializer.WriteObject(writer, logo);
}
}
}
List<Tags> IManager.LoadTags()
{
List<Tags> tags = new List<Tags>();
if (File.Exists(TagsDataFilePath))
{
Tags tag;
using (FileStream fileStream = File.OpenRead(TagsDataFilePath))
{
Tags? tag1 = (Tags?)TagsjsonSerializer.ReadObject(fileStream);
if (tag1 == null)
{
throw new FileException("Failed to load database. The loaded object is null.");
}
else
{
tag = tag1;
tags.Add(tag);
return tags;
}
}
}
else
{
throw new FileException("No tagfile find");
}
}
public void SaveTags(Tags tag)
{
using (FileStream fileStream = File.Create(TagsDataFilePath))
{
using (var writer = JsonReaderWriterFactory.CreateJsonWriter(
fileStream,
System.Text.Encoding.UTF8,
false,
true))//<- this boolean says that we sant indentation
{
TagsjsonSerializer.WriteObject(writer, tag);
}
}
}
List<NoteImage> IManager.LoadNoteImage()
{
List<NoteImage> noteImages = new List<NoteImage>();
if (File.Exists(NoteImageDataFilePath))
{
NoteImage noteImage;
using (FileStream fileStream = File.OpenRead(NoteImageDataFilePath))
{
NoteImage? noteImage1 = (NoteImage?)NoteImagejsonSerializer.ReadObject(fileStream);
if (noteImage1 == null)
{
throw new FileException("Failed to load database. The loaded object is null.");
}
else
{
noteImage = noteImage1;
noteImages.Add(noteImage);
return noteImages;
}
}
}
else
{
throw new FileException("No noteImagefile find");
}
}
public void SaveNoteImage(NoteImage noteImage)
{
using (FileStream fileStream = File.Create(NoteImageDataFilePath))
{
using (var writer = JsonReaderWriterFactory.CreateJsonWriter(
fileStream,
System.Text.Encoding.UTF8,
false,
true))//<- this boolean says that we sant indentation
{
NoteImagejsonSerializer.WriteObject(writer, noteImage);
}
}
}
}
}

@ -34,5 +34,52 @@ namespace Notus_Persistance
{
throw new NotImplementedException();
}
List<Note> IManager.LoadNote()
{
throw new NotImplementedException();
}
public void SaveNote(Note note)
{
throw new NotImplementedException();
}
List<Theme> IManager.LoadTheme()
{
throw new NotImplementedException();
}
public void SaveTheme(Theme theme)
{
throw new NotImplementedException();
}
List<Logo> IManager.LoadLogo()
{
throw new NotImplementedException();
}
public void SaveLogo(Logo logo)
{
throw new NotImplementedException();
}
List<Tags> IManager.LoadTags()
{
throw new NotImplementedException();
}
public void SaveTags(Tags tag)
{
throw new NotImplementedException();
}
List<NoteImage> IManager.LoadNoteImage()
{
throw new NotImplementedException();
}
public void SaveNoteImage(NoteImage noteImage)
{
throw new NotImplementedException();
}
}
}

Loading…
Cancel
Save