mirror of https://github.com/ErsatzTV/ErsatzTV.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.4 KiB
38 lines
1.4 KiB
using ErsatzTV.Application.MediaCards; |
|
using ErsatzTV.Pages; |
|
using NUnit.Framework; |
|
using Shouldly; |
|
using System.Collections.Generic; |
|
|
|
namespace ErsatzTV.Core.Tests.Pages; |
|
|
|
[TestFixture] |
|
public class MediaCardSelectionHelperTests |
|
{ |
|
[Test] |
|
public void Should_replace_existing_selection_and_return_last_card() |
|
{ |
|
var existingCard = new MediaCardViewModel(1, "Existing", "Sub", "Existing", "", Core.Domain.MediaItemState.Normal, false); |
|
var selected = new HashSet<MediaCardViewModel> { existingCard }; |
|
|
|
var first = new MediaCardViewModel(2, "First", "Sub", "First", "", Core.Domain.MediaItemState.Normal, false); |
|
var second = new MediaCardViewModel(3, "Second", "Sub", "Second", "", Core.Domain.MediaItemState.Normal, false); |
|
|
|
MediaCardViewModel last = MultiSelectBase<Search>.ResetSelectionWithCards(selected, new[] { first, second }); |
|
|
|
selected.ShouldBe(new[] { first, second }, ignoreOrder: true); |
|
last.ShouldBe(second); |
|
} |
|
|
|
[Test] |
|
public void Should_clear_selection_when_no_cards() |
|
{ |
|
var existingCard = new MediaCardViewModel(1, "Existing", "Sub", "Existing", "", Core.Domain.MediaItemState.Normal, false); |
|
var selected = new HashSet<MediaCardViewModel> { existingCard }; |
|
|
|
MediaCardViewModel last = MultiSelectBase<Search>.ResetSelectionWithCards(selected, []); |
|
|
|
selected.ShouldBeEmpty(); |
|
last.ShouldBeNull(); |
|
} |
|
}
|
|
|