diff --git a/.drone.yml b/.drone.yml index 99e8c35..5c0a580 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,7 +11,7 @@ steps: - name: build image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest commands: - - cd MangaMap/ + - cd src/MangaMap/ - dotnet restore MangaMap.sln - dotnet build MangaMap.sln -c Release --no-restore --framework net7.0 - dotnet publish MangaMap.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release --framework net7.0 @@ -19,9 +19,9 @@ steps: - name: tests image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest commands: - - cd MangaMap/ + - cd src/MangaMap/ - dotnet restore MangaMap.sln - - dotnet test MangaMap.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - dotnet test MangaMap.sln --logger trx --no-restore /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" depends_on: [build] - name: code-analysis @@ -34,7 +34,7 @@ steps: sonar_token: from_secret: SECRET_SONAR_LOGIN commands: - - cd MangaMap/ + - cd src/MangaMap/ - dotnet restore MangaMap.sln - dotnet sonarscanner begin /k:"MangaMap" /d:sonar.host.url=$${PLUGIN_SONAR_HOST} /d:sonar.login=$${PLUGIN_SONAR_TOKEN} - dotnet build MangaMap.sln -c Release --no-restore diff --git a/Documentation/doxygen/Doxyfile b/Documentation/doxygen/Doxyfile index 40db241..02fd53f 100644 --- a/Documentation/doxygen/Doxyfile +++ b/Documentation/doxygen/Doxyfile @@ -125,7 +125,7 @@ WARN_LOGFILE = # Configuration options related to the input files #--------------------------------------------------------------------------- -INPUT = MangaMap +INPUT = src INPUT_ENCODING = UTF-8 FILE_PATTERNS = *.c \ *.cc \ diff --git a/MangaMap/MangaMap.sln b/MangaMap/MangaMap.sln deleted file mode 100644 index c199b28..0000000 --- a/MangaMap/MangaMap.sln +++ /dev/null @@ -1,27 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31611.283 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MangaMap", "MangaMap.csproj", "{1946288E-37BA-420F-89BD-A1C3D4178344}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {1946288E-37BA-420F-89BD-A1C3D4178344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1946288E-37BA-420F-89BD-A1C3D4178344}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1946288E-37BA-420F-89BD-A1C3D4178344}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {1946288E-37BA-420F-89BD-A1C3D4178344}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1946288E-37BA-420F-89BD-A1C3D4178344}.Release|Any CPU.Build.0 = Release|Any CPU - {1946288E-37BA-420F-89BD-A1C3D4178344}.Release|Any CPU.Deploy.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572} - EndGlobalSection -EndGlobal diff --git a/MangaMap/App.xaml b/src/MangaMap/App.xaml similarity index 100% rename from MangaMap/App.xaml rename to src/MangaMap/App.xaml diff --git a/MangaMap/App.xaml.cs b/src/MangaMap/App.xaml.cs similarity index 70% rename from MangaMap/App.xaml.cs rename to src/MangaMap/App.xaml.cs index a13dace..fcfac7e 100644 --- a/MangaMap/App.xaml.cs +++ b/src/MangaMap/App.xaml.cs @@ -1,6 +1,7 @@ -using MangaMap.Model; -using MangaMap.Stub; +using Models; +using Stub; using MangaMap.Views; +using System.Diagnostics; namespace MangaMap; @@ -38,7 +39,8 @@ public partial class App : Application if (File.Exists(Path.Combine(FilePath, FileName))) { - MyManager = new Manager(new Stub.DataContract()); // Utilise le DataContract comme moyen de persistance. + MyManager = new Manager(new DataContractPersistance.DataContractXML()); // Utilise le DataContract comme moyen de persistance. + //MyManager = new Manager(new Stub.DataContractJSON()); // Utilise le DataContract comme moyen de persistance. } MyManager.charger(); @@ -48,7 +50,8 @@ public partial class App : Application if (!File.Exists(Path.Combine(FilePath, FileName))) { - MyManager.Persistance = new DataContract(); // Utilise le Stub comme moyen de persistance. + MyManager.Persistance = new DataContractPersistance.DataContractXML(); // Utilise le Stub comme moyen de persistance. + //MyManager = new Manager(new Stub.DataContractJSON()); } MyManager.sauvegarder(); diff --git a/MangaMap/AppShell.xaml b/src/MangaMap/AppShell.xaml similarity index 100% rename from MangaMap/AppShell.xaml rename to src/MangaMap/AppShell.xaml diff --git a/MangaMap/AppShell.xaml.cs b/src/MangaMap/AppShell.xaml.cs similarity index 100% rename from MangaMap/AppShell.xaml.cs rename to src/MangaMap/AppShell.xaml.cs diff --git a/MangaMap/CustomHeader.xaml b/src/MangaMap/CustomHeader.xaml similarity index 100% rename from MangaMap/CustomHeader.xaml rename to src/MangaMap/CustomHeader.xaml diff --git a/MangaMap/CustomHeader.xaml.cs b/src/MangaMap/CustomHeader.xaml.cs similarity index 96% rename from MangaMap/CustomHeader.xaml.cs rename to src/MangaMap/CustomHeader.xaml.cs index f62f384..c845dda 100644 --- a/MangaMap/CustomHeader.xaml.cs +++ b/src/MangaMap/CustomHeader.xaml.cs @@ -1,6 +1,6 @@ using MangaMap.Views; namespace MangaMap; -using MangaMap.Model; +using Models; using System.ComponentModel; using INotifyPropertyChanged = System.ComponentModel.INotifyPropertyChanged; diff --git a/src/MangaMap/DataContractPersistance/DataContractJSON.cs b/src/MangaMap/DataContractPersistance/DataContractJSON.cs new file mode 100644 index 0000000..08fb73a --- /dev/null +++ b/src/MangaMap/DataContractPersistance/DataContractJSON.cs @@ -0,0 +1,78 @@ +using Models; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.Serialization.Json; +using System.Text; +using System.Threading.Tasks; + +namespace MangaMap.DataContractPersistance +{ + /// + /// Implémentation de l'interface IPersistanceManager utilisant la sérialisation avec DataContract. + /// + public class DataContractJSON : IPersistanceManager + { + /// + /// Obtient ou définit le nom du fichier de sauvegarde JSON. + /// + public string FileName { get; set; } = "SauvegardeDonnees.json"; + + /// + /// Obtient ou définit le chemin du fichier de sauvegarde JSON. + /// + public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory); + + /// + /// Charge les données sauvegardées à partir du fichier JSON. + /// + /// Un tuple contenant la liste des oeuvres et la liste des utilisateurs. + public (ObservableCollection, List) chargeDonne() + { + DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(DataToPersist)); + + DataToPersist data; + + using (FileStream stream2 = File.OpenRead(Path.Combine(FilePath, FileName))) + { + data = jsonSerializer.ReadObject(stream2) as DataToPersist; + } + + return (data.Oeuvres, data.Utilisateurs); + } + + /// + /// Sauvegarde les données dans le fichier JSON. + /// + /// La liste des oeuvres à sauvegarder. + /// La liste des utilisateurs à sauvegarder. + public void sauvegarder(ObservableCollection o, List u) + { + DataToPersist data = new DataToPersist(); + data.Oeuvres = o; + data.Utilisateurs = u; + + if (!Directory.Exists(FilePath)) + { + Debug.WriteLine("Directory doesn't exist."); + Directory.CreateDirectory(FilePath); + } + + DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(DataToPersist)); + using (FileStream stream = File.Create(Path.Combine(FilePath, FileName))) + { + using (var writer = JsonReaderWriterFactory.CreateJsonWriter( + stream, + Encoding.UTF8, + false, + true))//<- this boolean says that we sant indentation + { + jsonSerializer.WriteObject(writer, data); + writer.Flush(); + } + } + } + } +} diff --git a/MangaMap/Stub/DataContract.cs b/src/MangaMap/DataContractPersistance/DataContractXML.cs similarity index 89% rename from MangaMap/Stub/DataContract.cs rename to src/MangaMap/DataContractPersistance/DataContractXML.cs index 1f3ba71..5c09abf 100644 --- a/MangaMap/Stub/DataContract.cs +++ b/src/MangaMap/DataContractPersistance/DataContractXML.cs @@ -1,82 +1,82 @@ -using MangaMap.Model; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.Linq; -using System.Runtime.Serialization; -using System.Text; -using System.Threading.Tasks; -using System.Xml; - -namespace MangaMap.Stub -{ - /// - /// Implémentation de l'interface IPersistanceManager utilisant la sérialisation avec DataContract. - /// - public class DataContract : IPersistanceManager - { - /// - /// Obtient ou définit le nom du fichier de sauvegarde. - /// - public string FileName { get; set; } = "SauvegardeDonnees.xml"; - - /// - /// Obtient ou définit le chemin du fichier de sauvegarde. - /// - public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory); - - /// - /// Charge les données sauvegardées à partir du fichier xml. - /// - /// Un tuple contenant la liste des oeuvres et la liste des utilisateurs. - public (ObservableCollection, List) chargeDonne() - { - var serializer = new DataContractSerializer(typeof(DataToPersist)); - DataToPersist data; - - if (File.Exists(Path.Combine(FilePath, FileName))) // Vérifiez si le fichier existe - { - using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName))) - { - data = serializer.ReadObject(s) as DataToPersist; - } - } - else - { - data = new DataToPersist(); // Si le fichier n'existe pas, créez une nouvelle liste - } - - return (data.Oeuvres, data.Utilisateurs); - } - - /// - /// Sauvegarde les données dans le fichier xml. - /// - /// La liste des oeuvres à sauvegarder. - /// La liste des utilisateurs à sauvegarder. - public void sauvegarder(ObservableCollection o, List u) - { - var serializer = new DataContractSerializer(typeof(DataToPersist)); - - if (!Directory.Exists(FilePath)) - { - Debug.WriteLine("Directory doesn't exist."); - Directory.CreateDirectory(FilePath); - } - - DataToPersist data = new DataToPersist(); - data.Oeuvres = o; - data.Utilisateurs = u; - - var settings = new XmlWriterSettings() { Indent = true }; - using (TextWriter tw = File.CreateText(Path.Combine(FilePath, FileName))) - { - using (XmlWriter w = XmlWriter.Create(tw, settings)) - { - serializer.WriteObject(w, data); // Version d'enregistrement des données avec indentation. - } - } - } - } -} +using Models; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; +using System.Threading.Tasks; +using System.Xml; + +namespace MangaMap.DataContractPersistance +{ + /// + /// Implémentation de l'interface IPersistanceManager utilisant la sérialisation avec DataContract. + /// + public class DataContractXML : IPersistanceManager + { + /// + /// Obtient ou définit le nom du fichier de sauvegarde XML. + /// + public string FileName { get; set; } = "SauvegardeDonnees.xml"; + + /// + /// Obtient ou définit le chemin du fichier de sauvegarde xml. + /// + public string FilePath { get; set; } = Path.Combine(AppDomain.CurrentDomain.BaseDirectory); + + /// + /// Charge les données sauvegardées à partir du fichier xml. + /// + /// Un tuple contenant la liste des oeuvres et la liste des utilisateurs. + public (ObservableCollection, List) chargeDonne() + { + var serializer = new DataContractSerializer(typeof(DataToPersist)); + DataToPersist data; + + if (File.Exists(Path.Combine(FilePath, FileName))) // Vérifiez si le fichier existe + { + using (Stream s = File.OpenRead(Path.Combine(FilePath, FileName))) + { + data = serializer.ReadObject(s) as DataToPersist; + } + } + else + { + data = new DataToPersist(); // Si le fichier n'existe pas, créez une nouvelle liste + } + + return (data.Oeuvres, data.Utilisateurs); + } + + /// + /// Sauvegarde les données dans le fichier XML. + /// + /// La liste des oeuvres à sauvegarder. + /// La liste des utilisateurs à sauvegarder. + public void sauvegarder(ObservableCollection o, List u) + { + var serializer = new DataContractSerializer(typeof(DataToPersist)); + + if (!Directory.Exists(FilePath)) + { + Debug.WriteLine("Directory doesn't exist."); + Directory.CreateDirectory(FilePath); + } + + DataToPersist data = new DataToPersist(); + data.Oeuvres = o; + data.Utilisateurs = u; + + var settings = new XmlWriterSettings() { Indent = true }; + using (TextWriter tw = File.CreateText(Path.Combine(FilePath, FileName))) + { + using (XmlWriter w = XmlWriter.Create(tw, settings)) + { + serializer.WriteObject(w, data); // Version d'enregistrement des données avec indentation. + } + } + } + } +} diff --git a/MangaMap/Stub/DataToPersist.cs b/src/MangaMap/DataContractPersistance/DataToPersist.cs similarity index 90% rename from MangaMap/Stub/DataToPersist.cs rename to src/MangaMap/DataContractPersistance/DataToPersist.cs index 0f30580..01cb813 100644 --- a/MangaMap/Stub/DataToPersist.cs +++ b/src/MangaMap/DataContractPersistance/DataToPersist.cs @@ -1,12 +1,12 @@ using System; -using MangaMap.Model; +using Models; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Collections.ObjectModel; -namespace MangaMap.Stub +namespace MangaMap.DataContractPersistance { /// /// Classe de données pour la persistance contenant les listes des oeuvres et des utilisateurs. diff --git a/MangaMap/MainPage.xaml b/src/MangaMap/MainPage.xaml similarity index 100% rename from MangaMap/MainPage.xaml rename to src/MangaMap/MainPage.xaml diff --git a/MangaMap/MainPage.xaml.cs b/src/MangaMap/MainPage.xaml.cs similarity index 100% rename from MangaMap/MainPage.xaml.cs rename to src/MangaMap/MainPage.xaml.cs diff --git a/MangaMap/MangaMap.csproj b/src/MangaMap/MangaMap.csproj similarity index 91% rename from MangaMap/MangaMap.csproj rename to src/MangaMap/MangaMap.csproj index d4b88f9..8b91f47 100644 --- a/MangaMap/MangaMap.csproj +++ b/src/MangaMap/MangaMap.csproj @@ -50,11 +50,17 @@ + + + + + + @@ -129,7 +135,8 @@ - + + \ No newline at end of file diff --git a/src/MangaMap/MangaMap.sln b/src/MangaMap/MangaMap.sln new file mode 100644 index 0000000..db3434e --- /dev/null +++ b/src/MangaMap/MangaMap.sln @@ -0,0 +1,45 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31611.283 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MangaMap", "MangaMap.csproj", "{1946288E-37BA-420F-89BD-A1C3D4178344}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Models", "..\Models\Models.csproj", "{D13B26C4-A575-4577-A735-0B04DC02BC85}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitTests", "..\UnitTests\UnitTests.csproj", "{6B675815-FEE2-49D0-BAF9-84ECD5116FF9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Stub", "..\Stub\Stub.csproj", "{434D7C7C-2B01-44AA-8619-28D65657C47A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1946288E-37BA-420F-89BD-A1C3D4178344}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1946288E-37BA-420F-89BD-A1C3D4178344}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1946288E-37BA-420F-89BD-A1C3D4178344}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {1946288E-37BA-420F-89BD-A1C3D4178344}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1946288E-37BA-420F-89BD-A1C3D4178344}.Release|Any CPU.Build.0 = Release|Any CPU + {1946288E-37BA-420F-89BD-A1C3D4178344}.Release|Any CPU.Deploy.0 = Release|Any CPU + {D13B26C4-A575-4577-A735-0B04DC02BC85}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D13B26C4-A575-4577-A735-0B04DC02BC85}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D13B26C4-A575-4577-A735-0B04DC02BC85}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D13B26C4-A575-4577-A735-0B04DC02BC85}.Release|Any CPU.Build.0 = Release|Any CPU + {6B675815-FEE2-49D0-BAF9-84ECD5116FF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6B675815-FEE2-49D0-BAF9-84ECD5116FF9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6B675815-FEE2-49D0-BAF9-84ECD5116FF9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6B675815-FEE2-49D0-BAF9-84ECD5116FF9}.Release|Any CPU.Build.0 = Release|Any CPU + {434D7C7C-2B01-44AA-8619-28D65657C47A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {434D7C7C-2B01-44AA-8619-28D65657C47A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {434D7C7C-2B01-44AA-8619-28D65657C47A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {434D7C7C-2B01-44AA-8619-28D65657C47A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572} + EndGlobalSection +EndGlobal diff --git a/MangaMap/MauiProgram.cs b/src/MangaMap/MauiProgram.cs similarity index 100% rename from MangaMap/MauiProgram.cs rename to src/MangaMap/MauiProgram.cs diff --git a/MangaMap/Platforms/Android/AndroidManifest.xml b/src/MangaMap/Platforms/Android/AndroidManifest.xml similarity index 100% rename from MangaMap/Platforms/Android/AndroidManifest.xml rename to src/MangaMap/Platforms/Android/AndroidManifest.xml diff --git a/MangaMap/Platforms/Android/MainActivity.cs b/src/MangaMap/Platforms/Android/MainActivity.cs similarity index 100% rename from MangaMap/Platforms/Android/MainActivity.cs rename to src/MangaMap/Platforms/Android/MainActivity.cs diff --git a/MangaMap/Platforms/Android/MainApplication.cs b/src/MangaMap/Platforms/Android/MainApplication.cs similarity index 100% rename from MangaMap/Platforms/Android/MainApplication.cs rename to src/MangaMap/Platforms/Android/MainApplication.cs diff --git a/MangaMap/Platforms/Android/Resources/values/colors.xml b/src/MangaMap/Platforms/Android/Resources/values/colors.xml similarity index 100% rename from MangaMap/Platforms/Android/Resources/values/colors.xml rename to src/MangaMap/Platforms/Android/Resources/values/colors.xml diff --git a/MangaMap/Platforms/MacCatalyst/AppDelegate.cs b/src/MangaMap/Platforms/MacCatalyst/AppDelegate.cs similarity index 100% rename from MangaMap/Platforms/MacCatalyst/AppDelegate.cs rename to src/MangaMap/Platforms/MacCatalyst/AppDelegate.cs diff --git a/MangaMap/Platforms/MacCatalyst/Info.plist b/src/MangaMap/Platforms/MacCatalyst/Info.plist similarity index 100% rename from MangaMap/Platforms/MacCatalyst/Info.plist rename to src/MangaMap/Platforms/MacCatalyst/Info.plist diff --git a/MangaMap/Platforms/MacCatalyst/Program.cs b/src/MangaMap/Platforms/MacCatalyst/Program.cs similarity index 100% rename from MangaMap/Platforms/MacCatalyst/Program.cs rename to src/MangaMap/Platforms/MacCatalyst/Program.cs diff --git a/MangaMap/Platforms/Tizen/Main.cs b/src/MangaMap/Platforms/Tizen/Main.cs similarity index 100% rename from MangaMap/Platforms/Tizen/Main.cs rename to src/MangaMap/Platforms/Tizen/Main.cs diff --git a/MangaMap/Platforms/Tizen/tizen-manifest.xml b/src/MangaMap/Platforms/Tizen/tizen-manifest.xml similarity index 100% rename from MangaMap/Platforms/Tizen/tizen-manifest.xml rename to src/MangaMap/Platforms/Tizen/tizen-manifest.xml diff --git a/MangaMap/Platforms/Windows/App.xaml b/src/MangaMap/Platforms/Windows/App.xaml similarity index 100% rename from MangaMap/Platforms/Windows/App.xaml rename to src/MangaMap/Platforms/Windows/App.xaml diff --git a/MangaMap/Platforms/Windows/App.xaml.cs b/src/MangaMap/Platforms/Windows/App.xaml.cs similarity index 100% rename from MangaMap/Platforms/Windows/App.xaml.cs rename to src/MangaMap/Platforms/Windows/App.xaml.cs diff --git a/MangaMap/Platforms/Windows/Package.appxmanifest b/src/MangaMap/Platforms/Windows/Package.appxmanifest similarity index 100% rename from MangaMap/Platforms/Windows/Package.appxmanifest rename to src/MangaMap/Platforms/Windows/Package.appxmanifest diff --git a/MangaMap/Platforms/Windows/app.manifest b/src/MangaMap/Platforms/Windows/app.manifest similarity index 100% rename from MangaMap/Platforms/Windows/app.manifest rename to src/MangaMap/Platforms/Windows/app.manifest diff --git a/MangaMap/Platforms/iOS/AppDelegate.cs b/src/MangaMap/Platforms/iOS/AppDelegate.cs similarity index 100% rename from MangaMap/Platforms/iOS/AppDelegate.cs rename to src/MangaMap/Platforms/iOS/AppDelegate.cs diff --git a/MangaMap/Platforms/iOS/Info.plist b/src/MangaMap/Platforms/iOS/Info.plist similarity index 100% rename from MangaMap/Platforms/iOS/Info.plist rename to src/MangaMap/Platforms/iOS/Info.plist diff --git a/MangaMap/Platforms/iOS/Program.cs b/src/MangaMap/Platforms/iOS/Program.cs similarity index 100% rename from MangaMap/Platforms/iOS/Program.cs rename to src/MangaMap/Platforms/iOS/Program.cs diff --git a/MangaMap/Properties/launchSettings.json b/src/MangaMap/Properties/launchSettings.json similarity index 100% rename from MangaMap/Properties/launchSettings.json rename to src/MangaMap/Properties/launchSettings.json diff --git a/MangaMap/Resources/AppIcon/appicon.svg b/src/MangaMap/Resources/AppIcon/appicon.svg similarity index 100% rename from MangaMap/Resources/AppIcon/appicon.svg rename to src/MangaMap/Resources/AppIcon/appicon.svg diff --git a/MangaMap/Resources/AppIcon/appiconfg.svg b/src/MangaMap/Resources/AppIcon/appiconfg.svg similarity index 100% rename from MangaMap/Resources/AppIcon/appiconfg.svg rename to src/MangaMap/Resources/AppIcon/appiconfg.svg diff --git a/MangaMap/Resources/AppIcon/logo.png b/src/MangaMap/Resources/AppIcon/logo.png similarity index 100% rename from MangaMap/Resources/AppIcon/logo.png rename to src/MangaMap/Resources/AppIcon/logo.png diff --git a/MangaMap/Resources/Fonts/OpenSans-Regular.ttf b/src/MangaMap/Resources/Fonts/OpenSans-Regular.ttf similarity index 100% rename from MangaMap/Resources/Fonts/OpenSans-Regular.ttf rename to src/MangaMap/Resources/Fonts/OpenSans-Regular.ttf diff --git a/MangaMap/Resources/Fonts/OpenSans-Semibold.ttf b/src/MangaMap/Resources/Fonts/OpenSans-Semibold.ttf similarity index 100% rename from MangaMap/Resources/Fonts/OpenSans-Semibold.ttf rename to src/MangaMap/Resources/Fonts/OpenSans-Semibold.ttf diff --git a/MangaMap/Resources/Images/account_circle.png b/src/MangaMap/Resources/Images/account_circle.png similarity index 100% rename from MangaMap/Resources/Images/account_circle.png rename to src/MangaMap/Resources/Images/account_circle.png diff --git a/MangaMap/Resources/Images/addepisodes.png b/src/MangaMap/Resources/Images/addepisodes.png similarity index 100% rename from MangaMap/Resources/Images/addepisodes.png rename to src/MangaMap/Resources/Images/addepisodes.png diff --git a/MangaMap/Resources/Images/dotnet_bot.svg b/src/MangaMap/Resources/Images/dotnet_bot.svg similarity index 100% rename from MangaMap/Resources/Images/dotnet_bot.svg rename to src/MangaMap/Resources/Images/dotnet_bot.svg diff --git a/MangaMap/Resources/Images/evangelion.jpg b/src/MangaMap/Resources/Images/evangelion.jpg similarity index 100% rename from MangaMap/Resources/Images/evangelion.jpg rename to src/MangaMap/Resources/Images/evangelion.jpg diff --git a/MangaMap/Resources/Images/listbutton.png b/src/MangaMap/Resources/Images/listbutton.png similarity index 100% rename from MangaMap/Resources/Images/listbutton.png rename to src/MangaMap/Resources/Images/listbutton.png diff --git a/MangaMap/Resources/Images/logo.png b/src/MangaMap/Resources/Images/logo.png similarity index 100% rename from MangaMap/Resources/Images/logo.png rename to src/MangaMap/Resources/Images/logo.png diff --git a/MangaMap/Resources/Images/ok.png b/src/MangaMap/Resources/Images/ok.png similarity index 100% rename from MangaMap/Resources/Images/ok.png rename to src/MangaMap/Resources/Images/ok.png diff --git a/MangaMap/Resources/Images/onepiece.jpg b/src/MangaMap/Resources/Images/onepiece.jpg similarity index 100% rename from MangaMap/Resources/Images/onepiece.jpg rename to src/MangaMap/Resources/Images/onepiece.jpg diff --git a/MangaMap/Resources/Images/oshinoko.png b/src/MangaMap/Resources/Images/oshinoko.png similarity index 100% rename from MangaMap/Resources/Images/oshinoko.png rename to src/MangaMap/Resources/Images/oshinoko.png diff --git a/MangaMap/Resources/Images/settings.png b/src/MangaMap/Resources/Images/settings.png similarity index 100% rename from MangaMap/Resources/Images/settings.png rename to src/MangaMap/Resources/Images/settings.png diff --git a/MangaMap/Resources/Images/star_empty.svg b/src/MangaMap/Resources/Images/star_empty.svg similarity index 100% rename from MangaMap/Resources/Images/star_empty.svg rename to src/MangaMap/Resources/Images/star_empty.svg diff --git a/MangaMap/Resources/Images/star_full.svg b/src/MangaMap/Resources/Images/star_full.svg similarity index 100% rename from MangaMap/Resources/Images/star_full.svg rename to src/MangaMap/Resources/Images/star_full.svg diff --git a/MangaMap/Resources/Raw/AboutAssets.txt b/src/MangaMap/Resources/Raw/AboutAssets.txt similarity index 100% rename from MangaMap/Resources/Raw/AboutAssets.txt rename to src/MangaMap/Resources/Raw/AboutAssets.txt diff --git a/MangaMap/Resources/Splash/splash.svg b/src/MangaMap/Resources/Splash/splash.svg similarity index 100% rename from MangaMap/Resources/Splash/splash.svg rename to src/MangaMap/Resources/Splash/splash.svg diff --git a/MangaMap/Resources/Styles/Colors.xaml b/src/MangaMap/Resources/Styles/Colors.xaml similarity index 100% rename from MangaMap/Resources/Styles/Colors.xaml rename to src/MangaMap/Resources/Styles/Colors.xaml diff --git a/MangaMap/Resources/Styles/Styles.xaml b/src/MangaMap/Resources/Styles/Styles.xaml similarity index 100% rename from MangaMap/Resources/Styles/Styles.xaml rename to src/MangaMap/Resources/Styles/Styles.xaml diff --git a/MangaMap/Resources/Theme/DarkTheme.xaml b/src/MangaMap/Resources/Theme/DarkTheme.xaml similarity index 100% rename from MangaMap/Resources/Theme/DarkTheme.xaml rename to src/MangaMap/Resources/Theme/DarkTheme.xaml diff --git a/MangaMap/Resources/Theme/DarkTheme.xaml.cs b/src/MangaMap/Resources/Theme/DarkTheme.xaml.cs similarity index 100% rename from MangaMap/Resources/Theme/DarkTheme.xaml.cs rename to src/MangaMap/Resources/Theme/DarkTheme.xaml.cs diff --git a/MangaMap/Views/Composants/ListOeuvre.xaml b/src/MangaMap/Views/Composants/ListOeuvre.xaml similarity index 100% rename from MangaMap/Views/Composants/ListOeuvre.xaml rename to src/MangaMap/Views/Composants/ListOeuvre.xaml diff --git a/MangaMap/Views/Composants/ListOeuvre.xaml.cs b/src/MangaMap/Views/Composants/ListOeuvre.xaml.cs similarity index 94% rename from MangaMap/Views/Composants/ListOeuvre.xaml.cs rename to src/MangaMap/Views/Composants/ListOeuvre.xaml.cs index 9c8d065..72a153e 100644 --- a/MangaMap/Views/Composants/ListOeuvre.xaml.cs +++ b/src/MangaMap/Views/Composants/ListOeuvre.xaml.cs @@ -1,5 +1,5 @@ namespace MangaMap.Views.Composants; -using MangaMap.Model; +using Models; using System.Xml; public partial class ListOeuvre : ContentView diff --git a/MangaMap/Views/Composants/StyleBouton.xaml b/src/MangaMap/Views/Composants/StyleBouton.xaml similarity index 100% rename from MangaMap/Views/Composants/StyleBouton.xaml rename to src/MangaMap/Views/Composants/StyleBouton.xaml diff --git a/MangaMap/Views/Composants/StyleBouton.xaml.cs b/src/MangaMap/Views/Composants/StyleBouton.xaml.cs similarity index 95% rename from MangaMap/Views/Composants/StyleBouton.xaml.cs rename to src/MangaMap/Views/Composants/StyleBouton.xaml.cs index 9ae2237..e22327b 100644 --- a/MangaMap/Views/Composants/StyleBouton.xaml.cs +++ b/src/MangaMap/Views/Composants/StyleBouton.xaml.cs @@ -1,4 +1,4 @@ -using MangaMap.Model; +using Models; namespace MangaMap.Views.Composants { diff --git a/MangaMap/Views/CreateOeuvre.xaml.cs b/src/MangaMap/Views/CreateOeuvre.xaml.cs similarity index 99% rename from MangaMap/Views/CreateOeuvre.xaml.cs rename to src/MangaMap/Views/CreateOeuvre.xaml.cs index 4fa4d98..9aec412 100644 --- a/MangaMap/Views/CreateOeuvre.xaml.cs +++ b/src/MangaMap/Views/CreateOeuvre.xaml.cs @@ -1,5 +1,5 @@ using System.Text.RegularExpressions; -using MangaMap.Model; +using Models; using static System.Runtime.InteropServices.JavaScript.JSType; using System.Threading.Tasks; using Microsoft.Maui.Storage; diff --git a/MangaMap/Views/FicheAnime.xaml.cs b/src/MangaMap/Views/FicheAnime.xaml.cs similarity index 97% rename from MangaMap/Views/FicheAnime.xaml.cs rename to src/MangaMap/Views/FicheAnime.xaml.cs index ab40e22..8564ae1 100644 --- a/MangaMap/Views/FicheAnime.xaml.cs +++ b/src/MangaMap/Views/FicheAnime.xaml.cs @@ -1,6 +1,6 @@ namespace MangaMap.Views { - using Model; + using Models; using System.ComponentModel; using System.Diagnostics; using System.Drawing; diff --git a/MangaMap/Views/createOeuvre.xaml b/src/MangaMap/Views/createOeuvre.xaml similarity index 100% rename from MangaMap/Views/createOeuvre.xaml rename to src/MangaMap/Views/createOeuvre.xaml diff --git a/MangaMap/Views/ficheAnime.xaml b/src/MangaMap/Views/ficheAnime.xaml similarity index 100% rename from MangaMap/Views/ficheAnime.xaml rename to src/MangaMap/Views/ficheAnime.xaml diff --git a/MangaMap/Views/homePage.xaml b/src/MangaMap/Views/homePage.xaml similarity index 94% rename from MangaMap/Views/homePage.xaml rename to src/MangaMap/Views/homePage.xaml index e2f52b9..ec60997 100644 --- a/MangaMap/Views/homePage.xaml +++ b/src/MangaMap/Views/homePage.xaml @@ -2,7 +2,7 @@ diff --git a/MangaMap/Views/homePage.xaml.cs b/src/MangaMap/Views/homePage.xaml.cs similarity index 96% rename from MangaMap/Views/homePage.xaml.cs rename to src/MangaMap/Views/homePage.xaml.cs index 8cdc9c4..86f369e 100644 --- a/MangaMap/Views/homePage.xaml.cs +++ b/src/MangaMap/Views/homePage.xaml.cs @@ -1,6 +1,6 @@ namespace MangaMap.Views { - using MangaMap.Model; + using Models; using System.Collections.ObjectModel; /// diff --git a/MangaMap/Views/listPage.xaml b/src/MangaMap/Views/listPage.xaml similarity index 100% rename from MangaMap/Views/listPage.xaml rename to src/MangaMap/Views/listPage.xaml diff --git a/MangaMap/Views/listPage.xaml.cs b/src/MangaMap/Views/listPage.xaml.cs similarity index 89% rename from MangaMap/Views/listPage.xaml.cs rename to src/MangaMap/Views/listPage.xaml.cs index 2a5ed04..a64e75e 100644 --- a/MangaMap/Views/listPage.xaml.cs +++ b/src/MangaMap/Views/listPage.xaml.cs @@ -1,5 +1,5 @@ namespace MangaMap.Views; -using MangaMap.Model; +using Models; using static System.Net.Mime.MediaTypeNames; diff --git a/MangaMap/Views/loginAdminPage.xaml b/src/MangaMap/Views/loginAdminPage.xaml similarity index 100% rename from MangaMap/Views/loginAdminPage.xaml rename to src/MangaMap/Views/loginAdminPage.xaml diff --git a/MangaMap/Views/loginAdminPage.xaml.cs b/src/MangaMap/Views/loginAdminPage.xaml.cs similarity index 98% rename from MangaMap/Views/loginAdminPage.xaml.cs rename to src/MangaMap/Views/loginAdminPage.xaml.cs index bd4f519..32b56cf 100644 --- a/MangaMap/Views/loginAdminPage.xaml.cs +++ b/src/MangaMap/Views/loginAdminPage.xaml.cs @@ -1,8 +1,8 @@ namespace MangaMap.Views; using System.Text.RegularExpressions; using System.Threading.Tasks; -using MangaMap.Stub; -using MangaMap.Model; +using Stub; +using Models; /// /// Classe représentant la page de connexion administrateur de l'application. diff --git a/MangaMap/Views/loginPage.xaml b/src/MangaMap/Views/loginPage.xaml similarity index 100% rename from MangaMap/Views/loginPage.xaml rename to src/MangaMap/Views/loginPage.xaml diff --git a/MangaMap/Views/loginPage.xaml.cs b/src/MangaMap/Views/loginPage.xaml.cs similarity index 95% rename from MangaMap/Views/loginPage.xaml.cs rename to src/MangaMap/Views/loginPage.xaml.cs index ac3565c..91ab0fa 100644 --- a/MangaMap/Views/loginPage.xaml.cs +++ b/src/MangaMap/Views/loginPage.xaml.cs @@ -1,8 +1,8 @@ namespace MangaMap.Views; using System.Text.RegularExpressions; using System.Threading.Tasks; -using MangaMap.Stub; -using MangaMap.Model; +using Stub; +using Models; /// /// Classe représentant la page de connexion de l'application. diff --git a/MangaMap/Views/settingsPage.xaml b/src/MangaMap/Views/settingsPage.xaml similarity index 100% rename from MangaMap/Views/settingsPage.xaml rename to src/MangaMap/Views/settingsPage.xaml diff --git a/MangaMap/Views/settingsPage.xaml.cs b/src/MangaMap/Views/settingsPage.xaml.cs similarity index 96% rename from MangaMap/Views/settingsPage.xaml.cs rename to src/MangaMap/Views/settingsPage.xaml.cs index 6d007c7..bbbdc24 100644 --- a/MangaMap/Views/settingsPage.xaml.cs +++ b/src/MangaMap/Views/settingsPage.xaml.cs @@ -1,5 +1,5 @@ namespace MangaMap.Views; -using Model; +using Models; /// /// Classe représentant la page des paramètres de l'application. diff --git a/MangaMap/Views/signUpPage.xaml b/src/MangaMap/Views/signUpPage.xaml similarity index 100% rename from MangaMap/Views/signUpPage.xaml rename to src/MangaMap/Views/signUpPage.xaml diff --git a/MangaMap/Views/signUpPage.xaml.cs b/src/MangaMap/Views/signUpPage.xaml.cs similarity index 96% rename from MangaMap/Views/signUpPage.xaml.cs rename to src/MangaMap/Views/signUpPage.xaml.cs index 8c87c23..180473a 100644 --- a/MangaMap/Views/signUpPage.xaml.cs +++ b/src/MangaMap/Views/signUpPage.xaml.cs @@ -1,6 +1,6 @@ namespace MangaMap.Views; -using MangaMap.Model; +using Models; using System.Text.RegularExpressions; using static System.Runtime.InteropServices.JavaScript.JSType; diff --git a/MangaMap/Model/Admin.cs b/src/Models/Admin.cs similarity index 91% rename from MangaMap/Model/Admin.cs rename to src/Models/Admin.cs index a78ef54..56f0154 100644 --- a/MangaMap/Model/Admin.cs +++ b/src/Models/Admin.cs @@ -1,11 +1,10 @@ -using MangaMap.Views; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace MangaMap.Model +namespace Models { /// /// Représente un administrateur dans le système de gestion de listes d'anime. diff --git a/MangaMap/Stub/IPersistanceManager.cs b/src/Models/IPersistanceManager.cs similarity index 92% rename from MangaMap/Stub/IPersistanceManager.cs rename to src/Models/IPersistanceManager.cs index 784f4a6..54288d8 100644 --- a/MangaMap/Stub/IPersistanceManager.cs +++ b/src/Models/IPersistanceManager.cs @@ -4,9 +4,8 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; -using MangaMap.Model; -namespace MangaMap.Stub +namespace Models { /// /// Interface pour la gestion de la persistance des données. diff --git a/MangaMap/Model/Liste.cs b/src/Models/Liste.cs similarity index 79% rename from MangaMap/Model/Liste.cs rename to src/Models/Liste.cs index 81d04f8..6b532d2 100644 --- a/MangaMap/Model/Liste.cs +++ b/src/Models/Liste.cs @@ -1,17 +1,16 @@ using System; -using MangaMap.Model; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace MangaMap.Model +namespace Models { class Liste { public string Nom { get; private set; } public int NbAnime { get; private set; } - public Oeuvre[] AnimeListe { get; private set; } + public Oeuvre[]? AnimeListe { get; private set; } public Liste(string nom, int nbAnime) { diff --git a/MangaMap/Model/Manager.cs b/src/Models/Manager.cs similarity index 82% rename from MangaMap/Model/Manager.cs rename to src/Models/Manager.cs index 095f99c..e3b508f 100644 --- a/MangaMap/Model/Manager.cs +++ b/src/Models/Manager.cs @@ -6,9 +6,8 @@ using System.Linq; using System.Runtime.CompilerServices; using System.Text; using System.Threading.Tasks; -using MangaMap.Stub; -namespace MangaMap.Model +namespace Models { /// /// Classe responsable de la gestion globale de l'application de gestion de listes d'anime. @@ -50,7 +49,7 @@ namespace MangaMap.Model public event PropertyChangedEventHandler? PropertyChanged; - void OnPropertyChanged([CallerMemberName] string propertyName = null) + void OnPropertyChanged([CallerMemberName] string? propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); /// @@ -90,21 +89,6 @@ namespace MangaMap.Model isAdmin = false; } - /*public Utilisateur charger() - { - var donnees = Persistance.chargeDonne(); - foreach (var item in donnees.Item1) - { - Oeuvres.Add(item); - } - Utilisateurs.AddRange(donnees.Item2); - - // récupérer le premier utilisateur de la liste Utilisateurs : - Utilisateur utilisateurActuel = Utilisateurs.FirstOrDefault(); - - return utilisateurActuel; // Renvoyez l'utilisateur actuel - }*/ - /// /// Charge les données de l'application à partir du gestionnaire de persistance. /// diff --git a/src/Models/Models.csproj b/src/Models/Models.csproj new file mode 100644 index 0000000..4658cbf --- /dev/null +++ b/src/Models/Models.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + + diff --git a/MangaMap/Model/Oeuvre.cs b/src/Models/Oeuvre.cs similarity index 96% rename from MangaMap/Model/Oeuvre.cs rename to src/Models/Oeuvre.cs index 877adc6..f8295e9 100644 --- a/MangaMap/Model/Oeuvre.cs +++ b/src/Models/Oeuvre.cs @@ -8,7 +8,7 @@ using System.ComponentModel; using System.Xml.Linq; using System.Runtime.CompilerServices; -namespace MangaMap.Model +namespace Models { /// /// Représente une oeuvre dans le système de gestion de listes d'anime. @@ -18,7 +18,7 @@ namespace MangaMap.Model { public event PropertyChangedEventHandler? PropertyChanged; - void OnPropertyChanged([CallerMemberName] string propertyName = null) + void OnPropertyChanged([CallerMemberName] string? propertyName = null) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); /// @@ -106,6 +106,7 @@ namespace MangaMap.Model public Oeuvre(string nom, string type, string description, int nbEpisode, string affiche) { Nom = nom; + Genre = new List(); Type = type; Description = description; NbEpisodes = nbEpisode; diff --git a/MangaMap/Model/Personne.cs b/src/Models/Personne.cs similarity index 94% rename from MangaMap/Model/Personne.cs rename to src/Models/Personne.cs index 43b00d0..bc7c1da 100644 --- a/MangaMap/Model/Personne.cs +++ b/src/Models/Personne.cs @@ -5,7 +5,7 @@ using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; -namespace MangaMap.Model +namespace Models { /// /// Représente une personne dans le système de gestion de listes d'anime. @@ -17,19 +17,19 @@ namespace MangaMap.Model /// Obtient ou définit le mot de passe de la personne. /// [DataMember] - public string MotDePasse { get; set; } + public string? MotDePasse { get; set; } /// /// Obtient ou définit l'adresse e-mail de la personne. /// [DataMember] - public string Email { get; set; } + public string? Email { get; set; } /// /// Obtient ou définit le pseudo de la personne. /// [DataMember] - public string Pseudo { get; set; } + public string? Pseudo { get; set; } /// /// Modifie le mot de passe de la personne en vérifiant une confirmation. diff --git a/MangaMap/Model/Utilisateur.cs b/src/Models/Utilisateur.cs similarity index 94% rename from MangaMap/Model/Utilisateur.cs rename to src/Models/Utilisateur.cs index bc70eff..ca3883b 100644 --- a/MangaMap/Model/Utilisateur.cs +++ b/src/Models/Utilisateur.cs @@ -6,7 +6,7 @@ using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; -namespace MangaMap.Model +namespace Models { /// /// Représente un utilisateur de l'application de gestion de listes d'anime. @@ -18,13 +18,13 @@ namespace MangaMap.Model /// Obtient ou définit le nom de l'utilisateur. /// [DataMember] - public string nom { get; private set; } + public string? nom { get; private set; } /// /// Obtient ou définit le prénom de l'utilisateur. /// [DataMember] - public string prenom { get; private set; } + public string? prenom { get; private set; } /// /// Obtient ou définit l'âge de l'utilisateur. diff --git a/MangaMap/Stub/Stub.cs b/src/Stub/Stub.cs similarity index 93% rename from MangaMap/Stub/Stub.cs rename to src/Stub/Stub.cs index db3f7b3..e552f59 100644 --- a/MangaMap/Stub/Stub.cs +++ b/src/Stub/Stub.cs @@ -1,56 +1,56 @@ -using MangaMap.Model; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MangaMap.Stub -{ - /// - /// Classe de stub pour la gestion de la persistance des données. - /// - public class Stub : IPersistanceManager - { - /// - /// Charge un jeu de données en mémoire. - /// - /// Un tuple contenant la liste des oeuvres et la liste des utilisateurs. - public (ObservableCollection, List) chargeDonne() - { - ObservableCollection l1 = new ObservableCollection(); - List l2 = new List(); - - Utilisateur u1 = new Utilisateur("t", "Pseudo1", "t", "Jean", "Baptiste", 12); - Utilisateur u2 = new Utilisateur("s", "Pseudo2", "s", "Baptiste", "Jean", 12); - Utilisateur u3 = new Utilisateur("v", "Pseudo3", "v", "David", "Marc", 12); - List genres = new List(); - genres.Add("Action"); - genres.Add("Future"); - Oeuvre o1 = new Oeuvre("Evangelion", genres, "TV", "C'est une bonne série", 4, 150, "evangelion.jpg"); - Oeuvre o2 = new Oeuvre("[Oshi No Ko]", genres, "DVD", "A la fin il meurt", 2, 24, "oshinoko.png"); - Oeuvre o3 = new Oeuvre("One Piece", genres, "TV", "C'est la meilleur série du monde, regardez absolument", 2, 24, "onepiece.jpg"); - Oeuvre o4 = new Oeuvre("Naruto", genres, "DVD", "A la fin il meurt pas", 2, 24, "oshinoko.png"); - Oeuvre o5 = new Oeuvre("Vinland Saga", genres, "DVD", "A la fin il meurt peut-être", 2, 24, "oshinoko.png"); - Oeuvre o6 = new Oeuvre("Hell's Paradise", genres, "DVD", "A la fin j'espère il meurt pas", 2, 24, "oshinoko.png"); - - l1.Add(o1); l1.Add(o2); l1.Add(o3); l1.Add(o4); l1.Add(o5); l1.Add(o6); - l2.Add(u1); l2.Add(u2); l2.Add(u3); - - //u1.ListeOeuvreEnVisionnage.Add(o1); - - return (l1, l2); - } - - /// - /// Méthode non implémentée pour la sauvegarde des données. - /// - /// La liste des oeuvres à sauvegarder. - /// La liste des utilisateurs à sauvegarder. - public void sauvegarder(ObservableCollection o, List u) - { - throw new NotImplementedException(); - } - } -} +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Models; + +namespace Stub +{ + /// + /// Classe de stub pour la gestion de la persistance des données. + /// + public class Stub : IPersistanceManager + { + /// + /// Charge un jeu de données en mémoire. + /// + /// Un tuple contenant la liste des oeuvres et la liste des utilisateurs. + public (ObservableCollection, List) chargeDonne() + { + ObservableCollection l1 = new ObservableCollection(); + List l2 = new List(); + + Utilisateur u1 = new Utilisateur("t", "Pseudo1", "t", "Jean", "Baptiste", 12); + Utilisateur u2 = new Utilisateur("s", "Pseudo2", "s", "Baptiste", "Jean", 12); + Utilisateur u3 = new Utilisateur("v", "Pseudo3", "v", "David", "Marc", 12); + List genres = new List(); + genres.Add("Action"); + genres.Add("Future"); + Oeuvre o1 = new Oeuvre("Evangelion", genres, "TV", "C'est une bonne série", 4, 150, "evangelion.jpg"); + Oeuvre o2 = new Oeuvre("[Oshi No Ko]", genres, "DVD", "A la fin il meurt", 2, 24, "oshinoko.png"); + Oeuvre o3 = new Oeuvre("One Piece", genres, "TV", "C'est la meilleur série du monde, regardez absolument", 2, 24, "onepiece.jpg"); + Oeuvre o4 = new Oeuvre("Naruto", genres, "DVD", "A la fin il meurt pas", 2, 24, "oshinoko.png"); + Oeuvre o5 = new Oeuvre("Vinland Saga", genres, "DVD", "A la fin il meurt peut-être", 2, 24, "oshinoko.png"); + Oeuvre o6 = new Oeuvre("Hell's Paradise", genres, "DVD", "A la fin j'espère il meurt pas", 2, 24, "oshinoko.png"); + + l1.Add(o1); l1.Add(o2); l1.Add(o3); l1.Add(o4); l1.Add(o5); l1.Add(o6); + l2.Add(u1); l2.Add(u2); l2.Add(u3); + + //u1.ListeOeuvreEnVisionnage.Add(o1); + + return (l1, l2); + } + + /// + /// Méthode non implémentée pour la sauvegarde des données. + /// + /// La liste des oeuvres à sauvegarder. + /// La liste des utilisateurs à sauvegarder. + public void sauvegarder(ObservableCollection o, List u) + { + Console.WriteLine("Méthode sauvegarder() appelée."); + } + } +} diff --git a/src/Stub/Stub.csproj b/src/Stub/Stub.csproj new file mode 100644 index 0000000..e45d1d7 --- /dev/null +++ b/src/Stub/Stub.csproj @@ -0,0 +1,13 @@ + + + + net7.0 + enable + enable + + + + + + + diff --git a/src/UnitTests/UnitTestIPersistanceManager.cs b/src/UnitTests/UnitTestIPersistanceManager.cs new file mode 100644 index 0000000..1f28fbd --- /dev/null +++ b/src/UnitTests/UnitTestIPersistanceManager.cs @@ -0,0 +1,68 @@ +using Models; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Stub; + +namespace UnitTests +{ + public class UnitTestIPersistanceManager + { + [Fact] + public void ChargeDonne_ReturnsExpectedData() + { + // Arrange + var stub = new Stub.Stub(); + + // Act + var (oeuvres, utilisateurs) = stub.chargeDonne(); + + // Assert + Assert.NotNull(oeuvres); + Assert.NotNull(utilisateurs); + Assert.Equal(6, oeuvres.Count); + Assert.Equal(3, utilisateurs.Count); + + // Assert specific oeuvre properties + var evangelion = oeuvres[0]; + Assert.Equal("Evangelion", evangelion.Nom); + Assert.Collection(evangelion.Genre, + genre => Assert.Equal("Action", genre), + genre => Assert.Equal("Future", genre)); + Assert.Equal("TV", evangelion.Type); + Assert.Equal("C'est une bonne série", evangelion.Description); + Assert.Equal(4, evangelion.Note); + Assert.Equal(150, evangelion.NbEpisodes); + Assert.Equal("evangelion.jpg", evangelion.Affiche); + + // Assert specific utilisateur properties + var utilisateur = utilisateurs[0]; + Assert.Equal("t", utilisateur.Email); + Assert.Equal("Pseudo1", utilisateur.Pseudo); + Assert.Equal("t", utilisateur.MotDePasse); + Assert.Equal("Jean", utilisateur.nom); + Assert.Equal("Baptiste", utilisateur.prenom); + Assert.Equal(12, utilisateur.age); + } + + [Fact] + public void Sauvegarder_CallsConsoleWriteLine() + { + // Arrange + var stub = new Stub.Stub(); + var oeuvres = new ObservableCollection(); + var utilisateurs = new List(); + + // Act + stub.sauvegarder(oeuvres, utilisateurs); + + // Assert + // Since the implementation of Sauvegarder only calls Console.WriteLine, + // we can't directly test the functionality, but we can assert that the method was called + } + } +} + diff --git a/src/UnitTests/UnitTestOeuvre.cs b/src/UnitTests/UnitTestOeuvre.cs new file mode 100644 index 0000000..5449031 --- /dev/null +++ b/src/UnitTests/UnitTestOeuvre.cs @@ -0,0 +1,76 @@ +using Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace UnitTests +{ + public class UnitTestOeuvre + { + [Fact] + public void Oeuvre_Constructor_WithAllParameters_ShouldSetPropertiesCorrectly() + { + // Arrange + string nom = "[Oshi No Ko]"; + List genre = new List { "Action", "Drama", "Fantasy" }; + string type = "TV Series"; + string description = "A thrilling anime series."; + int note = 9; + int nbEpisodes = 25; + string affiche = "oshinoko.png"; + + // Act + Oeuvre oeuvre = new Oeuvre(nom, genre, type, description, note, nbEpisodes, affiche); + + // Assert + Assert.Equal(nom, oeuvre.Nom); + Assert.Equal(genre, oeuvre.Genre); + Assert.Equal(type, oeuvre.Type); + Assert.Equal(description, oeuvre.Description); + Assert.Equal(note, oeuvre.Note); + Assert.Equal(nbEpisodes, oeuvre.NbEpisodes); + Assert.Equal(affiche, oeuvre.Affiche); + } + + [Fact] + public void Oeuvre_Constructor_WithRequiredParameters_ShouldSetPropertiesCorrectly() + { + // Arrange + string nom = "One Piece"; + string type = "TV Series"; + string description = "An epic adventure."; + int nbEpisodes = 1000; + string affiche = "onepiece.jpg"; + + // Act + Oeuvre oeuvre = new Oeuvre(nom, type, description, nbEpisodes, affiche); + + // Assert + Assert.Equal(nom, oeuvre.Nom); + Assert.Empty(oeuvre.Genre); + Assert.Equal(type, oeuvre.Type); + Assert.Equal(description, oeuvre.Description); + Assert.Equal(0, oeuvre.Note); + Assert.Equal(nbEpisodes, oeuvre.NbEpisodes); + Assert.Equal(affiche, oeuvre.Affiche); + } + + [Fact] + public void AjouterEpisode_ShouldIncreaseNbEpisodesByGivenAmount() + { + // Arrange + Oeuvre oeuvre = new Oeuvre("Naruto", "TV Series", "A ninja's journey.", 220, "evangelion.jpg"); + int nbEpisodesToAdd = 50; + int expectedNbEpisodes = oeuvre.NbEpisodes + nbEpisodesToAdd; + + // Act + oeuvre.AjouterEpisode(nbEpisodesToAdd); + + // Assert + Assert.Equal(expectedNbEpisodes, oeuvre.NbEpisodes); + } + + } +} diff --git a/src/UnitTests/UnitTestUtilisateur.cs b/src/UnitTests/UnitTestUtilisateur.cs new file mode 100644 index 0000000..7f903a3 --- /dev/null +++ b/src/UnitTests/UnitTestUtilisateur.cs @@ -0,0 +1,57 @@ +using Models; + +namespace UnitTests +{ + public class UnitTestUtilisateur + { + [Fact] + public void TestUtilisateur() + { + // Arrange + Utilisateur utilisateur = new Utilisateur("test@test.com", "pseudo", "mdp", "John", "Doe", 30); + + // Act + utilisateur.SupprimerUtilisateur(); + + // Assert + Assert.Null(utilisateur.nom); + Assert.Null(utilisateur.prenom); + Assert.Equal(0, utilisateur.age); + } + + [Fact] + public void Utilisateur_DefaultConstructor_SetsPropertiesToDefaultValues() + { + // Arrange & Act + Utilisateur utilisateur = new Utilisateur(); + + // Assert + Assert.Null(utilisateur.nom); + Assert.Null(utilisateur.prenom); + Assert.Equal(0, utilisateur.age); + } + + [Fact] + public void Utilisateur_Constructor_SetsPropertiesCorrectly() + { + // Arrange + string email = "test@test.com"; + string pseudo = "pseudo"; + string mdp = "mdp"; + string nom = "John"; + string prenom = "Doe"; + int age = 30; + + // Act + Utilisateur utilisateur = new Utilisateur(email, pseudo, mdp, nom, prenom, age); + + // Assert + Assert.Equal(email, utilisateur.Email); + Assert.Equal(pseudo, utilisateur.Pseudo); + Assert.Equal(mdp, utilisateur.MotDePasse); + Assert.Equal(nom, utilisateur.nom); + Assert.Equal(prenom, utilisateur.prenom); + Assert.Equal(age, utilisateur.age); + } + } +} \ No newline at end of file diff --git a/src/UnitTests/UnitTests.csproj b/src/UnitTests/UnitTests.csproj new file mode 100644 index 0000000..ed48d31 --- /dev/null +++ b/src/UnitTests/UnitTests.csproj @@ -0,0 +1,29 @@ + + + + net7.0 + enable + enable + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + + diff --git a/src/UnitTests/Usings.cs b/src/UnitTests/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/src/UnitTests/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file