-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
Description
Part of #94 - Migrate tests to AwesomeAssertions
File Details
- Path:
test/LoggerUsage.Tests/LoggerMessageAttributeTests.cs - Lines: 3,548
- Assertions: ~450
- Test Methods: 56 (51 Facts, 5 Theories)
- Complexity: ⭐⭐⭐⭐⭐ Very High
Scope
This is the largest and most complex test file in the project. It contains extensive tests for LoggerMessage attribute analysis including:
- Event ID and event name scenarios
- Log level variations
- Message template parsing
- Parameter extraction
- Complex nested assertions with
Assert.IsType<T>
Migration Checklist
- Add
using AwesomeAssertions;at the top - Replace
Assert.NotNull()→.Should().NotBeNull() - Replace
Assert.Single()→.Should().ContainSingle() - Replace
Assert.Equal()→.Should().Be() - Replace
Assert.IsType<T>()→.Should().BeOfType<T>().Which - Replace
Assert.Empty()→.Should().BeEmpty() - Replace
Assert.Contains()→.Should().Contain() - Replace
Assert.True()/Assert.False()→.Should().BeTrue()/.Should().BeFalse() - Run tests and verify all pass
Example Transformations
Before:
Assert.NotNull(loggerUsages);
Assert.Single(loggerUsages.Results);
var details = Assert.IsType<EventIdDetails>(loggerUsages.Results[0].EventId);
Assert.Equal(6, details.Id.Value);After:
loggerUsages.Should().NotBeNull();
loggerUsages.Results.Should().ContainSingle()
.Which.EventId.Should().BeOfType<EventIdDetails>()
.Which.Id.Value.Should().Be(6);Tips
- Use
.Whichfor chaining assertions on collection elements - Consider using
AssertionScopefor multiple related assertions - Test complex scenarios first to ensure patterns work correctly
Copilot