-
-
Notifications
You must be signed in to change notification settings - Fork 364
feat(MultiFilter): add StringComparison parameter #6010
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,8 +101,9 @@ public async Task MultiFilter_Ok() | |
| { | ||
| b.OpenComponent<MultiFilter>(0); | ||
| b.AddAttribute(1, nameof(MultiFilter.ShowSearch), true); | ||
| b.AddAttribute(2, nameof(MultiFilter.OnGetItemsAsync), () => Task.FromResult(new List<SelectedItem>() { new("test1", "test1") })); | ||
| b.AddAttribute(1, nameof(MultiFilter.AlwaysTriggerGetItems), true); | ||
| b.AddAttribute(2, nameof(MultiFilter.StringComparison), StringComparison.OrdinalIgnoreCase); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Consider adding tests to verify different Add tests covering each StringComparison mode. For each (e.g. Ordinal, CurrentCulture, OrdinalIgnoreCase), use items with varied casing (e.g., “Apple”, “apple”, “APPLE”), perform a search, and assert that results match the expected case-sensitive or case-insensitive behavior. Suggested implementation: using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Xunit;
public class TableFilterStringComparisonTests
{
[Fact]
public async Task Test_StringComparison_Ordinal()
{
// Arrange: Ordinal comparison is case-sensitive so only the exact match should be returned.
var filter = new MultiFilter
{
StringComparison = StringComparison.Ordinal
};
var items = new List<SelectedItem>
{
new SelectedItem("Apple", "Apple"),
new SelectedItem("apple", "apple"),
new SelectedItem("APPLE", "APPLE")
};
// Act: Perform search using "Apple" as query.
var result = await filter.GetItemsAsync("Apple", items);
// Assert: Only "Apple" should match.
Assert.Single(result);
Assert.Equal("Apple", result.First().Text);
}
[Fact]
public async Task Test_StringComparison_OrdinalIgnoreCase()
{
// Arrange: OrdinalIgnoreCase comparison returns matches regardless of casing.
var filter = new MultiFilter
{
StringComparison = StringComparison.OrdinalIgnoreCase
};
var items = new List<SelectedItem>
{
new SelectedItem("Apple", "Apple"),
new SelectedItem("apple", "apple"),
new SelectedItem("APPLE", "APPLE")
};
// Act: Perform search using "Apple" as query.
var result = await filter.GetItemsAsync("Apple", items);
// Assert: All three items should match.
Assert.Equal(3, result.Count);
}
[Fact]
public async Task Test_StringComparison_CurrentCulture()
{
// Arrange: CurrentCulture comparison is typically case-sensitive.
var filter = new MultiFilter
{
StringComparison = StringComparison.CurrentCulture
};
var items = new List<SelectedItem>
{
new SelectedItem("Apple", "Apple"),
new SelectedItem("apple", "apple"),
new SelectedItem("APPLE", "APPLE")
};
// Act: Perform search using "Apple" as query.
var result = await filter.GetItemsAsync("Apple", items);
// Assert: Only the item with exact casing "Apple" should be returned.
Assert.Single(result);
Assert.Equal("Apple", result.First().Text);
}
}
// End of fileMake sure that:
|
||
| b.AddAttribute(3, nameof(MultiFilter.OnGetItemsAsync), () => Task.FromResult(new List<SelectedItem>() { new("test1", "test1") })); | ||
| b.AddAttribute(4, nameof(MultiFilter.AlwaysTriggerGetItems), true); | ||
| b.CloseComponent(); | ||
| })); | ||
| builder.CloseComponent(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.