Finished voice work search provider implementation, and added several more tests.
This commit is contained in:
@@ -174,4 +174,544 @@ public class VoiceWorkSearchProviderTests(VoiceWorkSearchProviderFixture fixture
|
||||
result.TotalItems.ShouldBe(1);
|
||||
result.Items.ShouldAllBe(item => (item.Description ?? string.Empty).Contains("All Your Favorite", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Tags_Favorite_Exclude_Blacklisted()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
TagStatus = TagStatus.FavoriteExcludeBlacklist
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(1);
|
||||
result.TotalItems.ShouldBe(1);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000002"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Tags_Favorite_Include_Blacklisted()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
TagStatus = TagStatus.FavoriteIncludeBlacklist
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(2);
|
||||
result.TotalItems.ShouldBe(2);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000002", "RJ0000003"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Tags_Not_Blacklisted()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
TagStatus = TagStatus.NotBlacklisted
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(4);
|
||||
result.TotalItems.ShouldBe(4);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000001", "RJ0000002", "RJ0000004", "RJ0000005"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Tags_Blacklisted()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
TagStatus = TagStatus.Blacklisted
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(1);
|
||||
result.TotalItems.ShouldBe(1);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000003"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_TagIds_Or()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
TagIds = [1,2],
|
||||
IncludeAllTags = false
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(2);
|
||||
result.TotalItems.ShouldBe(2);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000001", "RJ0000002"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_TagIds_And()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
TagIds = [1, 2],
|
||||
IncludeAllTags = true
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(1);
|
||||
result.TotalItems.ShouldBe(1);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000001"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Creators_Favorite_Exclude_Blacklisted()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
CreatorStatus = CreatorStatus.FavoriteExcludeBlacklist
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(2);
|
||||
result.TotalItems.ShouldBe(2);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000002", "RJ0000005"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Creators_Favorite_Include_Blacklisted()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
CreatorStatus = CreatorStatus.FavoriteIncludeBlacklist
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(3);
|
||||
result.TotalItems.ShouldBe(3);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000002", "RJ0000003", "RJ0000005"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Creators_Not_Blacklisted()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
CreatorStatus = CreatorStatus.NotBlacklisted
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(4);
|
||||
result.TotalItems.ShouldBe(4);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000001", "RJ0000002", "RJ0000004", "RJ0000005"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Creators_Blacklisted()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
CreatorStatus = CreatorStatus.Blacklisted
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(1);
|
||||
result.TotalItems.ShouldBe(1);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000003"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_CreatorIds_Or()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
CreatorIds = [1, 4],
|
||||
IncludeAllCreators = false
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(3);
|
||||
result.TotalItems.ShouldBe(3);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000002", "RJ0000003", "RJ0000005"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_CreatorIds_And()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
CreatorIds = [1, 4],
|
||||
IncludeAllCreators = true
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items.Length.ShouldBe(1);
|
||||
result.TotalItems.ShouldBe(1);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000005"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Sort_By_Release_Date_Ascending()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
SortOptions =
|
||||
[
|
||||
new(VoiceWorkSortField.ReleaseDate, Application.Common.Search.SortDirection.Ascending)
|
||||
]
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000001", "RJ0000004", "RJ0000003", "RJ0000002", "RJ0000005"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Sort_By_Release_Date_Descending()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
SortOptions =
|
||||
[
|
||||
new(VoiceWorkSortField.ReleaseDate, Application.Common.Search.SortDirection.Descending)
|
||||
]
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000005", "RJ0000002", "RJ0000003", "RJ0000001", "RJ0000004"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Sort_By_Downloads_Ascending()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
SortOptions =
|
||||
[
|
||||
new(VoiceWorkSortField.Downloads, Application.Common.Search.SortDirection.Ascending)
|
||||
]
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000004", "RJ0000005", "RJ0000003", "RJ0000001", "RJ0000002"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Sort_By_Downloads_Descending()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
SortOptions =
|
||||
[
|
||||
new(VoiceWorkSortField.Downloads, Application.Common.Search.SortDirection.Descending)
|
||||
]
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000002", "RJ0000001", "RJ0000003", "RJ0000004", "RJ0000005"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Sort_By_WishlistCount_Ascending()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
SortOptions =
|
||||
[
|
||||
new(VoiceWorkSortField.WishlistCount, Application.Common.Search.SortDirection.Ascending)
|
||||
]
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000003", "RJ0000004", "RJ0000001", "RJ0000005", "RJ0000002"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Sort_By_WishlistCount_Descending()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
SortOptions =
|
||||
[
|
||||
new(VoiceWorkSortField.WishlistCount, Application.Common.Search.SortDirection.Descending)
|
||||
]
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000002", "RJ0000005", "RJ0000001", "RJ0000004", "RJ0000003"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Sort_By_StarRating_Ascending()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
SortOptions =
|
||||
[
|
||||
new(VoiceWorkSortField.StarRating, Application.Common.Search.SortDirection.Ascending)
|
||||
]
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000004", "RJ0000005", "RJ0000003", "RJ0000001", "RJ0000002"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Sort_By_StarRating_Descending()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
SortOptions =
|
||||
[
|
||||
new(VoiceWorkSortField.StarRating, Application.Common.Search.SortDirection.Descending)
|
||||
]
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000002", "RJ0000001", "RJ0000003", "RJ0000004", "RJ0000005"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Release_Date_Range()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
ReleaseDateStart = new DateTime(2025, 1, 1),
|
||||
ReleaseDateEnd = new DateTime(2025, 1, 2)
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000001", "RJ0000003"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Downloads_Range()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
MinDownloads = 100,
|
||||
MaxDownloads = 10000
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000001", "RJ0000002"]);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Filter_Favorite()
|
||||
{
|
||||
await using AppDbContext context = fixture.CreateDbContext();
|
||||
VoiceWorkSearchProvider provider = InitializeVoiceWorkSearchProvider(context);
|
||||
|
||||
var options = new SearchOptions<VoiceWorkSearchCriteria, VoiceWorkSortField>()
|
||||
{
|
||||
Criteria = new()
|
||||
{
|
||||
ShowFavoriteVoiceWorks = true
|
||||
}
|
||||
};
|
||||
|
||||
var result = await provider.SearchAsync(options);
|
||||
|
||||
result.Items
|
||||
.OrderBy(item => item.ProductId)
|
||||
.Select(item => item.ProductId)
|
||||
.ShouldBe(["RJ0000002"]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user