Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 26 additions & 20 deletions test/UnitTest/Extensions/QueryPageOptionsExtensionsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,25 +176,31 @@ public void Serialize_Ok()
model.AdvancedSortList.AddRange(["Name7", "Count7"]);

var payload = JsonSerializer.Serialize(model);
var expacted = JsonSerializer.Deserialize<QueryPageOptions>(payload);
Assert.NotNull(expacted);
Assert.Equal("SearchText", expacted.SearchText);
Assert.Equal("Name1", expacted.SortName);
Assert.Equal(3, expacted.StartIndex);
Assert.Equal(4, expacted.PageIndex);
Assert.Equal(5, expacted.PageItems);
Assert.Equal(SortOrder.Asc, expacted.SortOrder);
Assert.True(expacted.IsFirstQuery);
Assert.True(expacted.IsTriggerByPagination);
Assert.True(expacted.IsPage);
Assert.True(expacted.IsVirtualScroll);
Assert.NotNull(expacted.SearchModel);

Assert.Single(expacted.Searches);
Assert.Single(expacted.AdvanceSearches);
Assert.Single(expacted.CustomerSearches);
Assert.Single(expacted.Filters);
Assert.Equal(2, expacted.SortList.Count);
Assert.Equal(2, expacted.AdvancedSortList.Count);
var expected = JsonSerializer.Deserialize<QueryPageOptions>(payload);
Assert.NotNull(expected);
Assert.Equal("SearchText", expected.SearchText);
Assert.Equal("Name1", expected.SortName);
Assert.Equal(3, expected.StartIndex);
Assert.Equal(4, expected.PageIndex);
Assert.Equal(5, expected.PageItems);
Assert.Equal(SortOrder.Asc, expected.SortOrder);
Assert.True(expected.IsFirstQuery);
Assert.True(expected.IsTriggerByPagination);
Assert.True(expected.IsPage);
Assert.True(expected.IsVirtualScroll);
Assert.NotNull(expected.SearchModel);

// 临时更改为空集合
Assert.Empty(expected.Searches);
Assert.Empty(expected.AdvanceSearches);
Assert.Empty(expected.CustomerSearches);
Assert.Empty(expected.Filters);

//Assert.Single(expected.Searches);
//Assert.Single(expected.AdvanceSearches);
//Assert.Single(expected.CustomerSearches);
//Assert.Single(expected.Filters);
Comment on lines +193 to +202
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment "临时更改为空集合" (temporary change to empty collection) indicates this is a work-in-progress change. This test is now checking for empty collections instead of single items, which contradicts the test setup where items are explicitly added to these collections (lines 171-174). This makes the test ineffective as it no longer validates the serialization/deserialization of these collections.

Suggested change
// 临时更改为空集合
Assert.Empty(expected.Searches);
Assert.Empty(expected.AdvanceSearches);
Assert.Empty(expected.CustomerSearches);
Assert.Empty(expected.Filters);
//Assert.Single(expected.Searches);
//Assert.Single(expected.AdvanceSearches);
//Assert.Single(expected.CustomerSearches);
//Assert.Single(expected.Filters);
Assert.Single(expected.Searches);
Assert.Single(expected.AdvanceSearches);
Assert.Single(expected.CustomerSearches);
Assert.Single(expected.Filters);

Copilot uses AI. Check for mistakes.
Comment on lines +199 to +202
Copy link

Copilot AI Dec 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commented-out assertions should either be removed or uncommented. Leaving commented code in the codebase reduces maintainability and creates confusion about which assertions are actually being tested.

Suggested change
//Assert.Single(expected.Searches);
//Assert.Single(expected.AdvanceSearches);
//Assert.Single(expected.CustomerSearches);
//Assert.Single(expected.Filters);

Copilot uses AI. Check for mistakes.
Assert.Equal(2, expected.SortList.Count);
Assert.Equal(2, expected.AdvancedSortList.Count);
}
}
Loading