PosInformatique.Foundations.People.FluentAssertions
1.0.0-alpha.6
Prefix Reserved
dotnet add package PosInformatique.Foundations.People.FluentAssertions --version 1.0.0-alpha.6
NuGet\Install-Package PosInformatique.Foundations.People.FluentAssertions -Version 1.0.0-alpha.6
<PackageReference Include="PosInformatique.Foundations.People.FluentAssertions" Version="1.0.0-alpha.6" />
<PackageVersion Include="PosInformatique.Foundations.People.FluentAssertions" Version="1.0.0-alpha.6" />
<PackageReference Include="PosInformatique.Foundations.People.FluentAssertions" />
paket add PosInformatique.Foundations.People.FluentAssertions --version 1.0.0-alpha.6
#r "nuget: PosInformatique.Foundations.People.FluentAssertions, 1.0.0-alpha.6"
#:package PosInformatique.Foundations.People.FluentAssertions@1.0.0-alpha.6
#addin nuget:?package=PosInformatique.Foundations.People.FluentAssertions&version=1.0.0-alpha.6&prerelease
#tool nuget:?package=PosInformatique.Foundations.People.FluentAssertions&version=1.0.0-alpha.6&prerelease
PosInformatique.Foundations.People.FluentAssertions
Introduction
Assertion extensions for FirstName
and LastName
value objects from
PosInformatique.Foundations.People
using FluentAssertions.
This package resolves the ambiguity that occurs when using FluentAssertions directly on these value
objects and provides a simple, idiomatic assertion API where Be(string)
compares the literal content
(case-sensitive for FirstName
, uppercased for LastName
as per normalization).
Why this package?
FirstName
andLastName
implement bothIEnumerable<char>
andIComparable<T>
.- Calling
Should()
from FluentAssertions on such types leads to a compile-time ambiguity:- The call is ambiguous between the following methods or properties:
AssertionExtensions.Should<T>(IEnumerable<T>)
andAssertionExtensions.Should<T>(IComparable<T>)
- The call is ambiguous between the following methods or properties:
- This package introduces dedicated
Should()
extensions that return specialized assertions to avoid that ambiguity.
Install
You can install the package from NuGet:
dotnet add package PosInformatique.Foundations.People.FluentAssertions
Features
Should()
extension forFirstName
returningFirstNameAssertions
.Should()
extension forLastName
returningLastNameAssertions
.Be(string)
compares the value object to a string using the normalized literal content:- For
FirstName
, comparison is case-sensitive against the normalized first name (e.g., "Jean-Pierre"). - For
LastName
, comparison is case-sensitive against the normalized last name (e.g., "DUPONT").
- For
Examples
Basic usage with FirstName
:
using FluentAssertions;
using PosInformatique.Foundations.People;
var firstName = FirstName.Create("jean-pierre");
// Passes: "jean-pierre" is normalized to "Jean-Pierre"
firstName.Should().Be("Jean-Pierre");
// Fails (case-sensitive): expected "JEAN-PIERRE"
firstName.Should().Be("JEAN-PIERRE");
Basic usage with LastName
:
using FluentAssertions;
using PosInformatique.Foundations.People;
var lastName = LastName.Create("dupont");
// Passes: normalization uppercases to "DUPONT"
lastName.Should().Be("DUPONT");
// Fails (case-sensitive): expected "Dupont"
lastName.Should().Be("Dupont");
Using with your domain model:
using FluentAssertions;
using PosInformatique.Foundations.People;
public sealed class User
{
public User(string firstName, string lastName)
{
FirstName = FirstName.Create(firstName);
LastName = LastName.Create(lastName);
}
public FirstName FirstName { get; }
public LastName LastName { get; }
}
var user = new User("alice", "martin");
user.FirstName.Should().Be("Alice");
user.LastName.Should().Be("MARTIN");
Links
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- FluentAssertions (>= 7.2.0)
- PosInformatique.Foundations.People (>= 1.0.0-alpha.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0-alpha.6 | 58 | 10/10/2025 |
1.0.0
- Initial release with the support FluentAssertions to assert the FirstName and LastName value objects.