From 62a3eb25624c2bfe409c69f1efbb6671b2cc645f Mon Sep 17 00:00:00 2001 From: codefox Date: Fri, 22 May 2026 11:56:48 +0200 Subject: [PATCH] test: align aaa comments across tests --- .../Api/ApiRoutesTests.cs | 43 ++++++++++++++----- .../Common/ErrorTests.Conflict.cs | 4 ++ .../Common/ErrorTests.ErrorCode.cs | 8 ++++ .../Common/ErrorTests.NoError.cs | 2 + .../Common/ErrorTests.NotFound.cs | 4 ++ .../Common/ErrorTests.Unknown.cs | 2 + .../Common/ErrorTests.Validation.cs | 12 ++++++ .../Common/DomainErrorTests.cs | 10 +++++ .../Products/ProductTests.cs | 6 +++ .../SharedKernel/CurrencyTests.cs | 38 ++++++++++++++++ .../SharedKernel/Iso4217CurrencyCodesTests.cs | 6 +++ .../SharedKernel/MoneyTests.cs | 22 ++++++++++ 12 files changed, 146 insertions(+), 11 deletions(-) diff --git a/content/tests/Company.Template.Api.Tests/Api/ApiRoutesTests.cs b/content/tests/Company.Template.Api.Tests/Api/ApiRoutesTests.cs index 0a330ef..08207e9 100644 --- a/content/tests/Company.Template.Api.Tests/Api/ApiRoutesTests.cs +++ b/content/tests/Company.Template.Api.Tests/Api/ApiRoutesTests.cs @@ -7,21 +7,42 @@ public sealed class ApiRoutesTests [Fact] public void ProductsRoutes_ShouldExposeExpectedRouteTemplates() { - ApiRoutes.Root.ShouldBe("/api"); - ApiRoutes.Products.Base.ShouldBe("/api/products"); - ApiRoutes.Products.Collection.ShouldBe(""); - ApiRoutes.Products.ById.ShouldBe("/{productId:guid}"); - ApiRoutes.Products.Price.ShouldBe("/{productId:guid}/price"); - ApiRoutes.Products.Discontinue.ShouldBe("/{productId:guid}/discontinue"); + // Arrange + + // Act + string root = ApiRoutes.Root; + string productsBase = ApiRoutes.Products.Base; + string collection = ApiRoutes.Products.Collection; + string byId = ApiRoutes.Products.ById; + string price = ApiRoutes.Products.Price; + string discontinue = ApiRoutes.Products.Discontinue; + + // Assert + root.ShouldBe("/api"); + productsBase.ShouldBe("/api/products"); + collection.ShouldBe(""); + byId.ShouldBe("/{productId:guid}"); + price.ShouldBe("/{productId:guid}/price"); + discontinue.ShouldBe("/{productId:guid}/discontinue"); } [Fact] public void ProductsRouteNames_ShouldExposeExpectedNames() { - ApiRoutes.Products.Names.GetProducts.ShouldBe("GetProducts"); - ApiRoutes.Products.Names.CreateProduct.ShouldBe("CreateProduct"); - ApiRoutes.Products.Names.GetProductById.ShouldBe("GetProductById"); - ApiRoutes.Products.Names.ChangeProductPrice.ShouldBe("ChangeProductPrice"); - ApiRoutes.Products.Names.DiscontinueProduct.ShouldBe("DiscontinueProduct"); + // Arrange + + // Act + string getProducts = ApiRoutes.Products.Names.GetProducts; + string createProduct = ApiRoutes.Products.Names.CreateProduct; + string getProductById = ApiRoutes.Products.Names.GetProductById; + string changeProductPrice = ApiRoutes.Products.Names.ChangeProductPrice; + string discontinueProduct = ApiRoutes.Products.Names.DiscontinueProduct; + + // Assert + getProducts.ShouldBe("GetProducts"); + createProduct.ShouldBe("CreateProduct"); + getProductById.ShouldBe("GetProductById"); + changeProductPrice.ShouldBe("ChangeProductPrice"); + discontinueProduct.ShouldBe("DiscontinueProduct"); } } diff --git a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Conflict.cs b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Conflict.cs index b52a117..e3ce287 100644 --- a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Conflict.cs +++ b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Conflict.cs @@ -7,6 +7,8 @@ public sealed partial class ErrorTests [Fact] public void Conflict_WithMessage_ReturnsConflictError() { + // Arrange + // Act Error error = Error.Conflict("Product already exists."); @@ -19,6 +21,8 @@ public void Conflict_WithMessage_ReturnsConflictError() [Fact] public void Conflict_WithCodeAndMessage_ReturnsConflictError() { + // Arrange + // Act Error error = Error.Conflict(ErrorCodes.Conflict, "Product already exists."); diff --git a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.ErrorCode.cs b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.ErrorCode.cs index bbfe723..b3c2335 100644 --- a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.ErrorCode.cs +++ b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.ErrorCode.cs @@ -8,6 +8,8 @@ public sealed partial class ErrorTests [Fact] public void ErrorCodeCreate_WithRegularValue_ReturnsCode() { + // Arrange + // Act ErrorCode code = ErrorCode.Create("custom_error"); @@ -20,6 +22,8 @@ public void ErrorCodeCreate_WithRegularValue_ReturnsCode() [Fact] public void ErrorCodeCreate_WithNoneValue_ReturnsNoneCode() { + // Arrange + // Act ErrorCode code = ErrorCode.Create("none"); @@ -34,6 +38,8 @@ public void ErrorCodeCreate_WithNoneValue_ReturnsNoneCode() [InlineData("\t")] public void ErrorCodeCreate_WithMissingValue_ThrowsArgumentException(string value) { + // Arrange + // Act Action action = () => ErrorCode.Create(value); @@ -57,6 +63,8 @@ public void ErrorCodeFromDomain_WithDomainCode_PreservesCodeValue() [Fact] public void ErrorCodeFromDomain_WithNullDomainCode_ThrowsArgumentNullException() { + // Arrange + // Act Action action = () => ErrorCode.FromDomain(null!); diff --git a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.NoError.cs b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.NoError.cs index 74c2e71..e545885 100644 --- a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.NoError.cs +++ b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.NoError.cs @@ -7,6 +7,8 @@ public sealed partial class ErrorTests [Fact] public void None_ReturnsNoneError() { + // Arrange + // Act Error error = Error.None; diff --git a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.NotFound.cs b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.NotFound.cs index f7e61b0..eb60aaa 100644 --- a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.NotFound.cs +++ b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.NotFound.cs @@ -7,6 +7,8 @@ public sealed partial class ErrorTests [Fact] public void NotFound_WithMessage_ReturnsNotFoundError() { + // Arrange + // Act Error error = Error.NotFound("Product was not found."); @@ -19,6 +21,8 @@ public void NotFound_WithMessage_ReturnsNotFoundError() [Fact] public void NotFound_WithCodeAndMessage_ReturnsNotFoundError() { + // Arrange + // Act Error error = Error.NotFound(ErrorCodes.NotFound, "Product was not found."); diff --git a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Unknown.cs b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Unknown.cs index 8a16b2a..4de9724 100644 --- a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Unknown.cs +++ b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Unknown.cs @@ -7,6 +7,8 @@ public sealed partial class ErrorTests [Fact] public void Unknown_WithCodeAndMessage_ReturnsUnknownError() { + // Arrange + // Act Error error = Error.Unknown(ErrorCode.Create("unexpected_error"), "Unexpected error."); diff --git a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Validation.cs b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Validation.cs index c0a03dd..b51422f 100644 --- a/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Validation.cs +++ b/content/tests/Company.Template.Application.Tests/Common/ErrorTests.Validation.cs @@ -7,6 +7,8 @@ public sealed partial class ErrorTests [Fact] public void Validation_WithMessage_ReturnsValidationError() { + // Arrange + // Act Error error = Error.Validation("Invalid input."); @@ -20,6 +22,8 @@ public void Validation_WithMessage_ReturnsValidationError() [Fact] public void Validation_WithCodeAndMessage_ReturnsValidationError() { + // Arrange + // Act Error error = Error.Validation(ErrorCodes.ProductNameRequired, "Product name is required."); @@ -32,6 +36,8 @@ public void Validation_WithCodeAndMessage_ReturnsValidationError() [Fact] public void Validation_WithTarget_PreservesTarget() { + // Arrange + // Act Error error = Error.Validation(ErrorCodes.ProductNameRequired, "Product name is required.", "name"); @@ -67,6 +73,8 @@ public void Validation_WithDetails_PreservesDetails() [Fact] public void Validation_WithNoneCode_ThrowsArgumentException() { + // Arrange + // Act Action action = () => Error.Validation(ErrorCode.None, "Invalid input."); @@ -80,6 +88,8 @@ public void Validation_WithNoneCode_ThrowsArgumentException() [InlineData("\t")] public void Validation_WithMissingCode_ThrowsArgumentException(string code) { + // Arrange + // Act Action action = () => Error.Validation(ErrorCode.Create(code), "Invalid input."); @@ -93,6 +103,8 @@ public void Validation_WithMissingCode_ThrowsArgumentException(string code) [InlineData("\t")] public void Validation_WithMissingMessage_ThrowsArgumentException(string message) { + // Arrange + // Act Action action = () => Error.Validation(ErrorCodes.ValidationError, message); diff --git a/content/tests/Company.Template.Domain.Tests/Common/DomainErrorTests.cs b/content/tests/Company.Template.Domain.Tests/Common/DomainErrorTests.cs index ce932c3..746a792 100644 --- a/content/tests/Company.Template.Domain.Tests/Common/DomainErrorTests.cs +++ b/content/tests/Company.Template.Domain.Tests/Common/DomainErrorTests.cs @@ -5,6 +5,8 @@ public sealed class DomainErrorTests [Fact] public void None_ReturnsNoneDomainError() { + // Arrange + // Act DomainError error = DomainError.None; @@ -17,6 +19,8 @@ public void None_ReturnsNoneDomainError() [Fact] public void Create_WithCodeAndMessage_ReturnsDomainError() { + // Arrange + // Act DomainError error = DomainError.Create( DomainErrorCodes.AmountNegative, @@ -31,6 +35,8 @@ public void Create_WithCodeAndMessage_ReturnsDomainError() [Fact] public void Create_WithNullCode_ThrowsArgumentNullException() { + // Arrange + // Act Action action = () => DomainError.Create(null!, "Amount cannot be negative."); @@ -41,6 +47,8 @@ public void Create_WithNullCode_ThrowsArgumentNullException() [Fact] public void Create_WithNoneCode_ThrowsArgumentException() { + // Arrange + // Act Action action = () => DomainError.Create( DomainErrorCode.None, @@ -56,6 +64,8 @@ public void Create_WithNoneCode_ThrowsArgumentException() [InlineData("\t")] public void Create_WithMissingMessage_ThrowsArgumentException(string message) { + // Arrange + // Act Action action = () => DomainError.Create(DomainErrorCodes.AmountNegative, message); diff --git a/content/tests/Company.Template.Domain.Tests/Products/ProductTests.cs b/content/tests/Company.Template.Domain.Tests/Products/ProductTests.cs index 2067f75..3bf6fbc 100644 --- a/content/tests/Company.Template.Domain.Tests/Products/ProductTests.cs +++ b/content/tests/Company.Template.Domain.Tests/Products/ProductTests.cs @@ -311,6 +311,8 @@ public void ClearDomainEvents_RemovesRecordedEvents() [Fact] public void TryCreate_WithValidValues_ReturnsTrueAndProduct() { + // Arrange + // Act bool result = Product.TryCreate( "Keyboard", @@ -333,6 +335,8 @@ public void TryCreate_WithValidValues_ReturnsTrueAndProduct() [Fact] public void TryCreate_WithMissingName_ReturnsFalseAndDomainError() { + // Arrange + // Act bool result = Product.TryCreate( " ", @@ -353,6 +357,8 @@ public void TryCreate_WithMissingName_ReturnsFalseAndDomainError() [Fact] public void TryCreate_WithInvalidPrice_ReturnsFalseAndDomainError() { + // Arrange + // Act bool result = Product.TryCreate( "Keyboard", diff --git a/content/tests/Company.Template.Domain.Tests/SharedKernel/CurrencyTests.cs b/content/tests/Company.Template.Domain.Tests/SharedKernel/CurrencyTests.cs index 6c0e17f..513c8fc 100644 --- a/content/tests/Company.Template.Domain.Tests/SharedKernel/CurrencyTests.cs +++ b/content/tests/Company.Template.Domain.Tests/SharedKernel/CurrencyTests.cs @@ -21,6 +21,8 @@ public void Create_WithValidCode_ReturnsCurrency() [Fact] public void Create_WithLowercaseCode_NormalizesCodeToUppercase() { + // Arrange + // Act Currency currency = Currency.Create("chf"); @@ -32,6 +34,8 @@ public void Create_WithLowercaseCode_NormalizesCodeToUppercase() [Fact] public void Create_WithLeadingAndTrailingWhitespace_TrimsCode() { + // Arrange + // Act Currency currency = Currency.Create(" chf "); @@ -46,6 +50,8 @@ public void Create_WithLeadingAndTrailingWhitespace_TrimsCode() [InlineData("\t")] public void Create_WithMissingCode_ThrowsArgumentException(string code) { + // Arrange + // Act ArgumentException exception = Should.Throw(() => Currency.Create(code)); @@ -72,6 +78,8 @@ public void Create_WithNullCode_ThrowsArgumentException() [InlineData("12!")] public void Create_WithInvalidCodeFormat_ThrowsArgumentException(string code) { + // Arrange + // Act ArgumentException exception = Should.Throw(() => Currency.Create(code)); @@ -82,6 +90,8 @@ public void Create_WithInvalidCodeFormat_ThrowsArgumentException(string code) [Fact] public void Create_WithUnsupportedCode_ThrowsArgumentException() { + // Arrange + // Act ArgumentException exception = Should.Throw(() => Currency.Create("ABC")); @@ -92,6 +102,8 @@ public void Create_WithUnsupportedCode_ThrowsArgumentException() [Fact] public void Create_WithValidCodeAndSymbol_ReturnsCurrency() { + // Arrange + // Act Currency currency = Currency.Create("CHF", "Fr."); @@ -103,6 +115,8 @@ public void Create_WithValidCodeAndSymbol_ReturnsCurrency() [Fact] public void Create_WithLowercaseCodeAndSymbol_NormalizesCodeOnly() { + // Arrange + // Act Currency currency = Currency.Create("chf", "Fr."); @@ -114,6 +128,8 @@ public void Create_WithLowercaseCodeAndSymbol_NormalizesCodeOnly() [Fact] public void Create_WithLeadingAndTrailingWhitespaceAroundSymbol_TrimsSymbol() { + // Arrange + // Act Currency currency = Currency.Create("CHF", " Fr. "); @@ -128,6 +144,8 @@ public void Create_WithLeadingAndTrailingWhitespaceAroundSymbol_TrimsSymbol() [InlineData("\t")] public void Create_WithMissingSymbol_ThrowsArgumentException(string symbol) { + // Arrange + // Act ArgumentException exception = Should.Throw(() => Currency.Create("CHF", symbol)); @@ -154,6 +172,8 @@ public void Create_WithNullSymbol_ThrowsArgumentException() [InlineData("12!")] public void Create_WithSymbolAndInvalidCodeFormat_ThrowsArgumentException(string code) { + // Arrange + // Act ArgumentException exception = Should.Throw(() => Currency.Create(code, "Fr.")); @@ -164,6 +184,8 @@ public void Create_WithSymbolAndInvalidCodeFormat_ThrowsArgumentException(string [Fact] public void Create_WithSymbolAndUnsupportedCode_ThrowsArgumentException() { + // Arrange + // Act ArgumentException exception = Should.Throw(() => Currency.Create("ABC", "ABC")); @@ -217,6 +239,8 @@ public void ToString_ReturnsCode() [Fact] public void TryCreate_WithValidCode_ReturnsTrueAndCurrency() { + // Arrange + // Act bool result = Currency.TryCreate( " chf ", @@ -234,6 +258,8 @@ public void TryCreate_WithValidCode_ReturnsTrueAndCurrency() [Fact] public void TryCreate_WithValidCodeAndSymbol_ReturnsTrueAndCurrency() { + // Arrange + // Act bool result = Currency.TryCreate( " usd ", @@ -256,6 +282,8 @@ public void TryCreate_WithValidCodeAndSymbol_ReturnsTrueAndCurrency() [InlineData("\t")] public void TryCreate_WithMissingCode_ReturnsCurrencyRequired(string? code) { + // Arrange + // Act bool result = Currency.TryCreate( code, @@ -275,6 +303,8 @@ public void TryCreate_WithMissingCode_ReturnsCurrencyRequired(string? code) [InlineData("12!")] public void TryCreate_WithInvalidCodeFormat_ReturnsCurrencyInvalidFormat(string code) { + // Arrange + // Act bool result = Currency.TryCreate( code, @@ -291,6 +321,8 @@ public void TryCreate_WithInvalidCodeFormat_ReturnsCurrencyInvalidFormat(string [Fact] public void TryCreate_WithUnsupportedCode_ReturnsCurrencyUnsupported() { + // Arrange + // Act bool result = Currency.TryCreate( "ABC", @@ -311,6 +343,8 @@ public void TryCreate_WithUnsupportedCode_ReturnsCurrencyUnsupported() [InlineData("\t")] public void TryCreate_WithMissingSymbol_ReturnsCurrencySymbolRequired(string? symbol) { + // Arrange + // Act bool result = Currency.TryCreate( "CHF", @@ -331,6 +365,8 @@ public void TryCreate_WithMissingSymbol_ReturnsCurrencySymbolRequired(string? sy [InlineData("12!")] public void TryCreate_WithSymbolAndInvalidCodeFormat_ReturnsCurrencyInvalidFormat(string code) { + // Arrange + // Act bool result = Currency.TryCreate( code, @@ -348,6 +384,8 @@ public void TryCreate_WithSymbolAndInvalidCodeFormat_ReturnsCurrencyInvalidForma [Fact] public void TryCreate_WithSymbolAndUnsupportedCode_ReturnsCurrencyUnsupported() { + // Arrange + // Act bool result = Currency.TryCreate( "ABC", diff --git a/content/tests/Company.Template.Domain.Tests/SharedKernel/Iso4217CurrencyCodesTests.cs b/content/tests/Company.Template.Domain.Tests/SharedKernel/Iso4217CurrencyCodesTests.cs index 7970e98..265bd2a 100644 --- a/content/tests/Company.Template.Domain.Tests/SharedKernel/Iso4217CurrencyCodesTests.cs +++ b/content/tests/Company.Template.Domain.Tests/SharedKernel/Iso4217CurrencyCodesTests.cs @@ -7,6 +7,8 @@ public sealed class Iso4217CurrencyCodesTests [Fact] public void Chf_ReturnsSwissFranc() { + // Arrange + // Act Currency currency = Iso4217CurrencyCodes.Chf; @@ -18,6 +20,8 @@ public void Chf_ReturnsSwissFranc() [Fact] public void Eur_ReturnsEuro() { + // Arrange + // Act Currency currency = Iso4217CurrencyCodes.Eur; @@ -29,6 +33,8 @@ public void Eur_ReturnsEuro() [Fact] public void Usd_ReturnsUsDollar() { + // Arrange + // Act Currency currency = Iso4217CurrencyCodes.Usd; diff --git a/content/tests/Company.Template.Domain.Tests/SharedKernel/MoneyTests.cs b/content/tests/Company.Template.Domain.Tests/SharedKernel/MoneyTests.cs index c02cb26..d888336 100644 --- a/content/tests/Company.Template.Domain.Tests/SharedKernel/MoneyTests.cs +++ b/content/tests/Company.Template.Domain.Tests/SharedKernel/MoneyTests.cs @@ -97,6 +97,8 @@ public void Create_WithStringCurrency_CreatesMoneyWithCurrency() [Fact] public void Create_WithUnsupportedStringCurrency_ThrowsArgumentException() { + // Arrange + // Act ArgumentException exception = Should.Throw(() => Money.Create(12.50m, "ABC")); @@ -498,6 +500,8 @@ public void ToString_WithCurrency_ReturnsAmountAndCurrencyCode() [Fact] public void TryCreate_WithValidAmountAndCurrency_ReturnsTrueAndMoney() { + // Arrange + // Act bool result = Money.TryCreate( 99.90m, @@ -516,6 +520,8 @@ public void TryCreate_WithValidAmountAndCurrency_ReturnsTrueAndMoney() [Fact] public void TryCreate_WithNullCurrency_ReturnsCurrencyRequired() { + // Arrange + // Act bool result = Money.TryCreate( 99.90m, @@ -533,6 +539,8 @@ public void TryCreate_WithNullCurrency_ReturnsCurrencyRequired() [Fact] public void TryCreate_WithNegativeAmount_ReturnsAmountNegative() { + // Arrange + // Act bool result = Money.TryCreate( -0.01m, @@ -550,6 +558,8 @@ public void TryCreate_WithNegativeAmount_ReturnsAmountNegative() [Fact] public void TryCreate_WithZeroAmountAndCurrency_ReturnsTrueAndZeroMoney() { + // Arrange + // Act bool result = Money.TryCreate( 0m, @@ -569,6 +579,8 @@ public void TryCreate_WithZeroAmountAndCurrency_ReturnsTrueAndZeroMoney() [Fact] public void TryCreate_WithTooManyDecimalPlaces_ReturnsAmountTooManyDecimalPlaces() { + // Arrange + // Act bool result = Money.TryCreate( 99.999m, @@ -586,6 +598,8 @@ public void TryCreate_WithTooManyDecimalPlaces_ReturnsAmountTooManyDecimalPlaces [Fact] public void TryCreate_WithValidAmountAndCurrencyCode_ReturnsTrueAndMoney() { + // Arrange + // Act bool result = Money.TryCreate( 99.90m, @@ -604,6 +618,8 @@ public void TryCreate_WithValidAmountAndCurrencyCode_ReturnsTrueAndMoney() [Fact] public void TryCreate_WithInvalidCurrencyCodeFormat_ReturnsCurrencyInvalidFormat() { + // Arrange + // Act bool result = Money.TryCreate( 99.90m, @@ -621,6 +637,8 @@ public void TryCreate_WithInvalidCurrencyCodeFormat_ReturnsCurrencyInvalidFormat [Fact] public void TryCreate_WithUnsupportedCurrencyCode_ReturnsCurrencyUnsupported() { + // Arrange + // Act bool result = Money.TryCreate( 99.90m, @@ -638,6 +656,8 @@ public void TryCreate_WithUnsupportedCurrencyCode_ReturnsCurrencyUnsupported() [Fact] public void TryCreate_WithMissingCurrencyCode_ReturnsCurrencyRequired() { + // Arrange + // Act bool result = Money.TryCreate( 99.90m, @@ -655,6 +675,8 @@ public void TryCreate_WithMissingCurrencyCode_ReturnsCurrencyRequired() [Fact] public void TryCreate_WithNegativeAmountAndInvalidCurrencyCode_ReturnsCurrencyInvalidFormat() { + // Arrange + // Act bool result = Money.TryCreate( -0.01m,