refactor(tests): migrate Database.Tests from FluentAssertions to Shouldly
Replace FluentAssertions with Shouldly across all 6 test files (94 tests). Add ShouldlyExtensions for BeCloseTo and BeEquivalentTo patterns.
This commit is contained in:
@@ -228,3 +228,26 @@ public class WorkOrderViewModel
|
||||
// Avoid: record types for DTOs
|
||||
public record WorkOrderViewModel(string OrderNumber, DateTime? CompletionDate);
|
||||
```
|
||||
|
||||
### Test Assertions: Use Shouldly, Not FluentAssertions
|
||||
|
||||
This project uses **Shouldly** for test assertions. Do not use FluentAssertions.
|
||||
|
||||
```csharp
|
||||
// Preferred: Shouldly
|
||||
result.ShouldBe(expected);
|
||||
result.ShouldBeNull();
|
||||
result.ShouldNotBeNull();
|
||||
list.ShouldBeEmpty();
|
||||
list.Count().ShouldBe(3);
|
||||
await Should.ThrowAsync<SqlException>(act);
|
||||
|
||||
// Avoid: FluentAssertions
|
||||
result.Should().Be(expected);
|
||||
result.Should().BeNull();
|
||||
await act.Should().ThrowAsync<SqlException>();
|
||||
```
|
||||
|
||||
Custom extension methods in `Infrastructure/ShouldlyExtensions.cs` provide additional assertions:
|
||||
- `ShouldBeCloseTo(DateTime, TimeSpan)` - DateTime tolerance comparison
|
||||
- `ShouldBeEquivalentTo<T>(IEnumerable<T>)` - Collection equivalence (order-independent)
|
||||
|
||||
Reference in New Issue
Block a user