
Security News
minimatch Patches 3 High-Severity ReDoS Vulnerabilities
minimatch patched three high-severity ReDoS vulnerabilities that can stall the Node.js event loop, and Socket has released free certified patches.
functionalddd.testing
Advanced tools
Testing utilities and FluentAssertions extensions for FunctionalDDD - Write expressive, maintainable tests for Railway-Oriented Programming patterns.
dotnet add package FunctionalDDD.Testing
✅ FluentAssertions Extensions - Expressive assertions for Result<T>, Maybe<T>, and Error types
🏗️ Test Builders - Fluent builders for creating test data
🎭 Fake Implementations - In-memory fakes for repositories and infrastructure
📖 Readable Tests - Write tests that read like specifications
💡 IntelliSense Support - Discover test utilities through IntelliSense
using FunctionalDdd.Testing;
[Fact]
public void Should_Return_Success()
{
var result = EmailAddress.TryCreate("user@example.com");
result.Should()
.BeSuccess()
.Which.Value.Should().Contain("@");
}
[Fact]
public void Should_Return_NotFound_Error()
{
var result = _repository.GetByIdAsync(userId, ct);
result.Should()
.BeFailureOfType<NotFoundError>()
.Which.Should()
.HaveDetail("User not found");
}
[Fact]
public void Should_Have_Multiple_Validation_Errors()
{
var result = CreateUser("", "invalid-email", 15);
result.Should()
.BeFailureOfType<ValidationError>()
.Which.Should()
.HaveFieldCount(3)
.And.HaveFieldError("firstName")
.And.HaveFieldError("email")
.And.HaveFieldErrorWithDetail("age", "Must be 18 or older");
}
[Fact]
public void Should_Have_Value()
{
var maybe = Maybe.From("hello");
maybe.Should()
.HaveValue()
.Which.Should().Be("hello");
}
[Fact]
public void Should_Be_None()
{
var maybe = Maybe.None<string>();
maybe.Should().BeNone();
}
[Fact]
public void Should_Handle_NotFound()
{
var result = ResultBuilder.NotFound<User>("User not found");
result.Should()
.BeFailureOfType<NotFoundError>();
}
[Fact]
public void Should_Build_Complex_Validation_Error()
{
var error = ValidationErrorBuilder.Create()
.WithFieldError("email", "Email is required")
.WithFieldError("email", "Invalid email format")
.WithFieldError("age", "Must be 18 or older")
.Build();
error.Should()
.HaveFieldCount(2)
.And.HaveFieldErrorWithDetail("email", "Email is required");
}
public class UserServiceTests
{
private readonly FakeRepository<User, UserId> _fakeRepository;
private readonly UserService _sut;
public UserServiceTests()
{
_fakeRepository = new FakeRepository<User, UserId>();
_sut = new UserService(_fakeRepository);
}
[Fact]
public async Task Should_Save_User_And_Publish_Event()
{
// Arrange
var command = new CreateUserCommand("John", "Doe", "john@example.com");
// Act
var result = await _sut.CreateUserAsync(command, CancellationToken.None);
// Assert
result.Should().BeSuccess();
_fakeRepository.Exists(result.Value.Id).Should().BeTrue();
_fakeRepository.PublishedEvents.Should().ContainSingle()
.Which.Should().BeOfType<UserCreatedEvent>();
}
}
| Method | Description |
|---|---|
BeSuccess() | Asserts the result is a success |
BeFailure() | Asserts the result is a failure |
BeFailureOfType<TError>() | Asserts the result failed with a specific error type |
HaveValue(expected) | Asserts the success value equals the expected value |
HaveValueMatching(predicate) | Asserts the success value satisfies a predicate |
| Method | Description |
|---|---|
HaveCode(code) | Asserts the error has the specified code |
HaveDetail(detail) | Asserts the error has the specified detail message |
HaveDetailContaining(substring) | Asserts the error detail contains a substring |
BeOfType<TError>() | Asserts the error is of a specific type |
| Method | Description |
|---|---|
HaveFieldError(fieldName) | Asserts the validation error contains a field error |
HaveFieldErrorWithDetail(field, detail) | Asserts a field has a specific error detail |
HaveFieldCount(count) | Asserts the number of field errors |
| Method | Description |
|---|---|
HaveValue() | Asserts the Maybe has a value |
BeNone() | Asserts the Maybe has no value |
HaveValueEqualTo(expected) | Asserts the value equals the expected value |
| Before | After |
|---|---|
result.IsSuccess.Should().BeTrue() | result.Should().BeSuccess() |
result.Error.Should().BeOfType<NotFoundError>() | result.Should().BeFailureOfType<NotFoundError>() |
maybe.HasValue.Should().BeTrue() | maybe.Should().HaveValue() |
| Manual repository setup with mocks | new FakeRepository<User, UserId>() |
Advantages:
MIT
Contributions are welcome! See the main repository for guidelines.
FAQs
Unknown package
We found that functionalddd.testing demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
minimatch patched three high-severity ReDoS vulnerabilities that can stall the Node.js event loop, and Socket has released free certified patches.

Research
/Security News
Socket uncovered 26 malicious npm packages tied to North Korea's Contagious Interview campaign, retrieving a live 9-module infostealer and RAT from the adversary's C2.

Research
An impersonated golang.org/x/crypto clone exfiltrates passwords, executes a remote shell stager, and delivers a Rekoobe backdoor on Linux.