From dbdd5a6de758b78fa3c0fc2a5d7d09826ea11578 Mon Sep 17 00:00:00 2001 From: Louis LABORIE Date: Wed, 10 May 2023 16:11:37 +0200 Subject: [PATCH] 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