From e8176659d159cfd2d8b42cf86120714e1f06e686 Mon Sep 17 00:00:00 2001 From: Louis LABORIE Date: Wed, 3 May 2023 16:08:35 +0200 Subject: [PATCH 01/22] 3/05 Commit Tests Unitaires Attributes --- Sources/Linaris.sln | 10 ++++++-- Sources/Linaris/FooterPage.xaml.cs | 4 +-- Sources/TestUnitaires/TU_Album.cs | 28 ++++++++++++++++++++ Sources/TestUnitaires/TU_Artiste.cs | 20 +++++++++++++++ Sources/TestUnitaires/TU_CustomTitle.cs | 30 ++++++++++++++++++++++ Sources/TestUnitaires/TU_Playlist.cs | 26 +++++++++++++++++++ Sources/TestUnitaires/TU_Title.cs | 26 +++++++++++++++++++ Sources/TestUnitaires/TestUnitaires.csproj | 28 ++++++++++++++++++++ Sources/TestUnitaires/Usings.cs | 1 + 9 files changed, 169 insertions(+), 4 deletions(-) create mode 100644 Sources/TestUnitaires/TU_Album.cs create mode 100644 Sources/TestUnitaires/TU_Artiste.cs create mode 100644 Sources/TestUnitaires/TU_CustomTitle.cs create mode 100644 Sources/TestUnitaires/TU_Playlist.cs create mode 100644 Sources/TestUnitaires/TU_Title.cs create mode 100644 Sources/TestUnitaires/TestUnitaires.csproj create mode 100644 Sources/TestUnitaires/Usings.cs diff --git a/Sources/Linaris.sln b/Sources/Linaris.sln index 6f91fb4..e01685e 100644 --- a/Sources/Linaris.sln +++ b/Sources/Linaris.sln @@ -5,9 +5,11 @@ VisualStudioVersion = 17.0.31611.283 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Linaris", "Linaris\Linaris.csproj", "{9E6281F7-95F6-472C-B268-894CE377C8A9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Console", "Console\Console.csproj", "{BB50C1E3-5A9A-40AF-8CD7-55B41064290B}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Console", "Console\Console.csproj", "{BB50C1E3-5A9A-40AF-8CD7-55B41064290B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{AA1DB94B-8273-437F-A07A-BB1F5F0D278D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj", "{AA1DB94B-8273-437F-A07A-BB1F5F0D278D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestUnitaires", "TestUnitaires\TestUnitaires.csproj", "{8B0671CF-1302-4244-8837-916E632007E2}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -29,6 +31,10 @@ Global {AA1DB94B-8273-437F-A07A-BB1F5F0D278D}.Debug|Any CPU.Build.0 = Debug|Any CPU {AA1DB94B-8273-437F-A07A-BB1F5F0D278D}.Release|Any CPU.ActiveCfg = Release|Any CPU {AA1DB94B-8273-437F-A07A-BB1F5F0D278D}.Release|Any CPU.Build.0 = Release|Any CPU + {8B0671CF-1302-4244-8837-916E632007E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8B0671CF-1302-4244-8837-916E632007E2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8B0671CF-1302-4244-8837-916E632007E2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8B0671CF-1302-4244-8837-916E632007E2}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Sources/Linaris/FooterPage.xaml.cs b/Sources/Linaris/FooterPage.xaml.cs index adaa690..a36c9e9 100644 --- a/Sources/Linaris/FooterPage.xaml.cs +++ b/Sources/Linaris/FooterPage.xaml.cs @@ -19,9 +19,9 @@ public partial class FooterPage : ContentView // (s,a) = convention, s = sender, a = arguments, si appli fermée, on free tout outputDevice.PlaybackStopped += PlaybackStoppedHandler; - morceauEnCours = "D:\\Musique\\Création\\winter.mp3"; + /*morceauEnCours = "Resources/Musics/peaches.mp3"; audioFile = new AudioFileReader(morceauEnCours); - outputDevice.Init(audioFile); + outputDevice.Init(audioFile);*/ } public void PlayButton_Clicked(object sender, EventArgs e) diff --git a/Sources/TestUnitaires/TU_Album.cs b/Sources/TestUnitaires/TU_Album.cs new file mode 100644 index 0000000..13861be --- /dev/null +++ b/Sources/TestUnitaires/TU_Album.cs @@ -0,0 +1,28 @@ +using Model; +using Newtonsoft.Json.Linq; +using NuGet.Frameworks; + +namespace TestUnitaires +{ + public class TU_Album + { + [Theory] + [InlineData("Fenêtre sur Rue","album2.jpg","Un banger","Sortie : 2012")] + [InlineData("Adios Bahamas", "album. jpg", "Un banger", "Sortie : 2012")] + [InlineData(null, "album2.jpg", "Un banger", "Sortie : 2012")] + [InlineData("Dans La Légende", null, "Un banger", "Sortie : 2012")] + [InlineData("Dans La Légende","album1.jpg", null, "Sortie : 2012")] + [InlineData("Dans La Légende", "album1.jpg", "Un banger", null)] + [InlineData("Dans La Légende", "album1jpg", "Un banger", "Sortie : 2012")] + public void TU_Attributes(string nameAlbum, string url, string desc, string info) + { + Assert.True(nameAlbum != null && nameAlbum.Length < 75); + Assert.True(url != null && url.Contains('.')); + Assert.False(url.Contains(' ')); + Assert.True(desc != null && desc.Length < 500); + Assert.True(info != null && info.Length < 500); + + } + + } +} \ No newline at end of file diff --git a/Sources/TestUnitaires/TU_Artiste.cs b/Sources/TestUnitaires/TU_Artiste.cs new file mode 100644 index 0000000..cb12bbd --- /dev/null +++ b/Sources/TestUnitaires/TU_Artiste.cs @@ -0,0 +1,20 @@ +using Model; +using Newtonsoft.Json.Linq; +using NuGet.Frameworks; + +namespace TestUnitaires +{ + + public class TU_Artist + { + [Theory] + [InlineData("Hugo TSR")] + [InlineData(null)] + [InlineData("Hugo TSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR")] + public void TU_Attributes(string name) + { + Assert.True(name != null && name.Length < 75); + } + } + +} \ No newline at end of file diff --git a/Sources/TestUnitaires/TU_CustomTitle.cs b/Sources/TestUnitaires/TU_CustomTitle.cs new file mode 100644 index 0000000..03c096c --- /dev/null +++ b/Sources/TestUnitaires/TU_CustomTitle.cs @@ -0,0 +1,30 @@ +using Model; +using Newtonsoft.Json.Linq; +using NuGet.Frameworks; + +namespace TestUnitaires +{ + + public class TU_CustomTitle + { + [Theory] + [InlineData("Trajectoire","morceau1.png","Sortie : 2020", "Musique/test.mp3")] + [InlineData(null, "morceau1.png", "Sortie : 2020", "Musique/test.mp3")] + [InlineData("Trajectoire", null, "Sortie : 2020", "Musique/test.mp3")] + [InlineData("Trajectoire", "morceau1.png", null, "Musique/test.mp3")] + [InlineData("Trajectoire", "morceau1png", "Sortie : 2020", "Musique/test.mp3")] + [InlineData("Trajectoire", "morceau1. png", "Sortie : 2020", "Musique/test.mp3")] + [InlineData("Trajectoire", "morceau1.png", "Sortie : 2020", null)] + public void TU_Attributes(string name, string url, string info, string path) + { + CustomTitle ct = new CustomTitle(name, url, info, path); + Assert.True(ct.Name != null && ct.Name.Length < 75); + Assert.True(ct.ImageURL != null && ct.ImageURL.Contains('.')); + Assert.False(ct.ImageURL.Contains(' ')); + Assert.True(ct.Information != null && ct.Information.Length < 500); + Assert.True(ct.Path != null && ct.Path.Contains('.')); + Assert.False(ct.Path.Contains(' ')); + } + } + +} \ No newline at end of file diff --git a/Sources/TestUnitaires/TU_Playlist.cs b/Sources/TestUnitaires/TU_Playlist.cs new file mode 100644 index 0000000..f1ca0d0 --- /dev/null +++ b/Sources/TestUnitaires/TU_Playlist.cs @@ -0,0 +1,26 @@ +using Model; +using Newtonsoft.Json.Linq; +using NuGet.Frameworks; + +namespace TestUnitaires +{ + + public class TU_Playlist + { + [Theory] + [InlineData("Sons Soirées","red-sky.png","Contient les sons que je mets quand je suis en soirée.")] + [InlineData(null, "red-sky.png", "Contient les sons que je mets quand je suis en soirée.")] + [InlineData("Sons Soirées", null, "Contient les sons que je mets quand je suis en soirée.")] + [InlineData("Sons Soirées", "red-sky.png", null)] + [InlineData("Sons Soirées", "redskypng", "Contient les sons que je mets quand je suis en soirée.")] + [InlineData("Sons Soirées", "red-sky .png", "Contient les sons que je mets quand je suis en soirée.")] + public void TU_Attributes(string name, string url, string desc) + { + Assert.True(name != null && name.Length < 75); + Assert.True(url != null && url.Contains('.')); + Assert.False(url.Contains(' ')); + Assert.True(desc != null && desc.Length < 500); + } + } + +} \ No newline at end of file diff --git a/Sources/TestUnitaires/TU_Title.cs b/Sources/TestUnitaires/TU_Title.cs new file mode 100644 index 0000000..d5162c3 --- /dev/null +++ b/Sources/TestUnitaires/TU_Title.cs @@ -0,0 +1,26 @@ +using Model; +using Newtonsoft.Json.Linq; +using NuGet.Frameworks; + +namespace TestUnitaires +{ + + public class TU_Title + { + [Theory] + [InlineData("Trajectoire","morceau1.png","Sortie : 2020")] + [InlineData(null, "morceau1.png", "Sortie : 2020")] + [InlineData("Trajectoire", null, "Sortie : 2020")] + [InlineData("Trajectoire", "morceau1.png", null)] + [InlineData("Trajectoire", "morceau1png", "Sortie : 2020")] + [InlineData("Trajectoire", "morceau1. png", "Sortie : 2020")] + public void TU_Attributes(string name, string url, string info) + { + Assert.True(name != null && name.Length < 75); + Assert.True(url != null && url.Contains('.')); + Assert.False(url.Contains(' ')); + Assert.True(info != null && info.Length < 500); + } + } + +} \ No newline at end of file diff --git a/Sources/TestUnitaires/TestUnitaires.csproj b/Sources/TestUnitaires/TestUnitaires.csproj new file mode 100644 index 0000000..dedc487 --- /dev/null +++ b/Sources/TestUnitaires/TestUnitaires.csproj @@ -0,0 +1,28 @@ + + + + net7.0 + enable + enable + + false + + + + + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + + + diff --git a/Sources/TestUnitaires/Usings.cs b/Sources/TestUnitaires/Usings.cs new file mode 100644 index 0000000..8c927eb --- /dev/null +++ b/Sources/TestUnitaires/Usings.cs @@ -0,0 +1 @@ +global using Xunit; \ No newline at end of file From 097fb5c257a09c374ac1c878be8952e82f559c3c Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Wed, 3 May 2023 19:40:32 +0200 Subject: [PATCH 02/22] Enhance UT --- Sources/Console/Program.cs | 2 +- Sources/Linaris/FooterPage.xaml.cs | 2 +- Sources/Model/Album.cs | 11 ++++++++++- Sources/TestUnitaires/TU_Album.cs | 16 ++++++++-------- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Sources/Console/Program.cs b/Sources/Console/Program.cs index fb87e4e..4c93076 100644 --- a/Sources/Console/Program.cs +++ b/Sources/Console/Program.cs @@ -1,6 +1,6 @@ using Model; - +Console.WriteLine("---"); // See https://aka.ms/new-console-template for more information /*Album a = new Album("Adios Bahamas", "album1.jpg", "Népal"); diff --git a/Sources/Linaris/FooterPage.xaml.cs b/Sources/Linaris/FooterPage.xaml.cs index a36c9e9..8176381 100644 --- a/Sources/Linaris/FooterPage.xaml.cs +++ b/Sources/Linaris/FooterPage.xaml.cs @@ -9,7 +9,7 @@ public partial class FooterPage : ContentView System.Timers.Timer timer; bool changementManuel = true; bool closing = false; - string morceauEnCours; + // string morceauEnCours; public FooterPage() { diff --git a/Sources/Model/Album.cs b/Sources/Model/Album.cs index 7dab8f9..32a57eb 100644 --- a/Sources/Model/Album.cs +++ b/Sources/Model/Album.cs @@ -40,7 +40,16 @@ set { - if (value != null && value.Contains('.')) + if (value == null || !value.Contains('.')) + { + value = "none.png"; + imageURL = value; + } + if (value.Contains(' ')) + { + imageURL = value.Replace(' ', '\\'); + } + if (value.Contains('.')) { imageURL = value; } diff --git a/Sources/TestUnitaires/TU_Album.cs b/Sources/TestUnitaires/TU_Album.cs index 13861be..3c7966a 100644 --- a/Sources/TestUnitaires/TU_Album.cs +++ b/Sources/TestUnitaires/TU_Album.cs @@ -7,8 +7,8 @@ namespace TestUnitaires public class TU_Album { [Theory] - [InlineData("Fenêtre sur Rue","album2.jpg","Un banger","Sortie : 2012")] - [InlineData("Adios Bahamas", "album. jpg", "Un banger", "Sortie : 2012")] + [InlineData("Fenêtre sur Rue","album2. jpg","Un banger","Sortie : 2012")] + [InlineData("Adios Bahamas", "album.jpg", "Un banger", "Sortie : 2012")] [InlineData(null, "album2.jpg", "Un banger", "Sortie : 2012")] [InlineData("Dans La Légende", null, "Un banger", "Sortie : 2012")] [InlineData("Dans La Légende","album1.jpg", null, "Sortie : 2012")] @@ -16,12 +16,12 @@ namespace TestUnitaires [InlineData("Dans La Légende", "album1jpg", "Un banger", "Sortie : 2012")] public void TU_Attributes(string nameAlbum, string url, string desc, string info) { - Assert.True(nameAlbum != null && nameAlbum.Length < 75); - Assert.True(url != null && url.Contains('.')); - Assert.False(url.Contains(' ')); - Assert.True(desc != null && desc.Length < 500); - Assert.True(info != null && info.Length < 500); - + Album album = new Album(nameAlbum, url, new Artiste("test"), desc, info); + Assert.True(album.Name != null && album.Name.Length < 75); + Assert.True(album.ImageURL != null && album.ImageURL.Contains('.')); + Assert.False(album.ImageURL.Contains(' ')); + Assert.True(album.Description != null && album.Description.Length < 500); + Assert.True(album.Information != null && album.Information.Length < 500); } } From a774e0c904ea726230db9d4877a3664d033cedac Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Fri, 5 May 2023 13:30:39 +0200 Subject: [PATCH 03/22] Add .drone.yml and activated drone --- .drone.yml | 23 +++++++++++++++++++++++ Sources/Linaris/Linaris.csproj | 6 ++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .drone.yml diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..0696232 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,23 @@ +kind: pipeline +type: docker +name: CI_Linaris_pipeline + +trigger: + event: + - push + +steps: + - name: build + image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest + commands: + - cd Sources/ + - dotnet restore Linaris.sln + - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 + - dotnet publish MyMauiApp/MyMauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk + - name: tests + image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest + commands: + - cd Sources/ + - dotnet restore Linaris.sln + - dotnet test Linaris.sln --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 + depends_on: [build] diff --git a/Sources/Linaris/Linaris.csproj b/Sources/Linaris/Linaris.csproj index bbcc06b..787cfe8 100644 --- a/Sources/Linaris/Linaris.csproj +++ b/Sources/Linaris/Linaris.csproj @@ -1,8 +1,10 @@  - net7.0-android;net7.0-ios;net7.0-maccatalyst - $(TargetFrameworks);net7.0-windows10.0.19041.0 + net7.0-android + $(TargetFrameworks);net7.0-windows10.0.19041.0 + $(TargetFrameworks);net7.0-ios + $(TargetFrameworks);net7.0-maccatalyst Exe From 38ccaf6a270076535367948e8f863cfc067152cb Mon Sep 17 00:00:00 2001 From: Louis LABORIE Date: Sat, 6 May 2023 09:09:58 +0200 Subject: [PATCH 04/22] =?UTF-8?q?Mise=20=C3=A0=20jour=20de=20'Sources/Conn?= =?UTF-8?q?sole/Program.cs'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add line to build --- Sources/Connsole/Program.cs | 51 +++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/Sources/Connsole/Program.cs b/Sources/Connsole/Program.cs index fb87e4e..e568c3b 100644 --- a/Sources/Connsole/Program.cs +++ b/Sources/Connsole/Program.cs @@ -1,25 +1,26 @@ -using Model; - - -// See https://aka.ms/new-console-template for more information - -/*Album a = new Album("Adios Bahamas", "album1.jpg", "Népal"); -Album a1 = new Album("Fenêtre sur Rue", "album3.jpg", "HugoTSR"); -Album a2 = new Album("Dans la Légende", "album8.jpg", "PNL"); - -List lst = new List { a1, a2, a }; - -foreach (Album album in lst) -{ - Console.WriteLine($"Nom de l'album : " + album.Nom); - - Console.WriteLine($"Nom du fichier : " + album.File_Name); - - Console.WriteLine($"Artiste : " + album.Artiste); - - Console.WriteLine($"-------------------------"); -}*/ - - - - +using Model; + +Console.WriteLine("---"); + +// See https://aka.ms/new-console-template for more information + +/*Album a = new Album("Adios Bahamas", "album1.jpg", "Népal"); +Album a1 = new Album("Fenêtre sur Rue", "album3.jpg", "HugoTSR"); +Album a2 = new Album("Dans la Légende", "album8.jpg", "PNL"); + +List lst = new List { a1, a2, a }; + +foreach (Album album in lst) +{ + Console.WriteLine($"Nom de l'album : " + album.Nom); + + Console.WriteLine($"Nom du fichier : " + album.File_Name); + + Console.WriteLine($"Artiste : " + album.Artiste); + + Console.WriteLine($"-------------------------"); +}*/ + + + + From b238fadee6bf21984ec715f4952251e491efafc1 Mon Sep 17 00:00:00 2001 From: Louis LABORIE Date: Sat, 6 May 2023 09:25:59 +0200 Subject: [PATCH 05/22] Update project name for Drone --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index 0696232..a6cb69c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -13,7 +13,7 @@ steps: - cd Sources/ - dotnet restore Linaris.sln - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 - - dotnet publish MyMauiApp/MyMauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk + - dotnet publish Linaris/Linaris.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk - name: tests image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest commands: From caf7a23ae231405a2c0331211449d55795a15293 Mon Sep 17 00:00:00 2001 From: Louis LABORIE Date: Sat, 6 May 2023 09:42:25 +0200 Subject: [PATCH 06/22] Add Artist's methods UT ; Trying to trigger events on buttons --- Sources/Linaris/MainPage.xaml.cs | 11 ++++++++++- Sources/TestUnitaires/TU_Artiste.cs | 15 +++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/Sources/Linaris/MainPage.xaml.cs b/Sources/Linaris/MainPage.xaml.cs index 9e8598f..de3a24b 100644 --- a/Sources/Linaris/MainPage.xaml.cs +++ b/Sources/Linaris/MainPage.xaml.cs @@ -7,7 +7,8 @@ public partial class MainPage : ContentPage public MainPage() { InitializeComponent(); - } + + } /*private void OnCounterClicked(object sender, EventArgs e) { @@ -20,5 +21,13 @@ public partial class MainPage : ContentPage SemanticScreenReader.Announce(CounterBtn.Text); }*/ + + /*async public void Go_Home() + { + await Navigation.PushAsync(new MainPage()); + + }*/ + + } diff --git a/Sources/TestUnitaires/TU_Artiste.cs b/Sources/TestUnitaires/TU_Artiste.cs index cb12bbd..4b24884 100644 --- a/Sources/TestUnitaires/TU_Artiste.cs +++ b/Sources/TestUnitaires/TU_Artiste.cs @@ -15,6 +15,21 @@ namespace TestUnitaires { Assert.True(name != null && name.Length < 75); } + + [Theory] + [InlineData("Hugo TSR")] + [InlineData(null)] + [InlineData("Hugo TSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR")] + public void TU_Methods(string name) + { + Artiste a = new Artiste(name); + Album a1 = new Album("Fenêtre sur Rue", "album2. jpg", a, "Un banger", "Sortie : 2012"); + List verif = new List(); + verif.Add(a1); + a.AddAlbum(a1); + Assert.True(a.Albums == verif); + + } } } \ No newline at end of file From d2886147316db3b332ec07cfd8f4629ccc1514b0 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Sat, 6 May 2023 10:57:16 +0200 Subject: [PATCH 07/22] Activate SonarQube --- .drone.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.drone.yml b/.drone.yml index a6cb69c..1620d40 100644 --- a/.drone.yml +++ b/.drone.yml @@ -21,3 +21,21 @@ steps: - dotnet restore Linaris.sln - dotnet test Linaris.sln --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 depends_on: [build] + - name: code-inspection + image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7-maui + secrets: [ SECRET_SONAR_LOGIN ] + environment: + sonar_host: https://codefirst.iut.uca.fr/sonar/ + sonar_token: + from_secret: SECRET_SONAR_LOGIN + project_key: Linaris_LEMAIRE_LABORIE + coverage_exclusions: "Tests/**" + commands: + - cd Sources/ + - dotnet restore Linaris.sln + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 + - dotnet test Linaris.sln --logger trx --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + - dotnet publish MauiApp/MauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk + - dotnet sonarscanner end /d:sonar.login=$${sonar_token} From c3e75af248bfb8f92635ae6273f92a48f96d81e3 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Sat, 6 May 2023 11:00:52 +0200 Subject: [PATCH 08/22] Fix dependencies --- .drone.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.drone.yml b/.drone.yml index 1620d40..fb038e6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,3 +39,4 @@ steps: - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - dotnet publish MauiApp/MauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk - dotnet sonarscanner end /d:sonar.login=$${sonar_token} + depends on: [tests] From eabc98da0a60863d25332bd5dc0ad7f86bc6702f Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Sat, 6 May 2023 11:08:16 +0200 Subject: [PATCH 09/22] Comment lines waiting for tests merge --- .drone.yml | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.drone.yml b/.drone.yml index fb038e6..172afe1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,29 +14,29 @@ steps: - dotnet restore Linaris.sln - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 - dotnet publish Linaris/Linaris.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk - - name: tests - image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest - commands: - - cd Sources/ - - dotnet restore Linaris.sln - - dotnet test Linaris.sln --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 - depends_on: [build] - - name: code-inspection - image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7-maui - secrets: [ SECRET_SONAR_LOGIN ] - environment: - sonar_host: https://codefirst.iut.uca.fr/sonar/ - sonar_token: - from_secret: SECRET_SONAR_LOGIN - project_key: Linaris_LEMAIRE_LABORIE - coverage_exclusions: "Tests/**" - commands: - - cd Sources/ - - dotnet restore Linaris.sln - - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} - - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 - - dotnet test Linaris.sln --logger trx --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - - dotnet publish MauiApp/MauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk - - dotnet sonarscanner end /d:sonar.login=$${sonar_token} - depends on: [tests] +# - name: tests +# image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest +# commands: +# - cd Sources/ +# - dotnet restore Linaris.sln +# - dotnet test Linaris.sln --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 +# depends_on: [build] +# - name: code-inspection +# image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7-maui +# secrets: [ SECRET_SONAR_LOGIN ] +# environment: +# sonar_host: https://codefirst.iut.uca.fr/sonar/ +# sonar_token: +# from_secret: SECRET_SONAR_LOGIN +# project_key: Linaris_LEMAIRE_LABORIE +# coverage_exclusions: "Tests/**" +# commands: +# - cd Sources/ +# - dotnet restore Linaris.sln +# - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} +# - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 +# - dotnet test Linaris.sln --logger trx --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" +# - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" +# - dotnet publish MauiApp/MauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk +# - dotnet sonarscanner end /d:sonar.login=$${sonar_token} +# depends on: [tests] From 48fc84b337c62a0722ae3f585e32d4b466b46db6 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Mon, 8 May 2023 20:27:10 +0200 Subject: [PATCH 10/22] Uncomment lines to test drone and sonar --- .drone.yml | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/.drone.yml b/.drone.yml index 172afe1..fb038e6 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,29 +14,29 @@ steps: - dotnet restore Linaris.sln - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 - dotnet publish Linaris/Linaris.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk -# - name: tests -# image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest -# commands: -# - cd Sources/ -# - dotnet restore Linaris.sln -# - dotnet test Linaris.sln --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 -# depends_on: [build] -# - name: code-inspection -# image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7-maui -# secrets: [ SECRET_SONAR_LOGIN ] -# environment: -# sonar_host: https://codefirst.iut.uca.fr/sonar/ -# sonar_token: -# from_secret: SECRET_SONAR_LOGIN -# project_key: Linaris_LEMAIRE_LABORIE -# coverage_exclusions: "Tests/**" -# commands: -# - cd Sources/ -# - dotnet restore Linaris.sln -# - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} -# - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 -# - dotnet test Linaris.sln --logger trx --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" -# - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" -# - dotnet publish MauiApp/MauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk -# - dotnet sonarscanner end /d:sonar.login=$${sonar_token} -# depends on: [tests] + - name: tests + image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dotnet7-maui:latest + commands: + - cd Sources/ + - dotnet restore Linaris.sln + - dotnet test Linaris.sln --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 + depends_on: [build] + - name: code-inspection + image: hub.codefirst.iut.uca.fr/marc.chevaldonne/codefirst-dronesonarplugin-dotnet7-maui + secrets: [ SECRET_SONAR_LOGIN ] + environment: + sonar_host: https://codefirst.iut.uca.fr/sonar/ + sonar_token: + from_secret: SECRET_SONAR_LOGIN + project_key: Linaris_LEMAIRE_LABORIE + coverage_exclusions: "Tests/**" + commands: + - cd Sources/ + - dotnet restore Linaris.sln + - dotnet sonarscanner begin /k:$${project_key} /d:sonar.host.url=$${sonar_host} /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" /d:sonar.coverage.exclusions=$${coverage_exclusions} /d:sonar.login=$${sonar_token} + - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 + - dotnet test Linaris.sln --logger trx --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" + - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + - dotnet publish MauiApp/MauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk + - dotnet sonarscanner end /d:sonar.login=$${sonar_token} + depends on: [tests] From cab27bc4d53290c10bf3346d2161c5c17ac2a8f7 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Mon, 8 May 2023 20:29:40 +0200 Subject: [PATCH 11/22] Fix dependency issue --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index fb038e6..cd7bf0d 100644 --- a/.drone.yml +++ b/.drone.yml @@ -39,4 +39,4 @@ steps: - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - dotnet publish MauiApp/MauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk - dotnet sonarscanner end /d:sonar.login=$${sonar_token} - depends on: [tests] + depends_on: [tests] From 45ceaa5a5a32cfc59dc063c63acaebec2f79c830 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE Date: Mon, 8 May 2023 21:07:08 +0200 Subject: [PATCH 12/22] Fix Unit tests --- Sources/Model/Album.cs | 30 +++++++++++++----------- Sources/Model/Artiste.cs | 13 ++++++++--- Sources/Model/CustomTitle.cs | 6 +++-- Sources/Model/Playlist.cs | 34 ++++++++++++++++++++-------- Sources/Model/Title.cs | 17 ++++++++++---- Sources/TestUnitaires/TU_Artiste.cs | 10 ++++---- Sources/TestUnitaires/TU_Playlist.cs | 9 ++++---- Sources/TestUnitaires/TU_Title.cs | 9 ++++---- 8 files changed, 85 insertions(+), 43 deletions(-) diff --git a/Sources/Model/Album.cs b/Sources/Model/Album.cs index 32a57eb..323ddb0 100644 --- a/Sources/Model/Album.cs +++ b/Sources/Model/Album.cs @@ -15,7 +15,7 @@ } } - private string name; + private string name = "Unknown"; public string Description { @@ -30,9 +30,17 @@ } } - private string description; + private string description = ""; - public IEnumerable Titles { get; set; } + public IEnumerable<Title> Titles + { + get + { + return titles; + } + } + + private List<Title> titles = new List<Title>(); public string ImageURL { @@ -47,16 +55,16 @@ } if (value.Contains(' ')) { - imageURL = value.Replace(' ', '\\'); + imageURL = value.Replace(' ', '_'); } - if (value.Contains('.')) + else if (value.Contains('.')) { imageURL = value; } } } - private string imageURL; + private string imageURL = "unknown.png"; public Artiste Artist { get; set; } @@ -73,7 +81,7 @@ } } - private string information; + private string information = ""; public Album(string name, string file_Name, Artiste artist, string description, string information) { @@ -82,20 +90,16 @@ Artist = artist; Description = description; Information = information; - Titles = new List<Title>(); } public void AddTitle(Title title) { - Titles.Prepend(title); + titles.Add(title); } public void RemoveTitle(Title title) { - foreach(var item in Titles) - { - Titles = Titles.Where(item => item != title).ToList(); - } + titles.Remove(title); } } diff --git a/Sources/Model/Artiste.cs b/Sources/Model/Artiste.cs index bcab081..ab29d82 100644 --- a/Sources/Model/Artiste.cs +++ b/Sources/Model/Artiste.cs @@ -17,16 +17,23 @@ public class Artiste private string name = "Unknown"; - public IEnumerable<Album> Albums { get; set; } + public IEnumerable<Album> Albums + { + get + { + return albums.ToList(); + } + } + + private List<Album> albums = new List<Album>(); public Artiste(string name) { Name = name; - Albums = new List<Album>(); } public void AddAlbum(Album album) { - Albums.Prepend(album); + albums.Add(album); } } diff --git a/Sources/Model/CustomTitle.cs b/Sources/Model/CustomTitle.cs index 9b41237..e3639c5 100644 --- a/Sources/Model/CustomTitle.cs +++ b/Sources/Model/CustomTitle.cs @@ -1,4 +1,6 @@ -namespace Model; +using System.Runtime.CompilerServices; + +namespace Model; public class CustomTitle : Title { @@ -15,7 +17,7 @@ public class CustomTitle : Title { } } - private string path; + private string path = "unknown.mp3"; public CustomTitle(string name, string imageURL, string information, string path) : base(name, imageURL, information) { diff --git a/Sources/Model/Playlist.cs b/Sources/Model/Playlist.cs index 97d3e43..a3882d0 100644 --- a/Sources/Model/Playlist.cs +++ b/Sources/Model/Playlist.cs @@ -15,7 +15,7 @@ public class Playlist } } - private string name; + private string name = "unknown"; public string Description { @@ -30,9 +30,17 @@ public class Playlist } } - private string description; + private string description = ""; - public IEnumerable<Title> Morceaux { get; set; } + public IEnumerable<Title> Titles + { + get + { + return titles; + } + } + + private List<Title> titles = new List<Title>(); public string ImageURL { @@ -40,31 +48,39 @@ public class Playlist set { - if (value != null && value.Contains('.')) + if (value == null || !value.Contains('.')) + { + value = "none.png"; + imageURL = value; + } + if (value.Contains(' ')) + { + imageURL = value.Replace(' ', '_'); + } + else if (value.Contains('.')) { imageURL = value; } } } - private string imageURL; + private string imageURL = "none.png"; public Playlist(string nom, string description, string imageURL) { Name = nom; Description = description; - Morceaux = new List<Title>(); - this.imageURL = imageURL; + ImageURL = imageURL; } public void AddTitle(Title morceau) { - Morceaux.Prepend(morceau); + titles.Add(morceau); } public void RemoveTitle(Title morceau) { - Morceaux.ToList().Remove(morceau); + titles.Remove(morceau); } } diff --git a/Sources/Model/Title.cs b/Sources/Model/Title.cs index 1d985e8..b7782d2 100644 --- a/Sources/Model/Title.cs +++ b/Sources/Model/Title.cs @@ -15,7 +15,7 @@ } } - private string name; + private string name = "unknown"; public string ImageURL { @@ -23,14 +23,23 @@ set { - if (value != null && value.Contains('.')) + if (value == null || !value.Contains('.')) + { + value = "none.png"; + imageURL = value; + } + if (value.Contains(' ')) + { + imageURL = value.Replace(' ', '_'); + } + else if (value.Contains('.')) { imageURL = value; } } } - private string imageURL; + private string imageURL = "unknown.png"; public string Information { @@ -45,7 +54,7 @@ } } - private string information; + private string information = ""; public Title(string nom, string file_Name, string informations) { diff --git a/Sources/TestUnitaires/TU_Artiste.cs b/Sources/TestUnitaires/TU_Artiste.cs index 4b24884..6d29157 100644 --- a/Sources/TestUnitaires/TU_Artiste.cs +++ b/Sources/TestUnitaires/TU_Artiste.cs @@ -13,7 +13,8 @@ namespace TestUnitaires [InlineData("Hugo TSRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR")] public void TU_Attributes(string name) { - Assert.True(name != null && name.Length < 75); + Artiste a = new Artiste(name); + Assert.True(a.Name != null && a.Name.Length < 75); } [Theory] @@ -23,11 +24,12 @@ namespace TestUnitaires public void TU_Methods(string name) { Artiste a = new Artiste(name); + Album a1 = new Album("Fenêtre sur Rue", "album2. jpg", a, "Un banger", "Sortie : 2012"); - List<Album> verif = new List<Album>(); - verif.Add(a1); + a.AddAlbum(a1); - Assert.True(a.Albums == verif); + + Assert.Contains(a1, a.Albums); } } diff --git a/Sources/TestUnitaires/TU_Playlist.cs b/Sources/TestUnitaires/TU_Playlist.cs index f1ca0d0..6a4d78c 100644 --- a/Sources/TestUnitaires/TU_Playlist.cs +++ b/Sources/TestUnitaires/TU_Playlist.cs @@ -16,10 +16,11 @@ namespace TestUnitaires [InlineData("Sons Soirées", "red-sky .png", "Contient les sons que je mets quand je suis en soirée.")] public void TU_Attributes(string name, string url, string desc) { - Assert.True(name != null && name.Length < 75); - Assert.True(url != null && url.Contains('.')); - Assert.False(url.Contains(' ')); - Assert.True(desc != null && desc.Length < 500); + Playlist p = new Playlist(name, desc, url); + Assert.True(p.Name != null && p.Name.Length < 75); + Assert.True(p.ImageURL != null && p.ImageURL.Contains('.')); + Assert.False(p.ImageURL.Contains(' ')); + Assert.True(p.Description != null && p.Description.Length < 500); } } diff --git a/Sources/TestUnitaires/TU_Title.cs b/Sources/TestUnitaires/TU_Title.cs index d5162c3..c22de93 100644 --- a/Sources/TestUnitaires/TU_Title.cs +++ b/Sources/TestUnitaires/TU_Title.cs @@ -16,10 +16,11 @@ namespace TestUnitaires [InlineData("Trajectoire", "morceau1. png", "Sortie : 2020")] public void TU_Attributes(string name, string url, string info) { - Assert.True(name != null && name.Length < 75); - Assert.True(url != null && url.Contains('.')); - Assert.False(url.Contains(' ')); - Assert.True(info != null && info.Length < 500); + Title t = new Title(name, url, info); + Assert.True(t.Name != null && t.Name.Length < 75); + Assert.True(t.ImageURL != null && t.ImageURL.Contains('.')); + Assert.False(t.ImageURL.Contains(' ')); + Assert.True(t.Information != null && t.Information.Length < 500); } } From e4d3f3f3fea80cf68fa1e30a5be7152fa092377a Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE <corentin.lemaire@etu.uca.fr> Date: Mon, 8 May 2023 21:13:42 +0200 Subject: [PATCH 13/22] Fix publish issue --- .drone.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.drone.yml b/.drone.yml index cd7bf0d..c6dcbe4 100644 --- a/.drone.yml +++ b/.drone.yml @@ -37,6 +37,6 @@ steps: - dotnet build Linaris.sln -c Release --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 - dotnet test Linaris.sln --logger trx --no-restore /p:AndroidSdkDirectory=$ANDROID_SDK_ROOT -property:Aapt2ToolPath=$ANDROID_SDK_ROOT/build-tools/33.0.0 /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura --collect "XPlat Code Coverage" - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" - - dotnet publish MauiApp/MauiApp.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk + - dotnet publish Linaris/Linaris.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/release -f:net7.0-android /p:AndroidSdkDirectory=/usr/lib/android-sdk - dotnet sonarscanner end /d:sonar.login=$${sonar_token} depends_on: [tests] From 377b9eb129255a443bde6738ac6463d317e584cd Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE <corentin.lemaire@etu.uca.fr> Date: Mon, 8 May 2023 21:26:53 +0200 Subject: [PATCH 14/22] Fix future unit tests --- Sources/Model/InfoTitle.cs | 20 ++++++++++------- Sources/Model/Manager.cs | 46 +++++++++++++++++++++++++++----------- 2 files changed, 45 insertions(+), 21 deletions(-) diff --git a/Sources/Model/InfoTitle.cs b/Sources/Model/InfoTitle.cs index bb9eb4d..eb4e688 100644 --- a/Sources/Model/InfoTitle.cs +++ b/Sources/Model/InfoTitle.cs @@ -17,9 +17,17 @@ public class InfoTitle : Title } } - private string description; + private string description = ""; - public IEnumerable<Artiste> Feat { get; set; } + public IEnumerable<Artiste> Feat + { + get + { + return feat; + } + } + + private List<Artiste> feat = new List<Artiste>(); public Genre Genre { get; set; } @@ -28,19 +36,15 @@ public class InfoTitle : Title Artiste = artist; Description = description; Genre = genre; - Feat = new List<Artiste>(); } public void AddFeat(Artiste artist) { - Feat.Prepend(artist); + feat.Add(artist); } public void RemoveFeat(Artiste artiste) { - foreach (var item in Feat) - { - Feat = Feat.Where(item => item != artiste).ToList(); - } + feat.Remove(artiste); } } diff --git a/Sources/Model/Manager.cs b/Sources/Model/Manager.cs index 9de8d13..4f8e51b 100644 --- a/Sources/Model/Manager.cs +++ b/Sources/Model/Manager.cs @@ -4,48 +4,68 @@ public class Manager { public IDataManager DataManager { get; set; } - public IEnumerable<Album> Albums; + public IEnumerable<Album> Albums + { + get + { + return albums; + } + } + + private List<Album> albums = new List<Album>(); - public IEnumerable<Title> Titles; + public IEnumerable<Title> Titles + { + get + { + return titles; + } + } + + private List<Title> titles = new List<Title>(); + + public IEnumerable<Playlist> Playlists + { + get + { + return playlists; + } + } - public IEnumerable<Playlist> Playlists; + private List<Playlist> playlists = new List<Playlist>(); public Manager() { DataManager = new Stub(); - // Albums = DataManager.GetAlbum(); - Albums = new List<Album>(); - Titles = new List<Title>(); - Playlists = new List<Playlist>(); } public void AddAlbum(Album album) { - Albums.Prepend(album); + albums.Add(album); } public void AddTitle(Title title) { - Titles.Prepend(title); + titles.Add(title); } public void AddPlaylist(Playlist playlist) { - Playlists.Prepend(playlist); + playlists.Add(playlist); } public void RemoveAlbum(Album album) { - Albums.ToList().Remove(album); + albums.Remove(album); } public void RemoveTitle(Title title) { - Titles.ToList().Remove(title); + titles.Remove(title); } public void RemovePlaylist(Playlist playlist) { - Playlists.ToList().Remove(playlist); + playlists.Remove(playlist); } } From dbdd5a6de758b78fa3c0fc2a5d7d09826ea11578 Mon Sep 17 00:00:00 2001 From: Louis LABORIE <lolaborie> Date: Wed, 10 May 2023 16:11:37 +0200 Subject: [PATCH 15/22] Add UT for classes's methods --- Sources/TestUnitaires/TU_Album.cs | 18 ++++++++++++++++++ Sources/TestUnitaires/TU_CustomTitle.cs | 1 + Sources/TestUnitaires/TU_Playlist.cs | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/Sources/TestUnitaires/TU_Album.cs b/Sources/TestUnitaires/TU_Album.cs index 3c7966a..3c5453f 100644 --- a/Sources/TestUnitaires/TU_Album.cs +++ b/Sources/TestUnitaires/TU_Album.cs @@ -24,5 +24,23 @@ namespace TestUnitaires Assert.True(album.Information != null && album.Information.Length < 500); } + [Theory] + [InlineData("Fenêtre sur Rue", "album2. jpg", "Un banger", "Sortie : 2012")] + [InlineData("Adios Bahamas", "album.jpg", "Un banger", "Sortie : 2012")] + [InlineData(null, "album2.jpg", "Un banger", "Sortie : 2012")] + [InlineData("Dans La Légende", null, "Un banger", "Sortie : 2012")] + [InlineData("Dans La Légende", "album1.jpg", null, "Sortie : 2012")] + [InlineData("Dans La Légende", "album1.jpg", "Un banger", null)] + [InlineData("Dans La Légende", "album1jpg", "Un banger", "Sortie : 2012")] + public void TU_Methods(string nameAlbum, string url, string desc, string info) + { + Album album = new Album(nameAlbum, url, new Artiste("test"), desc, info); + Title t = new Title("Débitage", "test. mp3", "Banger"); + album.AddTitle(t); + Assert.Contains(t, album.Titles); + album.RemoveTitle(t); + Assert.DoesNotContain(t, album.Titles); + } + } } \ No newline at end of file diff --git a/Sources/TestUnitaires/TU_CustomTitle.cs b/Sources/TestUnitaires/TU_CustomTitle.cs index 03c096c..5599ad1 100644 --- a/Sources/TestUnitaires/TU_CustomTitle.cs +++ b/Sources/TestUnitaires/TU_CustomTitle.cs @@ -25,6 +25,7 @@ namespace TestUnitaires Assert.True(ct.Path != null && ct.Path.Contains('.')); Assert.False(ct.Path.Contains(' ')); } + } } \ No newline at end of file diff --git a/Sources/TestUnitaires/TU_Playlist.cs b/Sources/TestUnitaires/TU_Playlist.cs index 6a4d78c..4380ab3 100644 --- a/Sources/TestUnitaires/TU_Playlist.cs +++ b/Sources/TestUnitaires/TU_Playlist.cs @@ -22,6 +22,24 @@ namespace TestUnitaires Assert.False(p.ImageURL.Contains(' ')); Assert.True(p.Description != null && p.Description.Length < 500); } + [Theory] + [InlineData("Sons Soirées", "red-sky.png", "Contient les sons que je mets quand je suis en soirée.")] + [InlineData(null, "red-sky.png", "Contient les sons que je mets quand je suis en soirée.")] + [InlineData("Sons Soirées", null, "Contient les sons que je mets quand je suis en soirée.")] + [InlineData("Sons Soirées", "red-sky.png", null)] + [InlineData("Sons Soirées", "redskypng", "Contient les sons que je mets quand je suis en soirée.")] + [InlineData("Sons Soirées", "red-sky .png", "Contient les sons que je mets quand je suis en soirée.")] + public void TU_Methods(string name, string url, string desc) + { + Playlist p = new Playlist(name, desc, url); + Title t = new Title("Débitage","test. mp3","Banger"); + p.AddTitle(t); + Assert.Contains(t,p.Titles); + p.RemoveTitle(t); + Assert.DoesNotContain(t,p.Titles); + + + } } } \ No newline at end of file From 835a7a54b2125638930ec2506575aa8157c9885b Mon Sep 17 00:00:00 2001 From: Louis LABORIE <lolaborie> Date: Wed, 10 May 2023 17:22:43 +0200 Subject: [PATCH 16/22] Add InfoTitle's UT --- Sources/TestUnitaires/TU_InfoTitle.cs | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 Sources/TestUnitaires/TU_InfoTitle.cs diff --git a/Sources/TestUnitaires/TU_InfoTitle.cs b/Sources/TestUnitaires/TU_InfoTitle.cs new file mode 100644 index 0000000..49727a8 --- /dev/null +++ b/Sources/TestUnitaires/TU_InfoTitle.cs @@ -0,0 +1,45 @@ +using Model; +using Newtonsoft.Json.Linq; +using NuGet.Frameworks; + +namespace TestUnitaires +{ + + public class TU_InfoTitle + { + [Theory] + [InlineData("Trajectoire","morceau1.png","Sortie : 2020","Morceau de Népal",Genre.HIP_HOP)] + [InlineData(null, "morceau1.png", "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP)] + [InlineData("Trajectoire", null, "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP)] + [InlineData("Trajectoire", "morceau1.png", null, "Morceau de Népal", Genre.HIP_HOP)] + [InlineData("Trajectoire", "morceau1png", "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP)] + [InlineData("Trajectoire", "morceau1. png", "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP)] + public void TU_Attributes(string name, string url, string info, string desc, Genre g) + { + InfoTitle it = new InfoTitle(name, url, info, new Artiste("test"), desc, g); + Assert.True(it.Name != null && it.Name.Length < 75); + Assert.True(it.ImageURL != null && it.ImageURL.Contains('.')); + Assert.False(it.ImageURL.Contains(' ')); + Assert.True(it.Information != null && it.Information.Length < 500); + Assert.True(it.Description != null && it.Description.Length < 500); + } + + [Theory] + [InlineData("Trajectoire", "morceau1.png", "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP)] + [InlineData(null, "morceau1.png", "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP)] + [InlineData("Trajectoire", null, "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP)] + [InlineData("Trajectoire", "morceau1.png", null, "Morceau de Népal", Genre.HIP_HOP)] + [InlineData("Trajectoire", "morceau1png", "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP)] + [InlineData("Trajectoire", "morceau1. png", "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP)] + public void TU_Methods(string name, string url, string info, string desc, Genre g) + { + InfoTitle it = new InfoTitle(name, url, info, new Artiste("test"), desc, g); + Artiste a = new Artiste("Lahuiss"); + it.AddFeat(a); + Assert.Contains(a, it.Feat); + it.RemoveFeat(a); + Assert.DoesNotContain(a, it.Feat); + } + } + +} \ No newline at end of file From adfebf218fb3634449eda9283041759fe32c6ce9 Mon Sep 17 00:00:00 2001 From: Louis LABORIE <lolaborie> Date: Sat, 13 May 2023 08:28:37 +0200 Subject: [PATCH 17/22] Add Manager's UT --- Sources/TestUnitaires/TU_Manager.cs | 36 +++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Sources/TestUnitaires/TU_Manager.cs diff --git a/Sources/TestUnitaires/TU_Manager.cs b/Sources/TestUnitaires/TU_Manager.cs new file mode 100644 index 0000000..990a9c1 --- /dev/null +++ b/Sources/TestUnitaires/TU_Manager.cs @@ -0,0 +1,36 @@ +using Model; +using Model.Stub; +using Newtonsoft.Json.Linq; +using NuGet.Frameworks; +using System; + +namespace TestUnitaires +{ + + public class TU_Manager + { + [Theory] + [InlineData(null)] + [InlineData("Réference")] + public void TU_Methods(string? test) + { + Playlist p = new Playlist(test, "PlaceHolder", "place.holder"); + Album album = new Album(test, "place.holder", new Artiste("test"), "PlaceHolder", "PlaceHolder"); + Title t = new Title(test, "test. mp3", "Banger"); + Manager m = new Manager(); + m.AddTitle(t); + m.AddPlaylist(p); + m.AddAlbum(album); + Assert.Contains(t, m.Titles); + Assert.Contains(album, m.Albums); + Assert.Contains(p, m.Playlists); + m.RemovePlaylist(p); + m.RemoveAlbum(album); + m.RemoveTitle(t); + Assert.DoesNotContain(t, m.Titles); + Assert.DoesNotContain(p, m.Playlists); + Assert.DoesNotContain(album, m.Albums); + } + } + +} \ No newline at end of file From b71461d7a9bf07f10daabc1a5da2b7acf4e370f8 Mon Sep 17 00:00:00 2001 From: Louis LABORIE <lolaborie> Date: Sat, 13 May 2023 09:31:12 +0200 Subject: [PATCH 18/22] Enhanced model (add readonly keyword to multiple fields) --- Sources/Model/Album.cs | 2 +- Sources/Model/Artiste.cs | 2 +- Sources/Model/InfoTitle.cs | 2 +- Sources/Model/Manager.cs | 6 +++--- Sources/Model/Playlist.cs | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Sources/Model/Album.cs b/Sources/Model/Album.cs index 323ddb0..06380d0 100644 --- a/Sources/Model/Album.cs +++ b/Sources/Model/Album.cs @@ -40,7 +40,7 @@ } } - private List<Title> titles = new List<Title>(); + private readonly List<Title> titles = new List<Title>(); public string ImageURL { diff --git a/Sources/Model/Artiste.cs b/Sources/Model/Artiste.cs index ab29d82..bc2a9b3 100644 --- a/Sources/Model/Artiste.cs +++ b/Sources/Model/Artiste.cs @@ -25,7 +25,7 @@ public class Artiste } } - private List<Album> albums = new List<Album>(); + private readonly List<Album> albums = new List<Album>(); public Artiste(string name) { diff --git a/Sources/Model/InfoTitle.cs b/Sources/Model/InfoTitle.cs index eb4e688..7a3c3b6 100644 --- a/Sources/Model/InfoTitle.cs +++ b/Sources/Model/InfoTitle.cs @@ -27,7 +27,7 @@ public class InfoTitle : Title } } - private List<Artiste> feat = new List<Artiste>(); + private readonly List<Artiste> feat = new List<Artiste>(); public Genre Genre { get; set; } diff --git a/Sources/Model/Manager.cs b/Sources/Model/Manager.cs index 4f8e51b..3f1de5d 100644 --- a/Sources/Model/Manager.cs +++ b/Sources/Model/Manager.cs @@ -12,7 +12,7 @@ public class Manager } } - private List<Album> albums = new List<Album>(); + private readonly List<Album> albums = new List<Album>(); public IEnumerable<Title> Titles { @@ -22,7 +22,7 @@ public class Manager } } - private List<Title> titles = new List<Title>(); + private readonly List<Title> titles = new List<Title>(); public IEnumerable<Playlist> Playlists { @@ -32,7 +32,7 @@ public class Manager } } - private List<Playlist> playlists = new List<Playlist>(); + private readonly List<Playlist> playlists = new List<Playlist>(); public Manager() { diff --git a/Sources/Model/Playlist.cs b/Sources/Model/Playlist.cs index a3882d0..afb3cd8 100644 --- a/Sources/Model/Playlist.cs +++ b/Sources/Model/Playlist.cs @@ -40,7 +40,7 @@ public class Playlist } } - private List<Title> titles = new List<Title>(); + private readonly List<Title> titles = new List<Title>(); public string ImageURL { From bda7f3c45b7f490cfbd94616da369e60deb64a87 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE <colemaire> Date: Sat, 13 May 2023 10:37:08 +0200 Subject: [PATCH 19/22] Fix critical issue --- Sources/Model/Artiste.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Model/Artiste.cs b/Sources/Model/Artiste.cs index bc2a9b3..e4626ba 100644 --- a/Sources/Model/Artiste.cs +++ b/Sources/Model/Artiste.cs @@ -21,7 +21,7 @@ public class Artiste { get { - return albums.ToList(); + return new List<Album>(albums); } } From fd704f8b0ab235e77d832a976e068d437c8f1654 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE <colemaire> Date: Sat, 13 May 2023 10:47:14 +0200 Subject: [PATCH 20/22] Fix major issues --- Sources/Console/Program.cs | 19 ------------------- Sources/Linaris/AlbumPage.xaml.cs | 9 --------- Sources/Linaris/MainPage.xaml.cs | 21 ++++----------------- Sources/Model/IDataManager.cs | 2 +- Sources/Model/Stub/Stub.cs | 2 -- 5 files changed, 5 insertions(+), 48 deletions(-) diff --git a/Sources/Console/Program.cs b/Sources/Console/Program.cs index 0806a11..1d3bfa7 100644 --- a/Sources/Console/Program.cs +++ b/Sources/Console/Program.cs @@ -2,23 +2,4 @@ Console.WriteLine("---"); -// See https://aka.ms/new-console-template for more information - -/*Album a = new Album("Adios Bahamas", "album1.jpg", "Népal"); -Album a1 = new Album("Fenêtre sur Rue", "album3.jpg", "HugoTSR"); -Album a2 = new Album("Dans la Légende", "album8.jpg", "PNL"); - -List<Album> lst = new List<Album> { a1, a2, a }; - -foreach (Album album in lst) -{ - Console.WriteLine($"Nom de l'album : " + album.Nom); - - Console.WriteLine($"Nom du fichier : " + album.File_Name); - - Console.WriteLine($"Artiste : " + album.Artiste); - - Console.WriteLine($"-------------------------"); -}*/ - diff --git a/Sources/Linaris/AlbumPage.xaml.cs b/Sources/Linaris/AlbumPage.xaml.cs index 821b100..adde9b9 100644 --- a/Sources/Linaris/AlbumPage.xaml.cs +++ b/Sources/Linaris/AlbumPage.xaml.cs @@ -6,13 +6,4 @@ public partial class AlbumPage : ContentPage { InitializeComponent(); } - - /* async void Button_Clicked(object sender, EventArgs e) - { - var random = new Random(); - var color = String.Format("#{0:X6}", random.Next(0x1000000)); - bouton.BackgroundColor = Color.FromArgb(color); - await bouton.RelRotateTo(360, 1000); - bouton.Rotation = 0; - }*/ } \ No newline at end of file diff --git a/Sources/Linaris/MainPage.xaml.cs b/Sources/Linaris/MainPage.xaml.cs index de3a24b..5a08d5f 100644 --- a/Sources/Linaris/MainPage.xaml.cs +++ b/Sources/Linaris/MainPage.xaml.cs @@ -2,7 +2,6 @@ public partial class MainPage : ContentPage { - // int count = 0; public MainPage() { @@ -10,23 +9,11 @@ public partial class MainPage : ContentPage } - /*private void OnCounterClicked(object sender, EventArgs e) - { - count++; - - if (count == 1) - CounterBtn.Text = $"Clicked {count} time"; - else - CounterBtn.Text = $"Clicked {count} times"; - - SemanticScreenReader.Announce(CounterBtn.Text); - }*/ - - /*async public void Go_Home() - { - await Navigation.PushAsync(new MainPage()); + async public void Go_Home() + { + await Navigation.PushAsync(new MainPage()); - }*/ + } } diff --git a/Sources/Model/IDataManager.cs b/Sources/Model/IDataManager.cs index 4799ef5..895bf1d 100644 --- a/Sources/Model/IDataManager.cs +++ b/Sources/Model/IDataManager.cs @@ -2,5 +2,5 @@ public interface IDataManager { - //méthodes style IEnumerable<Groupe> RecupGFroupe(); + } \ No newline at end of file diff --git a/Sources/Model/Stub/Stub.cs b/Sources/Model/Stub/Stub.cs index 9a60c86..23abbec 100644 --- a/Sources/Model/Stub/Stub.cs +++ b/Sources/Model/Stub/Stub.cs @@ -33,8 +33,6 @@ public class Stub : IDataManager Playlist Playlist1 = new Playlist("Playlist1", "desc1", "url1.png"); Playlist Playlist2 = new Playlist("Playlist2", "desc2", "url2.png"); - Playlist Playlist3 = new Playlist("Playlist3", "desc3", "url3.png"); - Playlist Playlist4 = new Playlist("Playlist4", "desc4", "url4.png"); Playlist1.AddTitle(new CustomTitle("custom1", "url1.png", "info1", "chemin1")); Playlist1.AddTitle(new CustomTitle("custom2", "url2.png", "info2", "chemin2")); From 061dc31cea7ca71d91ca06eefd8fbf2bcbe63a17 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE <colemaire> Date: Sat, 13 May 2023 10:54:32 +0200 Subject: [PATCH 21/22] Fix minor and major issues --- Sources/Linaris/MainPage.xaml.cs | 2 +- Sources/Model/Stub/Stub.cs | 36 +++++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/Sources/Linaris/MainPage.xaml.cs b/Sources/Linaris/MainPage.xaml.cs index 5a08d5f..d6caaeb 100644 --- a/Sources/Linaris/MainPage.xaml.cs +++ b/Sources/Linaris/MainPage.xaml.cs @@ -9,7 +9,7 @@ public partial class MainPage : ContentPage } - async public void Go_Home() + async public Task Go_Home() { await Navigation.PushAsync(new MainPage()); diff --git a/Sources/Model/Stub/Stub.cs b/Sources/Model/Stub/Stub.cs index 23abbec..906c959 100644 --- a/Sources/Model/Stub/Stub.cs +++ b/Sources/Model/Stub/Stub.cs @@ -3,20 +3,40 @@ public class Stub : IDataManager { - public IEnumerable<Artiste> Artistes; + public IEnumerable<Artiste> Artistes + { + get => artistes; + } + + public IEnumerable<Album> Albums + { + get => albums; + } + + public IEnumerable<Playlist> Playlists + { + get => playlists; + } + + public IEnumerable<Title> Titles + { + get => titles; + } + + private IEnumerable<Artiste> artistes; - public IEnumerable<Album> Albums; + private IEnumerable<Album> albums; - public IEnumerable<Playlist> Playlists; + private IEnumerable<Playlist> playlists; - public IEnumerable<Title> Titles; + private IEnumerable<Title> titles; public Stub() { - Artistes = new List<Artiste>(); - Albums = new List<Album>(); - Playlists = new List<Playlist>(); - Titles = new List<Title>(); + artistes = new List<Artiste>(); + albums = new List<Album>(); + playlists = new List<Playlist>(); + titles = new List<Title>(); Artiste Artiste1 = new Artiste("Critien"); Artiste Artiste2 = new Artiste("Gouriet"); From d4d304f9cda10350c4ff616ca086e71836ad5268 Mon Sep 17 00:00:00 2001 From: Corentin LEMAIRE <corentin.lemaire@etu.uca.fr> Date: Sun, 14 May 2023 18:09:53 +0200 Subject: [PATCH 22/22] Fix Major issues --- Sources/Model/Stub/Stub.cs | 110 ++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/Sources/Model/Stub/Stub.cs b/Sources/Model/Stub/Stub.cs index 906c959..dcef669 100644 --- a/Sources/Model/Stub/Stub.cs +++ b/Sources/Model/Stub/Stub.cs @@ -1,67 +1,67 @@ -namespace Model.Stub; - -public class Stub : IDataManager -{ - +namespace Model.Stub; + +public class Stub : IDataManager +{ + public IEnumerable<Artiste> Artistes { get => artistes; - } - + } + public IEnumerable<Album> Albums { get => albums; - } - + } + public IEnumerable<Playlist> Playlists { get => playlists; - } - + } + public IEnumerable<Title> Titles { get => titles; - } - - private IEnumerable<Artiste> artistes; - - private IEnumerable<Album> albums; - - private IEnumerable<Playlist> playlists; - - private IEnumerable<Title> titles; - - public Stub() - { - artistes = new List<Artiste>(); - albums = new List<Album>(); - playlists = new List<Playlist>(); - titles = new List<Title>(); - - Artiste Artiste1 = new Artiste("Critien"); - Artiste Artiste2 = new Artiste("Gouriet"); - Artiste Artiste3 = new Artiste("Poulifer"); - Artiste Artiste4 = new Artiste("Credian"); - - Album Album1 = new Album("la street", "lastreet.png", Artiste1, "c'est la street", "plein d'infos1"); - Album Album4 = new Album("la pas le choix", "peutetre.png", Artiste4, "c'est la parterre", "plein d'infos4"); - - Artiste1.AddAlbum(Album1); - Artiste1.AddAlbum(new Album("la jsp", "oui.png", Artiste1, "c'est la couri", "plein d'infos2")); - Artiste2.AddAlbum(new Album("la pas le temps", "non.png", Artiste3, "c'est pas la street", "plein d'infos3")); - Artiste2.AddAlbum(Album4); - - Playlist Playlist1 = new Playlist("Playlist1", "desc1", "url1.png"); - Playlist Playlist2 = new Playlist("Playlist2", "desc2", "url2.png"); - - Playlist1.AddTitle(new CustomTitle("custom1", "url1.png", "info1", "chemin1")); - Playlist1.AddTitle(new CustomTitle("custom2", "url2.png", "info2", "chemin2")); - Playlist1.AddTitle(new CustomTitle("custom3", "url3.png", "info3", "chemin3")); - Playlist2.AddTitle(new CustomTitle("custom4", "url4.png", "info4", "chemin4")); - - Album1.AddTitle(new InfoTitle("info1", "url1.png", "info1", Artiste2, "desc1", Genre.K_POP)); - Album1.AddTitle(new InfoTitle("info2", "url2.png", "info2", Artiste3, "desc2", Genre.GOSPEL)); - Album1.AddTitle(new InfoTitle("info3", "url3.png", "info3", Artiste4, "desc3", Genre.BLUES)); - Album4.AddTitle(new InfoTitle("info4", "url4.png", "info4", Artiste3, "desc4", Genre.DISCO)); - } -} + } + + private readonly IEnumerable<Artiste> artistes; + + private readonly IEnumerable<Album> albums; + + private readonly IEnumerable<Playlist> playlists; + + private readonly IEnumerable<Title> titles; + + public Stub() + { + artistes = new List<Artiste>(); + albums = new List<Album>(); + playlists = new List<Playlist>(); + titles = new List<Title>(); + + Artiste Artiste1 = new Artiste("Critien"); + Artiste Artiste2 = new Artiste("Gouriet"); + Artiste Artiste3 = new Artiste("Poulifer"); + Artiste Artiste4 = new Artiste("Credian"); + + Album Album1 = new Album("la street", "lastreet.png", Artiste1, "c'est la street", "plein d'infos1"); + Album Album4 = new Album("la pas le choix", "peutetre.png", Artiste4, "c'est la parterre", "plein d'infos4"); + + Artiste1.AddAlbum(Album1); + Artiste1.AddAlbum(new Album("la jsp", "oui.png", Artiste1, "c'est la couri", "plein d'infos2")); + Artiste2.AddAlbum(new Album("la pas le temps", "non.png", Artiste3, "c'est pas la street", "plein d'infos3")); + Artiste2.AddAlbum(Album4); + + Playlist Playlist1 = new Playlist("Playlist1", "desc1", "url1.png"); + Playlist Playlist2 = new Playlist("Playlist2", "desc2", "url2.png"); + + Playlist1.AddTitle(new CustomTitle("custom1", "url1.png", "info1", "chemin1")); + Playlist1.AddTitle(new CustomTitle("custom2", "url2.png", "info2", "chemin2")); + Playlist1.AddTitle(new CustomTitle("custom3", "url3.png", "info3", "chemin3")); + Playlist2.AddTitle(new CustomTitle("custom4", "url4.png", "info4", "chemin4")); + + Album1.AddTitle(new InfoTitle("info1", "url1.png", "info1", Artiste2, "desc1", Genre.K_POP)); + Album1.AddTitle(new InfoTitle("info2", "url2.png", "info2", Artiste3, "desc2", Genre.GOSPEL)); + Album1.AddTitle(new InfoTitle("info3", "url3.png", "info3", Artiste4, "desc3", Genre.BLUES)); + Album4.AddTitle(new InfoTitle("info4", "url4.png", "info4", Artiste3, "desc4", Genre.DISCO)); + } +}