Added initial voice work search provider logic.
This commit is contained in:
92
JSMR.Tests/Integration/VoiceWorkSearchProviderTests.cs
Normal file
92
JSMR.Tests/Integration/VoiceWorkSearchProviderTests.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user