Update to latest packages and show examples

This commit is contained in:
2026-07-05 22:05:53 +02:00
parent 3a36978997
commit c7ddc282ed
52 changed files with 2156 additions and 21 deletions
@@ -0,0 +1,57 @@
using AwesomeAssertions;
using GerstITS.Examples.Logic.Customers;
using GerstITS.Examples.Logic.Shared.Search.Sorting;
using GerstITS.Search;
using GerstITS.TestFramework;
using Xunit;
namespace GerstITS.Examples.Tests.Shared.Search.Sorting;
[TestCategory(TestCategories.Unit)]
public sealed class SortingProviderTest
{
#region Tests
[Fact]
public void If_customers_are_sorted_descending___The_order_is_reversed()
{
var query = CreateCustomers().AsQueryable();
var sorting = new CustomerSearchFilter { SortBy = nameof(Customer.LastName), SortDirection = SortingDirections.Descending };
var sorted = new SortingProvider().Sort(query, sorting);
sorted.First().LastName.Should().Be("Zimmermann");
}
[Fact]
public void If_the_sort_property_is_unknown___The_query_is_left_unchanged()
{
var query = CreateCustomers().AsQueryable();
var sorting = new CustomerSearchFilter { SortBy = "Unknown" };
var sorted = new SortingProvider().Sort(query, sorting);
sorted.Last().LastName.Should().Be("Zimmermann");
}
[Fact]
public void If_the_item_type_is_not_sortable___It_cannot_be_sorted()
{
new SortingProvider().CanSort(new[] { "a" }.AsQueryable()).Should().BeFalse();
}
#endregion
#region Methods
private static IEnumerable<Customer> CreateCustomers()
{
return new[]
{
new Customer { FirstName = "Anna", LastName = "Albrecht" },
new Customer { FirstName = "Zoe", LastName = "Zimmermann" }
};
}
#endregion
}
@@ -0,0 +1,30 @@
using AwesomeAssertions;
using GerstITS.Examples.Logic.Shared.Validation;
using GerstITS.TestFramework;
using Xunit;
namespace GerstITS.Examples.Tests.Shared.Validation;
[TestCategory(TestCategories.Unit)]
public sealed class IdValidationRuleTest
{
#region Tests
[Fact]
public void If_the_id_is_positive___It_is_valid()
{
var result = new IdValidationRule().Validate((object)1);
result.IsValid.Should().BeTrue();
}
[Fact]
public void If_the_id_is_zero___It_is_invalid()
{
var result = new IdValidationRule().Validate((object)0);
result.IsValid.Should().BeFalse();
}
#endregion
}