dupli de code
continuous-integration/drone/push Build is failing Details

refonte_program
Matheo THIERRY 2 years ago
parent 9b78f3ceca
commit 0c6def9fe7

@ -53,7 +53,7 @@ namespace Biblioteque_de_Class
public override string ToString() => $"username: {Username}\nemail: {Email}\npassword: {Password}\nOwned notes: {NoteList.Count}";
/// <summary>
/// rechercher une note dans la liste de note de l'utilisateur
/// rechercher une note dans la liste de note de l'utilisateur et la liste de note favoris de l'utilisateur
/// </summary>
public List<Note> SearchNoteByName(List<Note> ToResearchIntoList, string name)
{
@ -69,23 +69,6 @@ namespace Biblioteque_de_Class
return searchedNotes;
}
/// <summary>
/// rechercher une note dans la liste de note favoris de l'utilisateur
/// </summary>
public List<Note> SearchFavoriteNoteByName(List<Note> ToResearchIntoList, string name)
{
List<Note> searchedNotes = new List<Note>();
string search = name.ToLower();
foreach (Note note in ToResearchIntoList)
{
if (note.GetName().ToLower().Contains(search))
{
searchedNotes.Add(note);
}
}
return searchedNotes;
}
/// <summary>
/// rechercher un tag dans la liste de tag de l'utilisateur
/// </summary>

@ -1,41 +0,0 @@
using Biblioteque_de_Class;
namespace Notus_UnitTest_User
{
[TestFixture]
public class SearchFavoriteNoteByNameTests
{
private User owner;
private string searchName;
[SetUp]
public void SetUp()
{
owner = new("Owner", "owner@example.com", "password");
owner.CreateNote("Important note", "logo1.png");
owner.CreateNote("Personal note", "logo2.png");
owner.CreateNote("Work note", "logo3.png");
owner.CreateNote("Random note", "logo4.png");
searchName = "note";
}
[Test]
public void SearchFavoriteNoteByName_ShouldReturnMatchingNotes()
{
List<Note> searchedNotes = owner.SearchFavoriteNoteByName(owner.GetNoteList(), searchName);
Assert.That(searchedNotes, Has.Count.EqualTo(4));
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[0]);
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[1]);
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[2]);
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[3]);
}
[Test]
public void SearchFavoriteNoteByName_ShouldReturnEmptyList_WhenNoMatchFound()
{
searchName = "nonexistent";
List<Note> searchedNotes = owner.SearchFavoriteNoteByName(owner.GetNoteList(), searchName);
Assert.That(searchedNotes, Is.Empty);
}
}
}

@ -6,6 +6,7 @@ namespace Notus_UnitTest_User
public class SearchNoteByNameTests
{
private User owner;
private string searchName;
[SetUp]
public void SetUp()
@ -14,6 +15,7 @@ namespace Notus_UnitTest_User
owner.CreateNote("Note 1", "image1.png");
owner.CreateNote("Note 2", "image2.png");
owner.CreateNote("Another Note", "image3.png");
searchName = "note";
}
[Test]
@ -32,5 +34,23 @@ namespace Notus_UnitTest_User
List<Note> result = owner.SearchNoteByName(owner.GetNoteList(), "test");
Assert.That(result, Is.Empty);
}
[Test]
public void SearchFavoriteNoteByName_ShouldReturnMatchingNotes()
{
List<Note> searchedNotes = owner.SearchFavoriteNoteByName(owner.GetNoteList(), searchName);
Assert.That(searchedNotes, Has.Count.EqualTo(4));
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[0]);
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[1]);
CollectionAssert.Contains(searchedNotes, owner.GetNoteList()[2]);
}
[Test]
public void SearchFavoriteNoteByName_ShouldReturnEmptyList_WhenNoMatchFound()
{
searchName = "nonexistent";
List<Note> searchedNotes = owner.SearchFavoriteNoteByName(owner.GetNoteList(), searchName);
Assert.That(searchedNotes, Is.Empty);
}
}
}
Loading…
Cancel
Save