Add exists UT
continuous-integration/drone/push Build is failing Details

pull/39/head
Corentin LEMAIRE 2 years ago
parent c8f36cd7bb
commit 5684fced54

@ -52,7 +52,6 @@ steps:
when:
branch:
- master
- dev-doxygen
event:
- push
- pull_request

@ -430,7 +430,7 @@ namespace Model.Stub
List<CustomTitle> ToDelete = new();
foreach (CustomTitle ct in p.Titles)
{
if (ct == title)
if (ct.Equals(title))
{
ToDelete.Add(ct);
}

@ -316,7 +316,7 @@ namespace Model
{
foreach (CustomTitle custom in Titles)
{
if (custom == customTitle) return true;
if (custom.Equals(customTitle)) return true;
}
return false;
}

@ -481,7 +481,7 @@ namespace Model.Serialization
{
foreach (InfoTitle it in infoTitles)
{
if (it.Name == name)
if (it.Name.Equals(name))
{
return it;
}
@ -498,7 +498,7 @@ namespace Model.Serialization
{
foreach (Artist a in artists)
{
if (a.Name == name)
if (a.Name.Equals(name))
{
return a;
}
@ -515,7 +515,7 @@ namespace Model.Serialization
{
foreach (Album a in albums)
{
if (a.Name == name)
if (a.Name.Equals(name))
{
return a;
}
@ -532,7 +532,7 @@ namespace Model.Serialization
{
foreach (Album a in albums)
{
if (a.ID == id) return a;
if (a.ID.Equals(id)) return a;
}
return null;
}
@ -546,7 +546,7 @@ namespace Model.Serialization
{
foreach (CustomTitle customTitle in customTitles)
{
if (customTitle.Path == custom)
if (customTitle.Path.Equals(custom))
{
return customTitle;
}
@ -623,7 +623,7 @@ namespace Model.Serialization
{
foreach (Playlist p in playlists)
{
if (p.Name == name)
if (p.Name.Equals(name))
{
return p;
}
@ -918,7 +918,7 @@ namespace Model.Serialization
{
foreach (Playlist p in playlists)
{
if (p == playlist)
if (p.Equals(playlist))
{
return true;
}
@ -935,7 +935,7 @@ namespace Model.Serialization
{
foreach (Playlist p in playlists)
{
if (p.Name == name)
if (p.Name.Equals(name))
{
return true;
}
@ -952,7 +952,7 @@ namespace Model.Serialization
{
foreach (Album a in albums)
{
if (a == album)
if (a.Equals(album))
{
return true;
}
@ -969,7 +969,7 @@ namespace Model.Serialization
{
foreach (Album a in albums)
{
if (a.Name == name)
if (a.Name.Equals(name))
{
return true;
}
@ -986,7 +986,7 @@ namespace Model.Serialization
{
foreach (Artist a in artists)
{
if (a == artist)
if (a.Equals(artist))
{
return true;
}
@ -1003,7 +1003,7 @@ namespace Model.Serialization
{
foreach (Artist a in artists)
{
if (a.Name == name)
if (a.Name.Equals(name))
{
return true;
}
@ -1020,7 +1020,7 @@ namespace Model.Serialization
{
foreach (CustomTitle ct in customTitles)
{
if (title == ct)
if (title.Equals(ct))
{
return true;
}
@ -1037,7 +1037,7 @@ namespace Model.Serialization
{
foreach (CustomTitle ct in customTitles)
{
if (ct.Name == name)
if (ct.Name.Equals(name))
{
return true;
}
@ -1054,7 +1054,7 @@ namespace Model.Serialization
{
foreach (InfoTitle it in infoTitles)
{
if (it == title)
if (it.Equals(title))
{
return true;
}
@ -1071,7 +1071,7 @@ namespace Model.Serialization
{
foreach (InfoTitle it in infoTitles)
{
if (it.Name == name)
if (it.Name.Equals(name))
{
return true;
}

@ -666,7 +666,7 @@ namespace Model.Stub
{
foreach (Playlist p in StubPlaylist.Playlists)
{
if (p == playlist)
if (p.Equals(playlist))
{
return true;
}
@ -683,7 +683,7 @@ namespace Model.Stub
{
foreach (Playlist p in StubPlaylist.Playlists)
{
if (p.Name == name)
if (p.Name.Equals(name))
{
return true;
}
@ -700,7 +700,7 @@ namespace Model.Stub
{
foreach (Album a in StubAlbum.Albums)
{
if (a == album)
if (a.Equals(album))
{
return true;
}
@ -734,7 +734,7 @@ namespace Model.Stub
{
foreach (Artist a in StubArtist.Artists)
{
if (a == artist)
if (a.Equals(artist))
{
return true;
}
@ -768,7 +768,7 @@ namespace Model.Stub
{
foreach (CustomTitle ct in StubCustomTitle.CustomTitles)
{
if (title == ct)
if (title.Equals(ct))
{
return true;
}
@ -802,7 +802,7 @@ namespace Model.Stub
{
foreach (InfoTitle it in StubInfoTitle.InfoTitles)
{
if (it == title)
if (it.Equals(title))
{
return true;
}

@ -14,21 +14,20 @@ namespace TestUnitaires
[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 Artist("test"), "PlaceHolder", "PlaceHolder");
CustomTitle t = new CustomTitle(test, "test. mp3", "Banger", "path");
Artist artist = new Artist(test);
LinqXmlSerialization l = new LinqXmlSerialization(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"));
InfoTitle info = new InfoTitle(test, "url.test", "infos", "desc", Genre.POP, 345);
/*Assert.NotEmpty(l.Albums);
Playlist p = new(test, "PlaceHolder", "place.holder");
Album album = new(test, "place.holder", new Artist("test"), "PlaceHolder", "PlaceHolder");
CustomTitle t = new(test, "test. mp3", "Banger", "path");
Artist artist = new(test);
InfoTitle info = new(test, "url.test", "infos", "desc", Genre.POP, 345);
LinqXmlSerialization l = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"));
Assert.NotEmpty(l.Albums);
Assert.NotEmpty(l.Artists);
Assert.NotEmpty(l.InfoTitles);
Assert.NotEmpty(l.Playlists);
Assert.NotEmpty(l.CustomTitles);*/
l.AddCustomTitle(t);
Assert.Empty(l.Playlists);
Assert.Empty(l.CustomTitles);
l.AddPlaylist(p);
l.AddAlbum(album);
l.AddCustomTitle(t);
l.AddArtist(artist);
l.AddInfoTitle(info);
Assert.Contains(t, l.CustomTitles);
@ -59,6 +58,57 @@ namespace TestUnitaires
Assert.Equal(l.GetInfoTitleByName(test), info);
Assert.Equal(l.GetArtistByName(test), artist);
}
[Theory]
[InlineData("Imagine Dragons")]
[InlineData("Nepal")]
[InlineData("Booba")]
public void TU_ExistsArtist_Method(string name)
{
LinqXmlSerialization l = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"));
Assert.True(l.ExistsArtist(new Artist(name)));
Assert.True(l.ExistsArtistByName(name));
}
[Theory]
[InlineData("Fenêtre Sur Rue", "album2. jpg", "Hugo TSR", "Un banger", "Sortie : 2012")]
[InlineData("Adios Bahamas", "album1.jpg", "Nepal", "Album post-mortem qui signé également le dernier de l'artiste", "Sortie : 2020")]
public void TU_ExistsAlbum_Method(string name, string imageURL, string artistName, string desc, string info)
{
LinqXmlSerialization l = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"));
Assert.True(l.ExistsAlbum(new Album(name, imageURL, new Artist(artistName), desc, info)));
Assert.True(l.ExistsAlbumByName(name));
}
[Theory]
[InlineData("Trajectoire", "morceau1.png", "Sortie : 2020", "Morceau de Népal", Genre.HIP_HOP, 0)]
[InlineData("Bones", "album14.jpg", "Titre de l'album Mercury Act 2", "La chanson \"Bones\" a été publiée en tant que premier single de Mercury - Act 2 le 11 mars 2022. La chanson a été utilisée pour promouvoir la troisième saison de la série Amazon Prime Video The Boys. La sortie du clip de la chanson le 6 avril a coïncidé avec la précommande de l'album.", Genre.POP, 13)]
public void TU_ExistsInfoTitles_Method(string name, string imageURL, string desc, string info, Genre genre, long id)
{
LinqXmlSerialization l = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"));
Assert.True(l.ExistsInfoTitle(new InfoTitle(name, imageURL, desc, info, genre, id)));
Assert.True(l.ExistsInfoTitleByName(name));
}
[Theory]
[InlineData("Trajectoire", "morceau1.png", "Sortie : 2020")]
[InlineData("Bones", "album14.jpg", "Titre de l'album Mercury Act 2")]
public void TU_ExistsPlaylist_Method(string name, string imageURL, string desc)
{
LinqXmlSerialization l = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"));
Assert.False(l.ExistsPlaylist(new Playlist(name, desc, imageURL)));
Assert.False(l.ExistsPlaylistByName(name));
}
[Theory]
[InlineData("Trajectoire", "morceau1.png", "Sortie : 2020", "path.mp3")]
[InlineData("Bones", "album14.jpg", "Titre de l'album Mercury Act 2", "path.mp3")]
public void TU_ExistsCustomTitle_Method(string name, string imageURL, string info, string path)
{
LinqXmlSerialization l = new(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data"));
Assert.False(l.ExistsCustomTitle(new CustomTitle(name, imageURL, info, path)));
Assert.False(l.ExistsCustomTitleByName(name));
}
}
}

@ -9,9 +9,8 @@ namespace TestUnitaires
public class TU_StubAlbum
{
[Theory]
[InlineData("test")]
public void TU_Methods(string test)
[Fact]
public void TU_Methods()
{
StubAlbum stubAlbum = new StubAlbum();
Artist artist = new Artist("Un mec");

@ -9,9 +9,8 @@ namespace TestUnitaires
public class TU_StubCustomTitle
{
[Theory]
[InlineData("test")]
public void TU_Methods(string test)
[Fact]
public void TU_Methods()
{
StubCustomTitle sct = new StubCustomTitle();
List<CustomTitle> list = new List<CustomTitle>();

@ -9,9 +9,8 @@ namespace TestUnitaires
public class TU_StubPlaylist
{
[Theory]
[InlineData("test")]
public void TU_Methods(string test)
[Fact]
public void TU_Methods()
{
StubPlaylist stubPlaylist = new StubPlaylist();
Playlist playlist = new Playlist("Une playlist", "Une description", "image.jpeg");

Loading…
Cancel
Save