Fix Unit tests
continuous-integration/drone/push Build is failing Details

pull/18/head
Corentin LEMAIRE 2 years ago
parent cab27bc4d5
commit 45ceaa5a5a

@ -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<Title> 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);
}
}

@ -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);
}
}

@ -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)
{

@ -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);
}
}

@ -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)
{

@ -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);
}
}

@ -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);
}
}

@ -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);
}
}

Loading…
Cancel
Save