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 Titles
+ {
+ get
+ {
+ return titles;
+ }
+ }
+
+ private List titles = new List();
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();
}
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 Albums { get; set; }
+ public IEnumerable Albums
+ {
+ get
+ {
+ return albums.ToList();
+ }
+ }
+
+ private List albums = new List();
public Artiste(string name)
{
Name = name;
- Albums = new List();
}
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 Morceaux { get; set; }
+ public IEnumerable Titles
+ {
+ get
+ {
+ return titles;
+ }
+ }
+
+ private List titles = new List();
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();
- 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 verif = new List();
- 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);
}
}