diff --git a/Sources/Model/Serialization/LINQ_XML_Serialization.cs b/Sources/Model/Serialization/LINQ_XML_Serialization.cs
index 8d2f242..fa35a33 100644
--- a/Sources/Model/Serialization/LINQ_XML_Serialization.cs
+++ b/Sources/Model/Serialization/LINQ_XML_Serialization.cs
@@ -479,11 +479,7 @@ namespace Model.Serialization
/// Retourne l'objet InfoTitle avec un nom équivalent à celui donné en paramètre
public InfoTitle GetInfoTitleByName(string name)
{
- if (infoTitles.Any(it => it.Name.Equals(name)))
- {
- return infoTitles.Where(it => it.Name.Equals(name)).FirstOrDefault();
- }
- return null;
+ return infoTitles.FirstOrDefault(it => it.Name.Equals(name));
}
///
@@ -493,11 +489,7 @@ namespace Model.Serialization
/// Retourne l'objet Artist avec un nom équivalent à celui donné en paramètre
public Artist GetArtistByName(string name)
{
- if (artists.Any(artist => artist.Name.Equals(name)))
- {
- return artists.Where(artist => artist.Name.Equals(name)).FirstOrDefault();
- }
- return null;
+ return artists.FirstOrDefault(artist => artist.Name.Equals(name));
}
///
@@ -507,11 +499,7 @@ namespace Model.Serialization
/// Retourne l'objet Album avec un nom équivalent à celui donné en paramètre
public Album GetAlbumByName(string name)
{
- if (albums.Any(a => a.Name.Equals(name)))
- {
- return albums.Where(a => a.Name.Equals(name)).FirstOrDefault();
- }
- return null;
+ return albums.FirstOrDefault(a => a.Name.Equals(name));
}
///
@@ -521,11 +509,7 @@ namespace Model.Serialization
/// Retourne l'objet Album avec un ID équivalent à celui donné en paramètre
public Album GetAlbumById(long id)
{
- if (albums.Any(a => a.ID == id))
- {
- return albums.Where(a => a.ID == id).FirstOrDefault();
- }
- return null;
+ return albums.FirstOrDefault(a => a.ID == id);
}
///
@@ -535,11 +519,7 @@ namespace Model.Serialization
/// Retourne l'objet CustomTitle avec un chemin d'accès équivalent à celui donné en paramètre
public CustomTitle GetCustomTitleByPath(string custom)
{
- if (customTitles.Any(customTitle => customTitle.Path.Equals(custom)))
- {
- return customTitles.Where(customTitle => customTitle.Path.Equals(custom)).FirstOrDefault();
- }
- return null;
+ return customTitles.FirstOrDefault(customTitle => customTitle.Path.Equals(custom));
}
///
@@ -609,11 +589,7 @@ namespace Model.Serialization
/// Retourne l'objet Playlist avec un nom équivalent à celui donné en paramètre
public Playlist GetPlaylistByName(string name)
{
- if (playlists.Any(p => p.Name.Equals(name)))
- {
- return playlists.Where(p => p.Name.Equals(name)).FirstOrDefault();
- }
- return null;
+ return playlists.FirstOrDefault(p => p.Name.Equals(name));
}
///
@@ -901,11 +877,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsPlaylist(Playlist playlist)
{
- if (playlists.Any(p => p.Equals(playlist)))
- {
- return true;
- }
- return false;
+ return playlists.Any(p => p.Equals(playlist));
}
///
@@ -915,11 +887,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsPlaylistByName(string name)
{
- if (playlists.Any(p => p.Name.Equals(name)))
- {
- return true;
- }
- return false;
+ return playlists.Any(p => p.Name.Equals(name));
}
///
@@ -929,11 +897,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsAlbum(Album album)
{
- if (albums.Any(a => a.Equals(album)))
- {
- return true;
- }
- return false;
+ return albums.Any(a => a.Equals(album));
}
///
@@ -943,11 +907,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsAlbumByName(string name)
{
- if (albums.Any(a => a.Name.Equals(name)))
- {
- return true;
- }
- return false;
+ return albums.Any(a => a.Name.Equals(name));
}
///
@@ -957,11 +917,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsArtist(Artist artist)
{
- if (artists.Any(a => a.Equals(artist)))
- {
- return true;
- }
- return false;
+ return artists.Any(a => a.Equals(artist));
}
///
@@ -971,11 +927,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsArtistByName(string name)
{
- if (artists.Any(a => a.Name.Equals(name)))
- {
- return true;
- }
- return false;
+ return artists.Any(a => a.Name.Equals(name));
}
///
@@ -985,11 +937,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsCustomTitle(CustomTitle title)
{
- if (customTitles.Any(ct => title.Equals(ct)))
- {
- return true;
- }
- return false;
+ return customTitles.Any(ct => ct.Equals(title));
}
///
@@ -999,11 +947,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsCustomTitleByName(string name)
{
- if (customTitles.Any(ct => ct.Name.Equals(name)))
- {
- return true;
- }
- return false;
+ return customTitles.Any(ct => ct.Name.Equals(name));
}
///
@@ -1013,11 +957,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsInfoTitle(InfoTitle title)
{
- if (infoTitles.Any(it => it.Equals(title)))
- {
- return true;
- }
- return false;
+ return infoTitles.Any(it => it.Equals(title));
}
///
@@ -1027,11 +967,7 @@ namespace Model.Serialization
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsInfoTitleByName(string name)
{
- if (infoTitles.Any(it => it.Name.Equals(name)))
- {
- return true;
- }
- return false;
+ return infoTitles.Any(it => it.Name.Equals(name));
}
}
}
\ No newline at end of file
diff --git a/Sources/Model/Stub/StubManager.cs b/Sources/Model/Stub/StubManager.cs
index c004b05..93d6891 100644
--- a/Sources/Model/Stub/StubManager.cs
+++ b/Sources/Model/Stub/StubManager.cs
@@ -241,14 +241,7 @@ namespace Model.Stub
/// Retourne l'objet CustomTitle avec un chemin d'accès équivalent à celui donné en paramètre
public CustomTitle GetCustomTitleByPath(string custom)
{
- foreach (CustomTitle customTitle in StubCustomTitle.GetCustomTitles())
- {
- if (customTitle.Path == custom)
- {
- return customTitle;
- }
- }
- return null;
+ return StubCustomTitle.GetCustomTitles().FirstOrDefault(customTitle => customTitle.Path == custom);
}
///
@@ -258,14 +251,7 @@ namespace Model.Stub
/// Retourne l'objet InfoTitle avec un nom équivalent à celui donné en paramètre
public InfoTitle GetInfoTitleByName(string name)
{
- foreach (InfoTitle title in StubInfoTitle.GetInfoTitles())
- {
- if (title.Name == name)
- {
- return title;
- }
- }
- return null;
+ return StubInfoTitle.GetInfoTitles().FirstOrDefault(title => title.Name == name);
}
///
@@ -275,14 +261,7 @@ namespace Model.Stub
/// Retourne l'objet Album avec un nom équivalent à celui donné en paramètre
public Album GetAlbumByName(string name)
{
- foreach (Album album in StubAlbum.GetAlbums())
- {
- if (album.Name == name)
- {
- return album;
- }
- }
- return null;
+ return StubAlbum.GetAlbums().FirstOrDefault(album => album.Name == name);
}
///
@@ -292,14 +271,7 @@ namespace Model.Stub
/// Retourne l'objet Artist avec un nom équivalent à celui donné en paramètre
public Artist GetArtistByName(string name)
{
- foreach (Artist artist in StubArtist.GetArtists())
- {
- if (artist.Name == name)
- {
- return artist;
- }
- }
- return null;
+ return StubArtist.GetArtists().FirstOrDefault(artist => artist.Name == name);
}
///
@@ -369,14 +341,7 @@ namespace Model.Stub
/// Retourne l'objet Playlist avec un nom équivalent à celui donné en paramètre
public Playlist GetPlaylistByName(string name)
{
- foreach (Playlist p in StubPlaylist.Playlists)
- {
- if (p.Name == name)
- {
- return p;
- }
- }
- return null;
+ return StubPlaylist.Playlists.FirstOrDefault(p => p.Name == name);
}
///
@@ -664,14 +629,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsPlaylist(Playlist playlist)
{
- foreach (Playlist p in StubPlaylist.Playlists)
- {
- if (p.Equals(playlist))
- {
- return true;
- }
- }
- return false;
+ return StubPlaylist.Playlists.Any(p => p.Equals(playlist));
}
///
@@ -681,14 +639,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsPlaylistByName(string name)
{
- foreach (Playlist p in StubPlaylist.Playlists)
- {
- if (p.Name.Equals(name))
- {
- return true;
- }
- }
- return false;
+ return StubPlaylist.Playlists.Any(p => p.Name.Equals(name));
}
///
@@ -698,14 +649,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsAlbum(Album album)
{
- foreach (Album a in StubAlbum.Albums)
- {
- if (a.Equals(album))
- {
- return true;
- }
- }
- return false;
+ return StubAlbum.Albums.Any(a => a.Equals(album));
}
///
@@ -715,14 +659,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsAlbumByName(string name)
{
- foreach (Album a in StubAlbum.Albums)
- {
- if (a.Name == name)
- {
- return true;
- }
- }
- return false;
+ return StubAlbum.Albums.Any(a => a.Name == name);
}
///
@@ -732,14 +669,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsArtist(Artist artist)
{
- foreach (Artist a in StubArtist.Artists)
- {
- if (a.Equals(artist))
- {
- return true;
- }
- }
- return false;
+ return StubArtist.Artists.Any(a => a.Equals(artist));
}
///
@@ -749,14 +679,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsArtistByName(string name)
{
- foreach (Artist a in StubArtist.Artists)
- {
- if (a.Name == name)
- {
- return true;
- }
- }
- return false;
+ return StubArtist.Artists.Any(a => a.Name == name);
}
///
@@ -766,14 +689,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsCustomTitle(CustomTitle title)
{
- foreach (CustomTitle ct in StubCustomTitle.CustomTitles)
- {
- if (title.Equals(ct))
- {
- return true;
- }
- }
- return false;
+ return StubCustomTitle.CustomTitles.Any(ct => ct.Equals(title));
}
///
@@ -783,14 +699,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsCustomTitleByName(string name)
{
- foreach (CustomTitle ct in StubCustomTitle.CustomTitles)
- {
- if (ct.Name == name)
- {
- return true;
- }
- }
- return false;
+ return StubCustomTitle.CustomTitles.Any(ct => ct.Name == name);
}
///
@@ -800,14 +709,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsInfoTitle(InfoTitle title)
{
- foreach (InfoTitle it in StubInfoTitle.InfoTitles)
- {
- if (it.Equals(title))
- {
- return true;
- }
- }
- return false;
+ return StubInfoTitle.InfoTitles.Any(it => it.Equals(title));
}
///
@@ -817,14 +719,7 @@ namespace Model.Stub
/// Booléen True s'il est contenu dans l'application, False sinon
public bool ExistsInfoTitleByName(string name)
{
- foreach (InfoTitle it in StubInfoTitle.InfoTitles)
- {
- if (it.Name == name)
- {
- return true;
- }
- }
- return false;
+ return StubInfoTitle.InfoTitles.Any(it => it.Name == name);
}
///
@@ -834,14 +729,7 @@ namespace Model.Stub
/// Retourne l'objet Album avec un ID équivalent à celui donné en paramètre
public Album GetAlbumById(long id)
{
- foreach (Album album in StubAlbum.Albums)
- {
- if (album.ID == id)
- {
- return album;
- }
- }
- return null;
+ return StubAlbum.Albums.FirstOrDefault(album => album.ID == id);
}
}
}
\ No newline at end of file
diff --git a/Sources/TestUnitaires/TU_StubInfoTitle.cs b/Sources/TestUnitaires/TU_StubInfoTitle.cs
index 9496f55..943cae5 100644
--- a/Sources/TestUnitaires/TU_StubInfoTitle.cs
+++ b/Sources/TestUnitaires/TU_StubInfoTitle.cs
@@ -9,9 +9,8 @@ namespace TestUnitaires
public class TU_StubInfoTitle
{
- [Theory]
- [InlineData("test")]
- public void TU_Methods(string test)
+ [Fact]
+ public void TU_Methods()
{
StubInfoTitle sit = new StubInfoTitle();
/*List list = new List();*/