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,35 @@
using AwesomeAssertions;
using GerstITS.Examples.Logic.Customers;
using GerstITS.Examples.Logic.Customers.Customizations;
using GerstITS.System.Customizations;
using GerstITS.TestFramework;
using Xunit;
namespace GerstITS.Examples.Tests.Customers.Customizations;
[TestCategory(TestCategories.Unit)]
public sealed class CustomerDisplayNameCustomizationTest
{
#region Tests
[Fact]
public void If_a_customer_is_customized___The_display_name_is_composed()
{
ICustomization customization = new CustomerDisplayNameCustomization();
var customer = new Customer { FirstName = "Erika", LastName = "Mustermann" };
var customized = customization.Customize(customer, null);
customized.DisplayName.Should().Be("Mustermann, Erika");
}
[Fact]
public void If_the_customer_is_null___It_cannot_be_customized()
{
ICustomization customization = new CustomerDisplayNameCustomization();
customization.CanCustomize<Customer>(null, null).Should().BeFalse();
}
#endregion
}
@@ -0,0 +1,50 @@
using AwesomeAssertions;
using GerstITS.Examples.Logic.Customers;
using GerstITS.Examples.Logic.Customers.Search;
using GerstITS.TestFramework;
using Xunit;
namespace GerstITS.Examples.Tests.Customers.Search;
[TestCategory(TestCategories.Unit)]
public sealed class CustomerSearchFilterInitializationRuleTest
{
#region Tests
[Fact]
public void If_the_filter_is_empty___Defaults_are_applied()
{
var filter = new CustomerSearchFilter();
var initialized = new CustomerSearchFilterInitializationRule().Initialize(filter);
initialized.Skip.Should().Be(0);
initialized.Take.Should().Be(50);
initialized.SortBy.Should().Be(nameof(Customer.LastName));
}
[Fact]
public void If_the_filter_is_already_configured___Values_are_kept()
{
var filter = new CustomerSearchFilter
{
Skip = 10,
Take = 5,
SortBy = nameof(Customer.EMail)
};
var initialized = new CustomerSearchFilterInitializationRule().Initialize(filter);
initialized.Skip.Should().Be(10);
initialized.Take.Should().Be(5);
initialized.SortBy.Should().Be(nameof(Customer.EMail));
}
[Fact]
public void If_another_filter_type_is_checked___It_cannot_be_initialized()
{
new CustomerSearchFilterInitializationRule().CanInitialize<string>().Should().BeFalse();
}
#endregion
}
@@ -0,0 +1,67 @@
using AwesomeAssertions;
using GerstITS.Examples.Logic.Customers;
using GerstITS.Examples.Logic.Customers.Validation;
using GerstITS.TestFramework;
using Xunit;
namespace GerstITS.Examples.Tests.Customers.Validation;
[TestCategory(TestCategories.Unit)]
public sealed class CustomerValidationRuleTest
{
#region Tests
[Fact]
public void If_a_customer_is_complete___It_is_valid()
{
var customer = CreateCustomer();
var result = new CustomerValidationRule().Validate((object)customer);
result.IsValid.Should().BeTrue();
}
[Fact]
public void If_the_first_name_is_missing___It_is_invalid()
{
var customer = CreateCustomer();
customer.FirstName = string.Empty;
var result = new CustomerValidationRule().Validate((object)customer);
result.IsValid.Should().BeFalse();
}
[Fact]
public void If_the_email_has_no_valid_format___It_is_invalid()
{
var customer = CreateCustomer();
customer.EMail = "not-an-email";
var result = new CustomerValidationRule().Validate((object)customer);
result.IsValid.Should().BeFalse();
}
[Fact]
public void If_a_customer_type_is_checked___It_can_be_validated()
{
new CustomerValidationRule().CanValidate(typeof(Customer)).Should().BeTrue();
}
#endregion
#region Methods
private static Customer CreateCustomer()
{
return new Customer
{
FirstName = "Erika",
LastName = "Mustermann",
EMail = "erika.mustermann@example.com"
};
}
#endregion
}