92 lines
3.0 KiB
C#
92 lines
3.0 KiB
C#
using JSMR.Application.Common.Search;
|
|
using JSMR.Application.VoiceWorks.Queries.Search;
|
|
using JSMR.Infrastructure.Data;
|
|
using JSMR.Infrastructure.Data.Repositories.VoiceWorks;
|
|
using JSMR.Tests.Fixtures;
|
|
using Shouldly;
|
|
|
|
namespace JSMR.Tests.Integration;
|
|
|
|
public class VoiceWorkSearchProviderTests(VoiceWorkSearchProviderFixture fixture) : IClassFixture<VoiceWorkSearchProviderFixture>
|
|
{
|
|
[Fact]
|
|
public async Task Filter_Default()
|
|
{
|
|
await using AppDbContext context = fixture.CreateDbContext();
|
|
VoiceWorkSearchProvider provider = new(context);
|
|
|
|
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
|
{
|
|
Criteria = new()
|
|
{
|
|
SaleStatus = SaleStatus.Available,
|
|
CircleStatus = CircleStatus.NotBlacklisted
|
|
},
|
|
SortOptions =
|
|
[
|
|
new(VoiceWorkSortField.ReleaseDate, Application.Common.Search.SortDirection.Descending)
|
|
]
|
|
};
|
|
|
|
var result = await provider.SearchAsync(options);
|
|
|
|
result.Items.Length.ShouldBe(2);
|
|
result.TotalItems.ShouldBe(2);
|
|
result.Items.ShouldAllBe(item => item.SalesDate != null);
|
|
result.Items.ShouldNotContain(item => item.ExpectedDate != null);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Filter_Upcoming_Favorite()
|
|
{
|
|
await using AppDbContext context = fixture.CreateDbContext();
|
|
VoiceWorkSearchProvider provider = new(context);
|
|
|
|
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
|
{
|
|
Criteria = new()
|
|
{
|
|
SaleStatus = SaleStatus.Upcoming,
|
|
CircleStatus = CircleStatus.Favorited
|
|
},
|
|
SortOptions =
|
|
[
|
|
new(VoiceWorkSortField.ReleaseDate, Application.Common.Search.SortDirection.Descending)
|
|
]
|
|
};
|
|
|
|
var result = await provider.SearchAsync(options);
|
|
|
|
result.Items.Length.ShouldBe(1);
|
|
result.TotalItems.ShouldBe(1);
|
|
result.Items.ShouldAllBe(item => item.ExpectedDate != null);
|
|
result.Items.ShouldNotContain(item => item.SalesDate != null);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Filter_Availble_Blacklisted()
|
|
{
|
|
await using AppDbContext context = fixture.CreateDbContext();
|
|
VoiceWorkSearchProvider provider = new(context);
|
|
|
|
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
|
{
|
|
Criteria = new()
|
|
{
|
|
SaleStatus = SaleStatus.Available,
|
|
CircleStatus = CircleStatus.Blacklisted
|
|
},
|
|
SortOptions =
|
|
[
|
|
new(VoiceWorkSortField.ReleaseDate, Application.Common.Search.SortDirection.Descending)
|
|
]
|
|
};
|
|
|
|
var result = await provider.SearchAsync(options);
|
|
|
|
result.Items.Length.ShouldBe(1);
|
|
result.TotalItems.ShouldBe(1);
|
|
result.Items.ShouldAllBe(item => item.SalesDate != null);
|
|
result.Items.ShouldNotContain(item => item.ExpectedDate != null);
|
|
}
|
|
} |