From a101051ab48959eed14c8da387803ebedbe2e77c Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Thu, 14 May 2026 04:18:06 +0300 Subject: [PATCH 01/15] Refactored API structures/directories and namespaces --- .../{ => Mutations}/Delete/DeleteAccountEndpoint.cs | 2 +- .../{ => Mutations}/Delete/DeleteAccountRequest.cs | 2 +- .../Endpoints/{ => Mutations}/Post/PostAccountEndpoint.cs | 4 ++-- .../Endpoints/{ => Mutations}/Post/PostAccountRequest.cs | 2 +- .../Endpoints/{ => Queries}/Get/All/GetAccountsEndpoint.cs | 2 +- .../Endpoints/{ => Queries}/Get/All/GetAccountsMapper.cs | 2 +- .../Endpoints/{ => Queries}/Get/All/GetAccountsRequest.cs | 2 +- .../{ => Queries}/Get/Single/GetAccountEndpoint.cs | 2 +- .../Endpoints/{ => Queries}/Get/Single/GetAccountRequest.cs | 2 +- .../Get/Sortings/GetAccountSortingsEndpoint.cs | 2 +- .../API/Roles/Endpoints/Delete/DeleteRoleRequest.cs | 3 --- .../API/Roles/Endpoints/Get/Single/GetRoleRequest.cs | 3 --- .../Endpoints/{ => Mutations}/Delete/DeleteRoleEndpoint.cs | 2 +- .../Roles/Endpoints/Mutations/Delete/DeleteRoleRequest.cs | 3 +++ .../Endpoints/{ => Mutations}/Post/PostRoleEndpoint.cs | 4 ++-- .../API/Roles/Endpoints/Mutations/Post/PostRoleRequest.cs | 3 +++ .../Accounts/API/Roles/Endpoints/Post/PostRoleRequest.cs | 3 --- .../Endpoints/{ => Queries}/Get/All/GetRolesEndpoint.cs | 2 +- .../Endpoints/{ => Queries}/Get/Single/GetRoleEndpoint.cs | 2 +- .../Roles/Endpoints/Queries/Get/Single/GetRoleRequest.cs | 3 +++ .../{ => Mutations}/Delete/DeleteActiveCartItemEndpoint.cs | 2 +- .../{ => Mutations}/Delete/DeleteActiveCartItemRequest.cs | 2 +- .../DecreaeseActiveCartItemQuantityEndpoint.cs | 2 +- .../DecreaseActiveCartItemQuantityRequest.cs | 2 +- .../IncreaseActiveCartItemQuantityEndpoint.cs | 2 +- .../IncreaseActiveCartItemQuantityRequest.cs | 2 +- .../ToggleActiveCartItemForDeliveryEndpoint.cs | 2 +- .../ToggleActiveCartItemForDeliveryRequest.cs | 2 +- .../{ => Mutations}/Post/Item/PostActiveCartItemEndpoint.cs | 2 +- .../{ => Mutations}/Post/Item/PostActiveCartItemRequest.cs | 2 +- .../Post/Purchase/PurchaseActiveCartEndpoint.cs | 2 +- .../Post/Purchase/PurchaseActiveCartRequest.cs | 2 +- .../Post/PurchaseWithDelivery/PurchaseActiveCartEndpoint.cs | 2 +- .../Post/PurchaseWithDelivery/PurchaseActiveCartRequest.cs | 2 +- .../{ => Queries}/Get/All/GetActiveCartItemsEndpoint.cs | 2 +- .../CalculateActiveCartShipmentEndpoint.cs | 2 +- .../CalculateShipment/CalculateActiveCartShipmentMappper.cs | 2 +- .../CalculateShipment/CalculateActiveCartShipmentRequest.cs | 2 +- .../CalculateActiveCartShipmentResponse.cs | 2 +- .../{ => Queries}/Get/Count/CountActiveCartItemsEndpoint.cs | 2 +- .../{ => Queries}/Get/All/GetPurchasedCartsEndpoint.cs | 2 +- .../{ => Queries}/Get/All/GetPurchasedCartsMapper.cs | 2 +- .../{ => Queries}/Get/All/GetPurchasedCartsRequest.cs | 2 +- .../{ => Queries}/Get/All/GetPurchasedCartsResponse.cs | 2 +- .../GetPurchasedCartPaymentStatusesEndpoint.cs | 2 +- .../{ => Queries}/Get/Single/GetPurchasedCartEndpoint.cs | 2 +- .../{ => Queries}/Get/Single/GetPurchasedCartMappper.cs | 2 +- .../{ => Queries}/Get/Single/GetPurchasedCartRequest.cs | 2 +- .../{ => Queries}/Get/Single/GetPurchasedCartResponse.cs | 2 +- .../Get/Sortings/GetPurchasedCartSortingsEndpoint.cs | 2 +- .../{ => Queries}/Get/Stats/PurchasedCartsStatsEndpoint.cs | 2 +- .../{ => Queries}/Get/Stats/PurchasedCartsStatsMappper.cs | 2 +- .../{ => Queries}/Get/Stats/PurchasedCartsStatsResponse.cs | 2 +- .../Endpoints/Get/Single/Id/GetCategoryRequest.cs | 5 ----- .../{ => Mutations}/Delete/DeleteCategoryEndpoint.cs | 2 +- .../{ => Mutations}/Delete/DeleteCategoryRequest.cs | 2 +- .../Endpoints/{ => Mutations}/Post/PostCategoryEndpoint.cs | 4 ++-- .../Endpoints/{ => Mutations}/Post/PostCategoryRequest.cs | 2 +- .../Endpoints/{ => Mutations}/Put/PutCategoryEndpoint.cs | 2 +- .../Endpoints/{ => Mutations}/Put/PutCategoryRequest.cs | 2 +- .../{ => Queries}/Get/All/GetCategoriesEndpoint.cs | 2 +- .../{ => Queries}/Get/Single/Id/GetCategoryEndpoint.cs | 2 +- .../Endpoints/Queries/Get/Single/Id/GetCategoryRequest.cs | 5 +++++ .../{ => Queries}/Get/Single/Name/GetCategoryEndpoint.cs | 2 +- .../{ => Queries}/Get/Single/Name/GetCategoryRequest.cs | 2 +- .../Admin/{ => Mutations}/Remove/RemoveProductEndpoint.cs | 2 +- .../Admin/{ => Mutations}/Remove/RemoveProductRequest.cs | 2 +- .../Creator/{ => Mutations}/Delete/DeleteProductEndpoint.cs | 2 +- .../Creator/{ => Mutations}/Delete/DeleteProductRequest.cs | 2 +- .../Creator/{ => Mutations}/Post/PostProductEndpoint.cs | 4 ++-- .../Creator/{ => Mutations}/Post/PostProductMapper.cs | 2 +- .../Creator/{ => Mutations}/Post/PostProductRequest.cs | 2 +- .../Creator/{ => Mutations}/Post/PostProductResponse.cs | 2 +- .../Creator/{ => Mutations}/Put/PutProductEndpoint.cs | 2 +- .../Creator/{ => Mutations}/Put/PutProductRequest.cs | 2 +- .../Creator/{ => Queries}/Get/All/GetProductsEndpoint.cs | 2 +- .../Creator/{ => Queries}/Get/All/GetProductsMapper.cs | 2 +- .../Creator/{ => Queries}/Get/All/GetProductsRequest.cs | 2 +- .../Creator/{ => Queries}/Get/All/GetProductsResponse.cs | 2 +- .../Creator/{ => Queries}/Get/Recent/GetProductsMapper.cs | 2 +- .../{ => Queries}/Get/Recent/RecentProductsEndpoint.cs | 2 +- .../{ => Queries}/Get/Recent/RecentProductsRequest.cs | 2 +- .../{ => Queries}/Get/Recent/RecentProductsResponse.cs | 2 +- .../Get/Single/CreatorSingleProductEndpoint.cs | 2 +- .../{ => Queries}/Get/Single/CreatorSingleProductMapper.cs | 2 +- .../{ => Queries}/Get/Single/CreatorSingleProductRequest.cs | 2 +- .../Get/Single/CreatorSingleProductResponse.cs | 2 +- .../Get/Sortings/GetProductSortingsEndpoint.cs | 2 +- .../{ => Queries}/Get/Stats/ProductsStatsEndpoint.cs | 2 +- .../Creator/{ => Queries}/Get/Stats/ProductsStatsMapper.cs | 2 +- .../{ => Queries}/Get/Stats/ProductsStatsResponse.cs | 2 +- .../{ => Mutations}/Patch/Report/ReportProductEndpoint.cs | 2 +- .../{ => Mutations}/Patch/Report/ReportProductRequest.cs | 2 +- .../Patch/Validate/ValidateProductEndpoint.cs | 2 +- .../Patch/Validate/ValidateProductRequest.cs | 2 +- .../Get/Reported/GetReportedProductsEndpoint.cs | 2 +- .../{ => Queries}/Get/Reported/GetReportedProductsMapper.cs | 2 +- .../Get/Reported/GetReportedProductsRequest.cs | 2 +- .../Get/Reported/GetReportedProductsResponse.cs | 2 +- .../Get/Single/DesignerSingleProductEndpoint.cs | 2 +- .../{ => Queries}/Get/Single/DesignerSingleProductMapper.cs | 2 +- .../Get/Single/DesignerSingleProductRequest.cs | 2 +- .../Get/Single/DesignerSingleProductResponse.cs | 2 +- .../Get/Sortings/GetProductSortingsEndpoint.cs | 2 +- .../Get/Unchecked/GetUncheckedProductsEndpoint.cs | 2 +- .../Get/Unchecked/GetUncheckedProductsMapper.cs | 2 +- .../Get/Unchecked/GetUncheckedProductsRequest.cs | 2 +- .../Get/Unchecked/GetUncheckedProductsResponse.cs | 2 +- .../Get/Validated/GetValidatedProductsEndpoint.cs | 2 +- .../Get/Validated/GetValidatedProductsMapper.cs | 2 +- .../Get/Validated/GetValidatedProductsRequest.cs | 2 +- .../Get/Validated/GetValidatedProductsResponse.cs | 2 +- .../{ => Mutations}/Patch/AddTag/AddProductTagEndpoint.cs | 2 +- .../{ => Mutations}/Patch/AddTag/AddProductTagRequest.cs | 2 +- .../Patch/RemoveTag/RemoveProductTagEndpoint.cs | 2 +- .../Patch/RemoveTag/RemoveProductTagRequest.cs | 2 +- .../{ => Queries}/Get/All/GetAllGalleryProductsEndpoint.cs | 2 +- .../{ => Queries}/Get/All/GetAllGalleryProductsMapper.cs | 2 +- .../{ => Queries}/Get/All/GetAllGalleryProductsRequest.cs | 2 +- .../{ => Queries}/Get/All/GetAllGalleryProductsResponse.cs | 2 +- .../{ => Queries}/Get/Single/GetGalleryProductEndpoint.cs | 2 +- .../{ => Queries}/Get/Single/GetGalleryProductMapper.cs | 2 +- .../{ => Queries}/Get/Single/GetGalleryProductRequest.cs | 2 +- .../{ => Queries}/Get/Single/GetGalleryProductResponse.cs | 2 +- .../Get/Sortings/GetProductSortingsEndpoint.cs | 2 +- .../Catalog/API/Tags/Endpoints/Delete/DeleteTagRequest.cs | 5 ----- .../API/Tags/Endpoints/Get/All/GetAllTagsResponse.cs | 6 ------ .../API/Tags/Endpoints/Get/Single/GetTagByIdRequest.cs | 5 ----- .../API/Tags/Endpoints/Get/Single/GetTagByIdResponse.cs | 6 ------ .../Endpoints/{ => Mutations}/Delete/DeleteTagEndpoint.cs | 2 +- .../API/Tags/Endpoints/Mutations/Delete/DeleteTagRequest.cs | 5 +++++ .../Endpoints/{ => Mutations}/Post/CreateTagEndpoint.cs | 2 +- .../API/Tags/Endpoints/Mutations/Post/CreateTagRequest.cs | 5 +++++ .../API/Tags/Endpoints/Mutations/Post/CreateTagResponse.cs | 6 ++++++ .../Tags/Endpoints/{ => Mutations}/Put/EditTagEndpoint.cs | 2 +- .../API/Tags/Endpoints/Mutations/Put/EditTagRequest.cs | 6 ++++++ .../Catalog/API/Tags/Endpoints/Post/CreateTagRequest.cs | 5 ----- .../Catalog/API/Tags/Endpoints/Post/CreateTagResponse.cs | 6 ------ .../Catalog/API/Tags/Endpoints/Put/EditTagRequest.cs | 6 ------ .../Endpoints/{ => Queries}/Get/All/GetAllTagsEndpoint.cs | 2 +- .../Tags/Endpoints/Queries/Get/All/GetAllTagsResponse.cs | 6 ++++++ .../{ => Queries}/Get/Single/GetTagByIdEndpoint.cs | 2 +- .../Tags/Endpoints/Queries/Get/Single/GetTagByIdRequest.cs | 5 +++++ .../Tags/Endpoints/Queries/Get/Single/GetTagByIdResponse.cs | 6 ++++++ src/Modules/Catalog/API/Tags/Mapper.cs | 6 +++--- .../Patch/PatchCategory/PatchCustomCategoryEndpoint.cs | 2 +- .../Patch/PatchCategory/PatchCustomCategoryRequest.cs | 2 +- .../{ => Mutations}/Patch/Remove/RemoveCustomEndpoint.cs | 2 +- .../{ => Mutations}/Patch/Remove/RemoveCustomRequest.cs | 2 +- .../Admins/{ => Queries}/Get/All/GetCustomsEndpoint.cs | 2 +- .../Admins/{ => Queries}/Get/All/GetCustomsMapper.cs | 2 +- .../Admins/{ => Queries}/Get/All/GetCustomsRequest.cs | 2 +- .../Admins/{ => Queries}/Get/All/GetCustomsResponse.cs | 2 +- .../{ => Mutations}/Delete/DeleteCustomEndpoint.cs | 2 +- .../Customers/{ => Mutations}/Delete/DeleteCustomRequest.cs | 2 +- .../{ => Mutations}/Post/Create/PostCustomEndpoint.cs | 4 ++-- .../{ => Mutations}/Post/Create/PostCustomMapper.cs | 2 +- .../{ => Mutations}/Post/Create/PostCustomRequest.cs | 2 +- .../{ => Mutations}/Post/Create/PostCustomResponse.cs | 2 +- .../Post/Purchase/Normal/PurchaseCustomEndpoint.cs | 2 +- .../Post/Purchase/Normal/PurchaseCustomRequest.cs | 2 +- .../WithDelivery/PurchasCustomWithDeliveryRequest.cs | 2 +- .../WithDelivery/PurchaseCustomWithDeliveryEndpoint.cs | 2 +- .../Customers/{ => Mutations}/Put/PutCustomEndpoint.cs | 2 +- .../Customers/{ => Mutations}/Put/PutCustomRequest.cs | 2 +- .../Customers/{ => Queries}/Get/All/GetCustomsEndpoint.cs | 2 +- .../Customers/{ => Queries}/Get/All/GetCustomsMapper.cs | 2 +- .../Customers/{ => Queries}/Get/All/GetCustomsRequest.cs | 2 +- .../Customers/{ => Queries}/Get/All/GetCustomsResponse.cs | 2 +- .../CalculateShipment/CalculateCustomShipmentEndpoint.cs | 2 +- .../Get/CalculateShipment/CalculateCustomShipmentMapper.cs | 2 +- .../Get/CalculateShipment/CalculateCustomShipmentRequest.cs | 2 +- .../CalculateShipment/CalculateCustomShipmentResponse.cs | 2 +- .../Get/PaymentStatuses/GetCustomPaymentStatusesEndpoint.cs | 2 +- .../{ => Queries}/Get/Recent/RecentCustomsEndpoint.cs | 2 +- .../{ => Queries}/Get/Recent/RecentCustomsMapper.cs | 2 +- .../{ => Queries}/Get/Recent/RecentCustomsRequest.cs | 2 +- .../{ => Queries}/Get/Recent/RecentCustomsResponse.cs | 2 +- .../Customers/{ => Queries}/Get/Single/GetCustomEndpoint.cs | 2 +- .../Customers/{ => Queries}/Get/Single/GetCustomMapper.cs | 2 +- .../Customers/{ => Queries}/Get/Single/GetCustomRequest.cs | 2 +- .../Customers/{ => Queries}/Get/Single/GetCustomResponse.cs | 2 +- .../{ => Queries}/Get/Sortings/GetCustomSortingsEndpoint.cs | 2 +- .../Customers/{ => Queries}/Get/Stats/GetCustomMapper.cs | 2 +- .../{ => Queries}/Get/Stats/GetCustomsStatsEndpoint.cs | 2 +- .../{ => Queries}/Get/Stats/GetCustomsStatsResponse.cs | 2 +- .../Endpoints/{Designer => Designers}/DesignerGroup.cs | 2 +- .../Mutations}/Patch/Accept/AcceptCustomEndpoint.cs | 5 +++-- .../Mutations}/Patch/Accept/AcceptCustomRequest.cs | 2 +- .../Mutations}/Patch/Begin/BeginCustomEndpoint.cs | 5 +++-- .../Mutations}/Patch/Begin/BeginCustomRequest.cs | 2 +- .../Mutations}/Patch/Cancel/CancelCustomEndpoint.cs | 5 +++-- .../Mutations}/Patch/Cancel/CancelCustomRequest.cs | 2 +- .../Mutations}/Patch/Finish/FinishCustomEndpoint.cs | 5 +++-- .../Mutations}/Patch/Finish/FinishCustomRequest.cs | 2 +- .../Patch/PatchCategory/PatchCustomCategoryEndpoint.cs | 3 ++- .../Patch/PatchCategory/PatchCustomCategoryRequest.cs | 2 +- .../Mutations}/Patch/Report/ReportCustomEndpoint.cs | 5 +++-- .../Mutations}/Patch/Report/ReportCustomRequest.cs | 2 +- .../Queries}/Get/All/GetCustomMapper.cs | 2 +- .../Queries}/Get/All/GetCustomsEndpoint.cs | 5 +++-- .../Queries}/Get/All/GetCustomsRequest.cs | 2 +- .../Queries}/Get/All/GetCustomsResponse.cs | 2 +- .../Queries}/Get/Single/GetCustomEndpoint.cs | 5 +++-- .../Queries}/Get/Single/GetCustomMapper.cs | 2 +- .../Queries}/Get/Single/GetCustomRequest.cs | 2 +- .../Queries}/Get/Single/GetCustomResponse.cs | 2 +- .../{ => Mutations}/Patch/Cancel/CancelShipmentEndpoint.cs | 2 +- .../{ => Mutations}/Patch/Cancel/CancelShipmentRequest.cs | 2 +- .../{ => Queries}/Get/Shipment/GetShipmentsEndpoint.cs | 2 +- .../{ => Queries}/Get/Shipment/GetShipmentsMapper.cs | 2 +- .../{ => Queries}/Get/Shipment/GetShipmentsRequest.cs | 2 +- .../{ => Queries}/Get/Shipment/GetShipmentsResponse.cs | 2 +- .../Get/Sortings/GetShipmentSortingsEndpoint.cs | 2 +- .../{ => Queries}/Get/Track/TrackShipmentEndpoint.cs | 2 +- .../{ => Queries}/Get/Track/TrackShipmentMapper.cs | 2 +- .../{ => Queries}/Get/Track/TrackShipmentRequest.cs | 2 +- .../{ => Queries}/Get/Track/TrackShipmentResponse.cs | 2 +- .../Get/Waybill/GetShipmentGetWaybillEndpoint.cs | 2 +- .../{ => Queries}/Get/Waybill/GetShipmentWaybillRequest.cs | 2 +- .../Files/API/Cads/Endpoints/Get/All/GetCadsRequest.cs | 6 ------ .../Files/API/Cads/Endpoints/Get/Single/GetCadRequest.cs | 3 --- .../Endpoints/{ => Mutations}/Patch/PatchCadEndpoint.cs | 2 +- .../Cads/Endpoints/{ => Mutations}/Patch/PatchCadRequest.cs | 2 +- .../Endpoints/{ => Mutations}/Post/CreateCadEndpoint.cs | 4 ++-- .../Cads/Endpoints/{ => Mutations}/Post/CreateCadRequest.cs | 2 +- .../Cads/Endpoints/{ => Mutations}/Put/PutCadEndpoint.cs | 2 +- .../API/Cads/Endpoints/{ => Mutations}/Put/PutCadRequest.cs | 2 +- .../Cads/Endpoints/{ => Queries}/Get/All/GetCadsEndpoint.cs | 2 +- .../API/Cads/Endpoints/Queries/Get/All/GetCadsRequest.cs | 6 ++++++ .../Endpoints/{ => Queries}/Get/Single/GetCadEndpoint.cs | 2 +- .../API/Cads/Endpoints/Queries/Get/Single/GetCadRequest.cs | 3 +++ .../API/Images/Endpoints/Get/Single/GetImageRequest.cs | 3 --- .../Endpoints/{ => Mutations}/Post/CreateImageEndpoint.cs | 4 ++-- .../Endpoints/{ => Mutations}/Post/CreateImageRequest.cs | 2 +- .../Endpoints/{ => Mutations}/Put/PutImageEndpoint.cs | 2 +- .../API/Images/Endpoints/Mutations/Put/PutImageRequest.cs | 6 ++++++ .../Files/API/Images/Endpoints/Put/PutImageRequest.cs | 6 ------ .../Endpoints/{ => Queries}/Get/Single/GetImageEndpoint.cs | 2 +- .../Images/Endpoints/Queries/Get/Single/GetImageRequest.cs | 3 +++ .../Delete/Fingerprints/DeleteViewedProductRequest.cs | 3 --- .../Delete/ViewedProducts/DeleteViewedProductRequest.cs | 3 --- .../Identity/Post/ForgotPassword/ForgotPasswordRequest.cs | 3 --- .../Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs | 3 --- .../API/Identity/Post/VerifyEmail/ConfirmEmailRequest.cs | 6 ------ .../Identity/API/{ => Users}/Dtos/FingerprintResponse.cs | 2 +- .../Identity/API/{ => Users}/Dtos/ViewedProductResponse.cs | 2 +- .../API/{Identity => Users/Endpoints}/IdentityGroup.cs | 2 +- .../Endpoints/Mutations}/Delete/DeleteAccountEndpoint.cs | 2 +- .../Delete/Fingerprints/DeleteFingerprintsEndpoint.cs | 2 +- .../Delete/Fingerprints/DeleteViewedProductRequest.cs | 3 +++ .../Delete/ViewedProducts/DeleteViewedProductEndpoint.cs | 2 +- .../Delete/ViewedProducts/DeleteViewedProductRequest.cs | 3 +++ .../Endpoints/Mutations}/Patch/Names/ChangeNamesEndpoint.cs | 2 +- .../Mutations}/Patch/Names/ChangeUsernameRequest.cs | 2 +- .../ToggleViewedProductsTrackingEndpoint.cs | 2 +- .../Post/ForgotPassword/ForgotPasswordEndpoint.cs | 2 +- .../Mutations/Post/ForgotPassword/ForgotPasswordRequest.cs | 3 +++ .../Endpoints/Mutations}/Post/Login/LoginEndpoint.cs | 2 +- .../Endpoints/Mutations}/Post/Login/LoginRequest.cs | 2 +- .../Endpoints/Mutations}/Post/Logout/LogoutEndpoint.cs | 2 +- .../Mutations}/Post/RefreshToken/RefreshTokenEndpoint.cs | 2 +- .../Endpoints/Mutations}/Post/Register/RegisterEndpoint.cs | 2 +- .../Endpoints/Mutations}/Post/Register/RegisterRequest.cs | 2 +- .../Endpoints/Mutations}/Post/Register/RegisterValidator.cs | 2 +- .../Mutations}/Post/ResetPassword/ResetPasswordEndpoint.cs | 2 +- .../Mutations}/Post/ResetPassword/ResetPasswordRequest.cs | 2 +- .../Post/RetryVerifyEmail/RetryConfirmEmailEndpoint.cs | 2 +- .../Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs | 3 +++ .../Mutations}/Post/VerifyEmail/ConfirmEmailEndpoint.cs | 2 +- .../Mutations/Post/VerifyEmail/ConfirmEmailRequest.cs | 6 ++++++ .../Queries}/Get/Authentication/AuthenticationEndpoint.cs | 2 +- .../Queries}/Get/Authorization/AuthorizationEndpoint.cs | 2 +- .../Queries}/Get/DownloadInfo/DownloadInfoEndpoint.cs | 2 +- .../Endpoints/Queries}/Get/MyAccount/MyAccountEndpoint.cs | 2 +- .../Endpoints/Queries}/Get/MyAccount/MyAccountMapper.cs | 4 ++-- .../Endpoints/Queries}/Get/MyAccount/MyAccountResponse.cs | 4 ++-- .../{ => Mutations}/Patch/Hide/HideNotificationEndpoint.cs | 2 +- .../{ => Mutations}/Patch/Hide/HideNotificationRequest.cs | 2 +- .../{ => Mutations}/Patch/Open/OpenNotificationEndpoint.cs | 2 +- .../{ => Mutations}/Patch/Open/OpenNotificationRequest.cs | 2 +- .../{ => Mutations}/Patch/Read/ReadNotificationEndpoint.cs | 2 +- .../{ => Mutations}/Patch/Read/ReadNotificationRequest.cs | 2 +- .../Patch/Unhide/UnhideNotificationEndpoint.cs | 2 +- .../Patch/Unhide/UnhideNotificationRequest.cs | 2 +- .../{ => Queries}/Get/All/GetNotificationsEndpoint.cs | 2 +- .../{ => Queries}/Get/All/GetNotificationsMapper.cs | 2 +- .../{ => Queries}/Get/All/GetNotificationsRequest.cs | 2 +- .../{ => Queries}/Get/All/GetNotificationsResponse.cs | 2 +- .../Get/Sortings/GetNotificationSortingsEndpoint.cs | 2 +- .../Get/Stats/GetNotificationsStatsEndpoint.cs | 2 +- .../{ => Queries}/Get/Stats/GetNotificationsStatsMapper.cs | 2 +- .../Get/Stats/GetNotificationsStatsResponse.cs | 2 +- .../Get/Statuses/GetNotificationStatusesEndpoint.cs | 2 +- .../{ => Mutations}/Post/CreateCustomizationEndpoint.cs | 4 ++-- .../{ => Mutations}/Post/CreateCustomizationRequest.cs | 2 +- .../{ => Mutations}/Put/EditCustomizationEndpoint.cs | 2 +- .../{ => Mutations}/Put/EditCustomizationRequest.cs | 2 +- .../Endpoints/{ => Queries}/Get/GetCustomizationEndpoint.cs | 2 +- .../Endpoints/{ => Queries}/Get/GetCustomizationRequest.cs | 2 +- .../{ => Mutations}/Delete/DeleteMaterialEndpoint.cs | 2 +- .../{ => Mutations}/Delete/DeleteMaterialRequest.cs | 2 +- .../Endpoints/{ => Mutations}/Post/PostMaterialEndpoint.cs | 4 ++-- .../Endpoints/{ => Mutations}/Post/PostMaterialRequest.cs | 2 +- .../Endpoints/{ => Mutations}/Put/PutMaterialEndpoint.cs | 2 +- .../Endpoints/{ => Mutations}/Put/PutMaterialRequest.cs | 2 +- .../{ => Queries}/Get/All/GetCategoriesEndpoint.cs | 2 +- .../{ => Queries}/Get/Single/GetMaterialEndpoint.cs | 2 +- .../{ => Queries}/Get/Single/GetMaterialRequest.cs | 2 +- 309 files changed, 386 insertions(+), 378 deletions(-) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Mutations}/Delete/DeleteAccountEndpoint.cs (89%) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Mutations}/Delete/DeleteAccountRequest.cs (86%) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Mutations}/Post/PostAccountEndpoint.cs (88%) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Mutations}/Post/PostAccountRequest.cs (93%) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Queries}/Get/All/GetAccountsEndpoint.cs (92%) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Queries}/Get/All/GetAccountsMapper.cs (86%) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Queries}/Get/All/GetAccountsRequest.cs (81%) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Queries}/Get/Single/GetAccountEndpoint.cs (91%) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Queries}/Get/Single/GetAccountRequest.cs (85%) rename src/Modules/Accounts/API/Accounts/Endpoints/{ => Queries}/Get/Sortings/GetAccountSortingsEndpoint.cs (89%) delete mode 100644 src/Modules/Accounts/API/Roles/Endpoints/Delete/DeleteRoleRequest.cs delete mode 100644 src/Modules/Accounts/API/Roles/Endpoints/Get/Single/GetRoleRequest.cs rename src/Modules/Accounts/API/Roles/Endpoints/{ => Mutations}/Delete/DeleteRoleEndpoint.cs (89%) create mode 100644 src/Modules/Accounts/API/Roles/Endpoints/Mutations/Delete/DeleteRoleRequest.cs rename src/Modules/Accounts/API/Roles/Endpoints/{ => Mutations}/Post/PostRoleEndpoint.cs (87%) create mode 100644 src/Modules/Accounts/API/Roles/Endpoints/Mutations/Post/PostRoleRequest.cs delete mode 100644 src/Modules/Accounts/API/Roles/Endpoints/Post/PostRoleRequest.cs rename src/Modules/Accounts/API/Roles/Endpoints/{ => Queries}/Get/All/GetRolesEndpoint.cs (89%) rename src/Modules/Accounts/API/Roles/Endpoints/{ => Queries}/Get/Single/GetRoleEndpoint.cs (90%) create mode 100644 src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/Single/GetRoleRequest.cs rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Delete/DeleteActiveCartItemEndpoint.cs (90%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Delete/DeleteActiveCartItemRequest.cs (88%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Patch/DecrementQuantity/DecreaeseActiveCartItemQuantityEndpoint.cs (90%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Patch/DecrementQuantity/DecreaseActiveCartItemQuantityRequest.cs (81%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityEndpoint.cs (90%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityRequest.cs (81%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryEndpoint.cs (91%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryRequest.cs (82%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Post/Item/PostActiveCartItemEndpoint.cs (94%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Post/Item/PostActiveCartItemRequest.cs (89%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Post/Purchase/PurchaseActiveCartEndpoint.cs (91%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Post/Purchase/PurchaseActiveCartRequest.cs (84%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Post/PurchaseWithDelivery/PurchaseActiveCartEndpoint.cs (91%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Mutations}/Post/PurchaseWithDelivery/PurchaseActiveCartRequest.cs (66%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Queries}/Get/All/GetActiveCartItemsEndpoint.cs (90%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Queries}/Get/CalculateShipment/CalculateActiveCartShipmentEndpoint.cs (91%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Queries}/Get/CalculateShipment/CalculateActiveCartShipmentMappper.cs (84%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Queries}/Get/CalculateShipment/CalculateActiveCartShipmentRequest.cs (84%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Queries}/Get/CalculateShipment/CalculateActiveCartShipmentResponse.cs (87%) rename src/Modules/Carts/API/ActiveCarts/Endpoints/{ => Queries}/Get/Count/CountActiveCartItemsEndpoint.cs (89%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/All/GetPurchasedCartsEndpoint.cs (98%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/All/GetPurchasedCartsMapper.cs (96%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/All/GetPurchasedCartsRequest.cs (96%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/All/GetPurchasedCartsResponse.cs (90%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/PaymentStatuses/GetPurchasedCartPaymentStatusesEndpoint.cs (96%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/Single/GetPurchasedCartEndpoint.cs (97%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/Single/GetPurchasedCartMappper.cs (96%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/Single/GetPurchasedCartRequest.cs (83%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/Single/GetPurchasedCartResponse.cs (94%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/Sortings/GetPurchasedCartSortingsEndpoint.cs (97%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/Stats/PurchasedCartsStatsEndpoint.cs (98%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/Stats/PurchasedCartsStatsMappper.cs (96%) rename src/Modules/Carts/API/PurchasedCarts/Endpoints/{ => Queries}/Get/Stats/PurchasedCartsStatsResponse.cs (87%) delete mode 100644 src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Id/GetCategoryRequest.cs rename src/Modules/Catalog/API/Categories/Endpoints/{ => Mutations}/Delete/DeleteCategoryEndpoint.cs (89%) rename src/Modules/Catalog/API/Categories/Endpoints/{ => Mutations}/Delete/DeleteCategoryRequest.cs (86%) rename src/Modules/Catalog/API/Categories/Endpoints/{ => Mutations}/Post/PostCategoryEndpoint.cs (83%) rename src/Modules/Catalog/API/Categories/Endpoints/{ => Mutations}/Post/PostCategoryRequest.cs (89%) rename src/Modules/Catalog/API/Categories/Endpoints/{ => Mutations}/Put/PutCategoryEndpoint.cs (90%) rename src/Modules/Catalog/API/Categories/Endpoints/{ => Mutations}/Put/PutCategoryRequest.cs (90%) rename src/Modules/Catalog/API/Categories/Endpoints/{ => Queries}/Get/All/GetCategoriesEndpoint.cs (90%) rename src/Modules/Catalog/API/Categories/Endpoints/{ => Queries}/Get/Single/Id/GetCategoryEndpoint.cs (90%) create mode 100644 src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Id/GetCategoryRequest.cs rename src/Modules/Catalog/API/Categories/Endpoints/{ => Queries}/Get/Single/Name/GetCategoryEndpoint.cs (89%) rename src/Modules/Catalog/API/Categories/Endpoints/{ => Queries}/Get/Single/Name/GetCategoryRequest.cs (82%) rename src/Modules/Catalog/API/Products/Endpoints/Admin/{ => Mutations}/Remove/RemoveProductEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Admin/{ => Mutations}/Remove/RemoveProductRequest.cs (83%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Mutations}/Delete/DeleteProductEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Mutations}/Delete/DeleteProductRequest.cs (82%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Mutations}/Post/PostProductEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Mutations}/Post/PostProductMapper.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Mutations}/Post/PostProductRequest.cs (89%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Mutations}/Post/PostProductResponse.cs (92%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Mutations}/Put/PutProductEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Mutations}/Put/PutProductRequest.cs (89%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/All/GetProductsEndpoint.cs (98%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/All/GetProductsMapper.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/All/GetProductsRequest.cs (95%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/All/GetProductsResponse.cs (89%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Recent/GetProductsMapper.cs (95%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Recent/RecentProductsEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Recent/RecentProductsRequest.cs (82%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Recent/RecentProductsResponse.cs (88%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Single/CreatorSingleProductEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Single/CreatorSingleProductMapper.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Single/CreatorSingleProductRequest.cs (82%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Single/CreatorSingleProductResponse.cs (91%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Sortings/GetProductSortingsEndpoint.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Stats/ProductsStatsEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Stats/ProductsStatsMapper.cs (95%) rename src/Modules/Catalog/API/Products/Endpoints/Creator/{ => Queries}/Get/Stats/ProductsStatsResponse.cs (88%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Mutations}/Patch/Report/ReportProductEndpoint.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Mutations}/Patch/Report/ReportProductRequest.cs (78%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Mutations}/Patch/Validate/ValidateProductEndpoint.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Mutations}/Patch/Validate/ValidateProductRequest.cs (77%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Reported/GetReportedProductsEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Reported/GetReportedProductsMapper.cs (95%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Reported/GetReportedProductsRequest.cs (94%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Reported/GetReportedProductsResponse.cs (88%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Single/DesignerSingleProductEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Single/DesignerSingleProductMapper.cs (95%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Single/DesignerSingleProductRequest.cs (81%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Single/DesignerSingleProductResponse.cs (89%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Sortings/GetProductSortingsEndpoint.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Unchecked/GetUncheckedProductsEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Unchecked/GetUncheckedProductsMapper.cs (95%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Unchecked/GetUncheckedProductsRequest.cs (94%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Unchecked/GetUncheckedProductsResponse.cs (87%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Validated/GetValidatedProductsEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Validated/GetValidatedProductsMapper.cs (95%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Validated/GetValidatedProductsRequest.cs (94%) rename src/Modules/Catalog/API/Products/Endpoints/Designer/{ => Queries}/Get/Validated/GetValidatedProductsResponse.cs (87%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Mutations}/Patch/AddTag/AddProductTagEndpoint.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Mutations}/Patch/AddTag/AddProductTagRequest.cs (80%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Mutations}/Patch/RemoveTag/RemoveProductTagEndpoint.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Mutations}/Patch/RemoveTag/RemoveProductTagRequest.cs (79%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Queries}/Get/All/GetAllGalleryProductsEndpoint.cs (98%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Queries}/Get/All/GetAllGalleryProductsMapper.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Queries}/Get/All/GetAllGalleryProductsRequest.cs (95%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Queries}/Get/All/GetAllGalleryProductsResponse.cs (89%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Queries}/Get/Single/GetGalleryProductEndpoint.cs (97%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Queries}/Get/Single/GetGalleryProductMapper.cs (96%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Queries}/Get/Single/GetGalleryProductRequest.cs (81%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Queries}/Get/Single/GetGalleryProductResponse.cs (92%) rename src/Modules/Catalog/API/Products/Endpoints/Gallery/{ => Queries}/Get/Sortings/GetProductSortingsEndpoint.cs (96%) delete mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Delete/DeleteTagRequest.cs delete mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Get/All/GetAllTagsResponse.cs delete mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdRequest.cs delete mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdResponse.cs rename src/Modules/Catalog/API/Tags/Endpoints/{ => Mutations}/Delete/DeleteTagEndpoint.cs (89%) create mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Mutations/Delete/DeleteTagRequest.cs rename src/Modules/Catalog/API/Tags/Endpoints/{ => Mutations}/Post/CreateTagEndpoint.cs (92%) create mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagRequest.cs create mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagResponse.cs rename src/Modules/Catalog/API/Tags/Endpoints/{ => Mutations}/Put/EditTagEndpoint.cs (89%) create mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Mutations/Put/EditTagRequest.cs delete mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagRequest.cs delete mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagResponse.cs delete mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Put/EditTagRequest.cs rename src/Modules/Catalog/API/Tags/Endpoints/{ => Queries}/Get/All/GetAllTagsEndpoint.cs (91%) create mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/All/GetAllTagsResponse.cs rename src/Modules/Catalog/API/Tags/Endpoints/{ => Queries}/Get/Single/GetTagByIdEndpoint.cs (91%) create mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdRequest.cs create mode 100644 src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdResponse.cs rename src/Modules/Customs/API/Customs/Endpoints/Admins/{ => Mutations}/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Admins/{ => Mutations}/Patch/PatchCategory/PatchCustomCategoryRequest.cs (80%) rename src/Modules/Customs/API/Customs/Endpoints/Admins/{ => Mutations}/Patch/Remove/RemoveCustomEndpoint.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Admins/{ => Mutations}/Patch/Remove/RemoveCustomRequest.cs (80%) rename src/Modules/Customs/API/Customs/Endpoints/Admins/{ => Queries}/Get/All/GetCustomsEndpoint.cs (98%) rename src/Modules/Customs/API/Customs/Endpoints/Admins/{ => Queries}/Get/All/GetCustomsMapper.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Admins/{ => Queries}/Get/All/GetCustomsRequest.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Admins/{ => Queries}/Get/All/GetCustomsResponse.cs (94%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Delete/DeleteCustomEndpoint.cs (97%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Delete/DeleteCustomRequest.cs (82%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Post/Create/PostCustomEndpoint.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Post/Create/PostCustomMapper.cs (95%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Post/Create/PostCustomRequest.cs (85%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Post/Create/PostCustomResponse.cs (92%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Post/Purchase/Normal/PurchaseCustomEndpoint.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Post/Purchase/Normal/PurchaseCustomRequest.cs (78%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Post/Purchase/WithDelivery/PurchasCustomWithDeliveryRequest.cs (87%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Post/Purchase/WithDelivery/PurchaseCustomWithDeliveryEndpoint.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Put/PutCustomEndpoint.cs (97%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Mutations}/Put/PutCustomRequest.cs (88%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/All/GetCustomsEndpoint.cs (98%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/All/GetCustomsMapper.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/All/GetCustomsRequest.cs (95%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/All/GetCustomsResponse.cs (93%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/CalculateShipment/CalculateCustomShipmentEndpoint.cs (97%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/CalculateShipment/CalculateCustomShipmentMapper.cs (93%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/CalculateShipment/CalculateCustomShipmentRequest.cs (84%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/CalculateShipment/CalculateCustomShipmentResponse.cs (84%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/PaymentStatuses/GetCustomPaymentStatusesEndpoint.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Recent/RecentCustomsEndpoint.cs (97%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Recent/RecentCustomsMapper.cs (94%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Recent/RecentCustomsRequest.cs (81%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Recent/RecentCustomsResponse.cs (86%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Single/GetCustomEndpoint.cs (97%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Single/GetCustomMapper.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Single/GetCustomRequest.cs (80%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Single/GetCustomResponse.cs (95%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Sortings/GetCustomSortingsEndpoint.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Stats/GetCustomMapper.cs (95%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Stats/GetCustomsStatsEndpoint.cs (97%) rename src/Modules/Customs/API/Customs/Endpoints/Customers/{ => Queries}/Get/Stats/GetCustomsStatsResponse.cs (89%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers}/DesignerGroup.cs (97%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Accept/AcceptCustomEndpoint.cs (78%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Accept/AcceptCustomRequest.cs (78%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Begin/BeginCustomEndpoint.cs (78%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Begin/BeginCustomRequest.cs (78%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Cancel/CancelCustomEndpoint.cs (78%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Cancel/CancelCustomRequest.cs (78%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Finish/FinishCustomEndpoint.cs (80%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Finish/FinishCustomRequest.cs (82%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs (89%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/PatchCategory/PatchCustomCategoryRequest.cs (79%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Report/ReportCustomEndpoint.cs (78%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Mutations}/Patch/Report/ReportCustomRequest.cs (78%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Queries}/Get/All/GetCustomMapper.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Queries}/Get/All/GetCustomsEndpoint.cs (86%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Queries}/Get/All/GetCustomsRequest.cs (95%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Queries}/Get/All/GetCustomsResponse.cs (93%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Queries}/Get/Single/GetCustomEndpoint.cs (80%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Queries}/Get/Single/GetCustomMapper.cs (96%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Queries}/Get/Single/GetCustomRequest.cs (80%) rename src/Modules/Customs/API/Customs/Endpoints/{Designer => Designers/Queries}/Get/Single/GetCustomResponse.cs (95%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Mutations}/Patch/Cancel/CancelShipmentEndpoint.cs (88%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Mutations}/Patch/Cancel/CancelShipmentRequest.cs (83%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Shipment/GetShipmentsEndpoint.cs (91%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Shipment/GetShipmentsMapper.cs (84%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Shipment/GetShipmentsRequest.cs (78%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Shipment/GetShipmentsResponse.cs (71%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Sortings/GetShipmentSortingsEndpoint.cs (89%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Track/TrackShipmentEndpoint.cs (91%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Track/TrackShipmentMapper.cs (80%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Track/TrackShipmentRequest.cs (84%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Track/TrackShipmentResponse.cs (87%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Waybill/GetShipmentGetWaybillEndpoint.cs (90%) rename src/Modules/Delivery/API/Shipments/Endpoints/{ => Queries}/Get/Waybill/GetShipmentWaybillRequest.cs (83%) delete mode 100644 src/Modules/Files/API/Cads/Endpoints/Get/All/GetCadsRequest.cs delete mode 100644 src/Modules/Files/API/Cads/Endpoints/Get/Single/GetCadRequest.cs rename src/Modules/Files/API/Cads/Endpoints/{ => Mutations}/Patch/PatchCadEndpoint.cs (91%) rename src/Modules/Files/API/Cads/Endpoints/{ => Mutations}/Patch/PatchCadRequest.cs (70%) rename src/Modules/Files/API/Cads/Endpoints/{ => Mutations}/Post/CreateCadEndpoint.cs (88%) rename src/Modules/Files/API/Cads/Endpoints/{ => Mutations}/Post/CreateCadRequest.cs (57%) rename src/Modules/Files/API/Cads/Endpoints/{ => Mutations}/Put/PutCadEndpoint.cs (91%) rename src/Modules/Files/API/Cads/Endpoints/{ => Mutations}/Put/PutCadRequest.cs (54%) rename src/Modules/Files/API/Cads/Endpoints/{ => Queries}/Get/All/GetCadsEndpoint.cs (92%) create mode 100644 src/Modules/Files/API/Cads/Endpoints/Queries/Get/All/GetCadsRequest.cs rename src/Modules/Files/API/Cads/Endpoints/{ => Queries}/Get/Single/GetCadEndpoint.cs (90%) create mode 100644 src/Modules/Files/API/Cads/Endpoints/Queries/Get/Single/GetCadRequest.cs delete mode 100644 src/Modules/Files/API/Images/Endpoints/Get/Single/GetImageRequest.cs rename src/Modules/Files/API/Images/Endpoints/{ => Mutations}/Post/CreateImageEndpoint.cs (88%) rename src/Modules/Files/API/Images/Endpoints/{ => Mutations}/Post/CreateImageRequest.cs (52%) rename src/Modules/Files/API/Images/Endpoints/{ => Mutations}/Put/PutImageEndpoint.cs (90%) create mode 100644 src/Modules/Files/API/Images/Endpoints/Mutations/Put/PutImageRequest.cs delete mode 100644 src/Modules/Files/API/Images/Endpoints/Put/PutImageRequest.cs rename src/Modules/Files/API/Images/Endpoints/{ => Queries}/Get/Single/GetImageEndpoint.cs (90%) create mode 100644 src/Modules/Files/API/Images/Endpoints/Queries/Get/Single/GetImageRequest.cs delete mode 100644 src/Modules/Identity/API/Identity/Delete/Fingerprints/DeleteViewedProductRequest.cs delete mode 100644 src/Modules/Identity/API/Identity/Delete/ViewedProducts/DeleteViewedProductRequest.cs delete mode 100644 src/Modules/Identity/API/Identity/Post/ForgotPassword/ForgotPasswordRequest.cs delete mode 100644 src/Modules/Identity/API/Identity/Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs delete mode 100644 src/Modules/Identity/API/Identity/Post/VerifyEmail/ConfirmEmailRequest.cs rename src/Modules/Identity/API/{ => Users}/Dtos/FingerprintResponse.cs (70%) rename src/Modules/Identity/API/{ => Users}/Dtos/ViewedProductResponse.cs (57%) rename src/Modules/Identity/API/{Identity => Users/Endpoints}/IdentityGroup.cs (76%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Delete/DeleteAccountEndpoint.cs (90%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Delete/Fingerprints/DeleteFingerprintsEndpoint.cs (90%) create mode 100644 src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/Fingerprints/DeleteViewedProductRequest.cs rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Delete/ViewedProducts/DeleteViewedProductEndpoint.cs (89%) create mode 100644 src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/ViewedProducts/DeleteViewedProductRequest.cs rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Patch/Names/ChangeNamesEndpoint.cs (89%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Patch/Names/ChangeUsernameRequest.cs (54%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Patch/ToggleViewedProductsTracking/ToggleViewedProductsTrackingEndpoint.cs (87%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/ForgotPassword/ForgotPasswordEndpoint.cs (90%) create mode 100644 src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ForgotPassword/ForgotPasswordRequest.cs rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/Login/LoginEndpoint.cs (94%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/Login/LoginRequest.cs (55%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/Logout/LogoutEndpoint.cs (91%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/RefreshToken/RefreshTokenEndpoint.cs (93%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/Register/RegisterEndpoint.cs (93%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/Register/RegisterRequest.cs (68%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/Register/RegisterValidator.cs (92%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/ResetPassword/ResetPasswordEndpoint.cs (90%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/ResetPassword/ResetPasswordRequest.cs (50%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/RetryVerifyEmail/RetryConfirmEmailEndpoint.cs (89%) create mode 100644 src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs rename src/Modules/Identity/API/{Identity => Users/Endpoints/Mutations}/Post/VerifyEmail/ConfirmEmailEndpoint.cs (93%) create mode 100644 src/Modules/Identity/API/Users/Endpoints/Mutations/Post/VerifyEmail/ConfirmEmailRequest.cs rename src/Modules/Identity/API/{Identity => Users/Endpoints/Queries}/Get/Authentication/AuthenticationEndpoint.cs (82%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Queries}/Get/Authorization/AuthorizationEndpoint.cs (82%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Queries}/Get/DownloadInfo/DownloadInfoEndpoint.cs (94%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Queries}/Get/MyAccount/MyAccountEndpoint.cs (90%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Queries}/Get/MyAccount/MyAccountMapper.cs (89%) rename src/Modules/Identity/API/{Identity => Users/Endpoints/Queries}/Get/MyAccount/MyAccountResponse.cs (66%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Mutations}/Patch/Hide/HideNotificationEndpoint.cs (96%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Mutations}/Patch/Hide/HideNotificationRequest.cs (79%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Mutations}/Patch/Open/OpenNotificationEndpoint.cs (96%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Mutations}/Patch/Open/OpenNotificationRequest.cs (79%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Mutations}/Patch/Read/ReadNotificationEndpoint.cs (96%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Mutations}/Patch/Read/ReadNotificationRequest.cs (79%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Mutations}/Patch/Unhide/UnhideNotificationEndpoint.cs (96%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Mutations}/Patch/Unhide/UnhideNotificationRequest.cs (78%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Queries}/Get/All/GetNotificationsEndpoint.cs (97%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Queries}/Get/All/GetNotificationsMapper.cs (96%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Queries}/Get/All/GetNotificationsRequest.cs (94%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Queries}/Get/All/GetNotificationsResponse.cs (93%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Queries}/Get/Sortings/GetNotificationSortingsEndpoint.cs (96%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Queries}/Get/Stats/GetNotificationsStatsEndpoint.cs (96%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Queries}/Get/Stats/GetNotificationsStatsMapper.cs (94%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Queries}/Get/Stats/GetNotificationsStatsResponse.cs (86%) rename src/Modules/Notifications/API/Notifications/Endpoints/{ => Queries}/Get/Statuses/GetNotificationStatusesEndpoint.cs (96%) rename src/Modules/Printing/API/Customizations/Endpoints/{ => Mutations}/Post/CreateCustomizationEndpoint.cs (97%) rename src/Modules/Printing/API/Customizations/Endpoints/{ => Mutations}/Post/CreateCustomizationRequest.cs (89%) rename src/Modules/Printing/API/Customizations/Endpoints/{ => Mutations}/Put/EditCustomizationEndpoint.cs (98%) rename src/Modules/Printing/API/Customizations/Endpoints/{ => Mutations}/Put/EditCustomizationRequest.cs (90%) rename src/Modules/Printing/API/Customizations/Endpoints/{ => Queries}/Get/GetCustomizationEndpoint.cs (98%) rename src/Modules/Printing/API/Customizations/Endpoints/{ => Queries}/Get/GetCustomizationRequest.cs (85%) rename src/Modules/Printing/API/Materials/Endpoints/{ => Mutations}/Delete/DeleteMaterialEndpoint.cs (89%) rename src/Modules/Printing/API/Materials/Endpoints/{ => Mutations}/Delete/DeleteMaterialRequest.cs (86%) rename src/Modules/Printing/API/Materials/Endpoints/{ => Mutations}/Post/PostMaterialEndpoint.cs (88%) rename src/Modules/Printing/API/Materials/Endpoints/{ => Mutations}/Post/PostMaterialRequest.cs (91%) rename src/Modules/Printing/API/Materials/Endpoints/{ => Mutations}/Put/PutMaterialEndpoint.cs (90%) rename src/Modules/Printing/API/Materials/Endpoints/{ => Mutations}/Put/PutMaterialRequest.cs (91%) rename src/Modules/Printing/API/Materials/Endpoints/{ => Queries}/Get/All/GetCategoriesEndpoint.cs (90%) rename src/Modules/Printing/API/Materials/Endpoints/{ => Queries}/Get/Single/GetMaterialEndpoint.cs (90%) rename src/Modules/Printing/API/Materials/Endpoints/{ => Queries}/Get/Single/GetMaterialRequest.cs (84%) diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Delete/DeleteAccountEndpoint.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Delete/DeleteAccountEndpoint.cs similarity index 89% rename from src/Modules/Accounts/API/Accounts/Endpoints/Delete/DeleteAccountEndpoint.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Delete/DeleteAccountEndpoint.cs index 59ea15295..393ccf7f7 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Delete/DeleteAccountEndpoint.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Delete/DeleteAccountEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Accounts.Application.Accounts.Commands.Internal.Delete; using CustomCADs.Shared.Domain.TypedIds.Accounts; -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Delete; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Mutations.Delete; public sealed class DeleteAccountEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Delete/DeleteAccountRequest.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Delete/DeleteAccountRequest.cs similarity index 86% rename from src/Modules/Accounts/API/Accounts/Endpoints/Delete/DeleteAccountRequest.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Delete/DeleteAccountRequest.cs index dc2502086..0da3d1fd4 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Delete/DeleteAccountRequest.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Delete/DeleteAccountRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Delete; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Mutations.Delete; public sealed record DeleteAccountRequest(Guid Id); diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Post/PostAccountEndpoint.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Post/PostAccountEndpoint.cs similarity index 88% rename from src/Modules/Accounts/API/Accounts/Endpoints/Post/PostAccountEndpoint.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Post/PostAccountEndpoint.cs index 41de8973e..a903764c5 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Post/PostAccountEndpoint.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Post/PostAccountEndpoint.cs @@ -1,10 +1,10 @@ using CustomCADs.Modules.Accounts.API.Accounts.Dtos; -using CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Get.Single; +using CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Queries.Get.Single; using CustomCADs.Modules.Accounts.Application.Accounts.Commands.Internal.Create; using CustomCADs.Modules.Accounts.Application.Accounts.Queries.Internal.GetById; using CustomCADs.Shared.Domain.TypedIds.Accounts; -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Post; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Mutations.Post; public sealed class PostAccountEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Post/PostAccountRequest.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Post/PostAccountRequest.cs similarity index 93% rename from src/Modules/Accounts/API/Accounts/Endpoints/Post/PostAccountRequest.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Post/PostAccountRequest.cs index f1de0c794..bc9fcb228 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Post/PostAccountRequest.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Mutations/Post/PostAccountRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Post; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Mutations.Post; public sealed record PostAccountRequest( string Role, diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Get/All/GetAccountsEndpoint.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/All/GetAccountsEndpoint.cs similarity index 92% rename from src/Modules/Accounts/API/Accounts/Endpoints/Get/All/GetAccountsEndpoint.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/All/GetAccountsEndpoint.cs index 3da0dad6e..6c27ab8a6 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Get/All/GetAccountsEndpoint.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/All/GetAccountsEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Accounts.Application.Accounts.Queries.Internal.GetAll; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Get.All; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Queries.Get.All; public sealed class GetAccountsEndpoint(IRequestSender sender) : Endpoint, GetAccountsMapper> diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Get/All/GetAccountsMapper.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/All/GetAccountsMapper.cs similarity index 86% rename from src/Modules/Accounts/API/Accounts/Endpoints/Get/All/GetAccountsMapper.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/All/GetAccountsMapper.cs index 7f4dc4a34..c6c2e37aa 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Get/All/GetAccountsMapper.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/All/GetAccountsMapper.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Accounts.API.Accounts.Dtos; using CustomCADs.Modules.Accounts.Application.Accounts.Queries.Internal.GetAll; -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Get.All; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Queries.Get.All; public class GetAccountsMapper : ResponseMapper { diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Get/All/GetAccountsRequest.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/All/GetAccountsRequest.cs similarity index 81% rename from src/Modules/Accounts/API/Accounts/Endpoints/Get/All/GetAccountsRequest.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/All/GetAccountsRequest.cs index 9c108e7d0..ccb5313a0 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Get/All/GetAccountsRequest.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/All/GetAccountsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Accounts.Domain.Accounts.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Get.All; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Queries.Get.All; public sealed record GetAccountsRequest( string? Name = default, diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Get/Single/GetAccountEndpoint.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/Single/GetAccountEndpoint.cs similarity index 91% rename from src/Modules/Accounts/API/Accounts/Endpoints/Get/Single/GetAccountEndpoint.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/Single/GetAccountEndpoint.cs index f14efd65c..c7d739bb9 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Get/Single/GetAccountEndpoint.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/Single/GetAccountEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Accounts.Application.Accounts.Queries.Internal.GetById; using CustomCADs.Shared.Domain.TypedIds.Accounts; -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Get.Single; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Queries.Get.Single; public sealed class GetAccountEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Get/Single/GetAccountRequest.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/Single/GetAccountRequest.cs similarity index 85% rename from src/Modules/Accounts/API/Accounts/Endpoints/Get/Single/GetAccountRequest.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/Single/GetAccountRequest.cs index 37ba88fb4..02020e828 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Get/Single/GetAccountRequest.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/Single/GetAccountRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Get.Single; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Queries.Get.Single; public sealed record GetAccountRequest(Guid Id); diff --git a/src/Modules/Accounts/API/Accounts/Endpoints/Get/Sortings/GetAccountSortingsEndpoint.cs b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/Sortings/GetAccountSortingsEndpoint.cs similarity index 89% rename from src/Modules/Accounts/API/Accounts/Endpoints/Get/Sortings/GetAccountSortingsEndpoint.cs rename to src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/Sortings/GetAccountSortingsEndpoint.cs index 268221fc9..c9aeead39 100644 --- a/src/Modules/Accounts/API/Accounts/Endpoints/Get/Sortings/GetAccountSortingsEndpoint.cs +++ b/src/Modules/Accounts/API/Accounts/Endpoints/Queries/Get/Sortings/GetAccountSortingsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Accounts.Application.Accounts.Queries.Internal.GetSortings; using CustomCADs.Modules.Accounts.Domain.Accounts.Enums; -namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Get.Sortings; +namespace CustomCADs.Modules.Accounts.API.Accounts.Endpoints.Queries.Get.Sortings; public sealed class GetAccountSortingsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Delete/DeleteRoleRequest.cs b/src/Modules/Accounts/API/Roles/Endpoints/Delete/DeleteRoleRequest.cs deleted file mode 100644 index 3386f59b7..000000000 --- a/src/Modules/Accounts/API/Roles/Endpoints/Delete/DeleteRoleRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Delete; - -public sealed record DeleteRoleRequest(int Id); diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Get/Single/GetRoleRequest.cs b/src/Modules/Accounts/API/Roles/Endpoints/Get/Single/GetRoleRequest.cs deleted file mode 100644 index bc6185fd3..000000000 --- a/src/Modules/Accounts/API/Roles/Endpoints/Get/Single/GetRoleRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Get.Single; - -public sealed record GetRoleRequest(int Id); diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Delete/DeleteRoleEndpoint.cs b/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Delete/DeleteRoleEndpoint.cs similarity index 89% rename from src/Modules/Accounts/API/Roles/Endpoints/Delete/DeleteRoleEndpoint.cs rename to src/Modules/Accounts/API/Roles/Endpoints/Mutations/Delete/DeleteRoleEndpoint.cs index a11396a42..77dc2090d 100644 --- a/src/Modules/Accounts/API/Roles/Endpoints/Delete/DeleteRoleEndpoint.cs +++ b/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Delete/DeleteRoleEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Accounts.Application.Roles.Commands.Internal.Delete; using CustomCADs.Shared.Domain.TypedIds.Accounts; -namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Delete; +namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Mutations.Delete; public sealed class DeleteRoleEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Delete/DeleteRoleRequest.cs b/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Delete/DeleteRoleRequest.cs new file mode 100644 index 000000000..1bb5b4d9e --- /dev/null +++ b/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Delete/DeleteRoleRequest.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Mutations.Delete; + +public sealed record DeleteRoleRequest(int Id); diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Post/PostRoleEndpoint.cs b/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Post/PostRoleEndpoint.cs similarity index 87% rename from src/Modules/Accounts/API/Roles/Endpoints/Post/PostRoleEndpoint.cs rename to src/Modules/Accounts/API/Roles/Endpoints/Mutations/Post/PostRoleEndpoint.cs index 8b23d40a9..46458fd00 100644 --- a/src/Modules/Accounts/API/Roles/Endpoints/Post/PostRoleEndpoint.cs +++ b/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Post/PostRoleEndpoint.cs @@ -1,9 +1,9 @@ -using CustomCADs.Modules.Accounts.API.Roles.Endpoints.Get.Single; +using CustomCADs.Modules.Accounts.API.Roles.Endpoints.Queries.Get.Single; using CustomCADs.Modules.Accounts.Application.Roles.Commands.Internal.Create; using CustomCADs.Modules.Accounts.Application.Roles.Queries.Internal.GetById; using CustomCADs.Shared.Domain.TypedIds.Accounts; -namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Post; +namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Mutations.Post; public sealed class PostRoleEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Post/PostRoleRequest.cs b/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Post/PostRoleRequest.cs new file mode 100644 index 000000000..e47caf6e0 --- /dev/null +++ b/src/Modules/Accounts/API/Roles/Endpoints/Mutations/Post/PostRoleRequest.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Mutations.Post; + +public record PostRoleRequest(string Name, string Description); diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Post/PostRoleRequest.cs b/src/Modules/Accounts/API/Roles/Endpoints/Post/PostRoleRequest.cs deleted file mode 100644 index 29d5baa01..000000000 --- a/src/Modules/Accounts/API/Roles/Endpoints/Post/PostRoleRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Post; - -public record PostRoleRequest(string Name, string Description); diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Get/All/GetRolesEndpoint.cs b/src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/All/GetRolesEndpoint.cs similarity index 89% rename from src/Modules/Accounts/API/Roles/Endpoints/Get/All/GetRolesEndpoint.cs rename to src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/All/GetRolesEndpoint.cs index 2c698eaee..c3d12a125 100644 --- a/src/Modules/Accounts/API/Roles/Endpoints/Get/All/GetRolesEndpoint.cs +++ b/src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/All/GetRolesEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Accounts.Application.Roles.Queries.Internal.GetAll; -namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Get.All; +namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Queries.Get.All; public sealed class GetRolesEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Get/Single/GetRoleEndpoint.cs b/src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/Single/GetRoleEndpoint.cs similarity index 90% rename from src/Modules/Accounts/API/Roles/Endpoints/Get/Single/GetRoleEndpoint.cs rename to src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/Single/GetRoleEndpoint.cs index b4709f2a5..01e341f1e 100644 --- a/src/Modules/Accounts/API/Roles/Endpoints/Get/Single/GetRoleEndpoint.cs +++ b/src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/Single/GetRoleEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Accounts.Application.Roles.Queries.Internal.GetById; using CustomCADs.Shared.Domain.TypedIds.Accounts; -namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Get.Single; +namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Queries.Get.Single; public sealed class GetRoleEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/Single/GetRoleRequest.cs b/src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/Single/GetRoleRequest.cs new file mode 100644 index 000000000..3be71dd18 --- /dev/null +++ b/src/Modules/Accounts/API/Roles/Endpoints/Queries/Get/Single/GetRoleRequest.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.Modules.Accounts.API.Roles.Endpoints.Queries.Get.Single; + +public sealed record GetRoleRequest(int Id); diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Delete/DeleteActiveCartItemEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Delete/DeleteActiveCartItemEndpoint.cs similarity index 90% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Delete/DeleteActiveCartItemEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Delete/DeleteActiveCartItemEndpoint.cs index 3908b4ce0..387387f60 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Delete/DeleteActiveCartItemEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Delete/DeleteActiveCartItemEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Commands.Internal.Remove; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Delete; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Delete; public sealed class DeleteActiveCartItemEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Delete/DeleteActiveCartItemRequest.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Delete/DeleteActiveCartItemRequest.cs similarity index 88% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Delete/DeleteActiveCartItemRequest.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Delete/DeleteActiveCartItemRequest.cs index 95969a770..0f26b9de1 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Delete/DeleteActiveCartItemRequest.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Delete/DeleteActiveCartItemRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Delete; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Delete; public sealed record DeleteActiveCartItemRequest( Guid ProductId diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/DecrementQuantity/DecreaeseActiveCartItemQuantityEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/DecrementQuantity/DecreaeseActiveCartItemQuantityEndpoint.cs similarity index 90% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/DecrementQuantity/DecreaeseActiveCartItemQuantityEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/DecrementQuantity/DecreaeseActiveCartItemQuantityEndpoint.cs index 24ab970c7..82a01d5dc 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/DecrementQuantity/DecreaeseActiveCartItemQuantityEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/DecrementQuantity/DecreaeseActiveCartItemQuantityEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Commands.Internal.Quantity.Decrement; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Patch.DecrementQuantity; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Patch.DecrementQuantity; public class DecreaeseActiveCartItemQuantityEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/DecrementQuantity/DecreaseActiveCartItemQuantityRequest.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/DecrementQuantity/DecreaseActiveCartItemQuantityRequest.cs similarity index 81% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/DecrementQuantity/DecreaseActiveCartItemQuantityRequest.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/DecrementQuantity/DecreaseActiveCartItemQuantityRequest.cs index c6214cff2..66892a2a6 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/DecrementQuantity/DecreaseActiveCartItemQuantityRequest.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/DecrementQuantity/DecreaseActiveCartItemQuantityRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Patch.DecrementQuantity; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Patch.DecrementQuantity; public record DecreaseActiveCartItemQuantityRequest( Guid ProductId, diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityEndpoint.cs similarity index 90% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityEndpoint.cs index a3eccc689..99565a4f8 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Commands.Internal.Quantity.Increment; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Patch.IncrementQuantity; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Patch.IncrementQuantity; public class IncreaseActiveCartItemQuantityEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityRequest.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityRequest.cs similarity index 81% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityRequest.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityRequest.cs index c667c8f35..3e2d6a718 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityRequest.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/IncrementQuantity/IncreaseActiveCartItemQuantityRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Patch.IncrementQuantity; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Patch.IncrementQuantity; public record IncreaseActiveCartItemQuantityRequest( Guid ProductId, diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryEndpoint.cs similarity index 91% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryEndpoint.cs index 0f2f13a20..348c58acb 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Shared.Domain.TypedIds.Catalog; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Patch.ToggleForDelivery; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Patch.ToggleForDelivery; public class ToggleActiveCartItemForDeliveryEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryRequest.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryRequest.cs similarity index 82% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryRequest.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryRequest.cs index 5d16d7cd2..7f4ac7113 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryRequest.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Patch/ToggleForDelivery/ToggleActiveCartItemForDeliveryRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Patch.ToggleForDelivery; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Patch.ToggleForDelivery; public record ToggleActiveCartItemForDeliveryRequest( Guid ProductId, diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Item/PostActiveCartItemEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Item/PostActiveCartItemEndpoint.cs similarity index 94% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Item/PostActiveCartItemEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Item/PostActiveCartItemEndpoint.cs index 753c6f996..ca42ef54d 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Item/PostActiveCartItemEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Item/PostActiveCartItemEndpoint.cs @@ -4,7 +4,7 @@ using CustomCADs.Shared.Domain.TypedIds.Catalog; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Post.Item; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Post.Item; public sealed class PostActiveCartItemEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Item/PostActiveCartItemRequest.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Item/PostActiveCartItemRequest.cs similarity index 89% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Item/PostActiveCartItemRequest.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Item/PostActiveCartItemRequest.cs index ed47e892c..246b203be 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Item/PostActiveCartItemRequest.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Item/PostActiveCartItemRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Post.Item; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Post.Item; public sealed record PostActiveCartItemRequest( Guid ProductId, diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Purchase/PurchaseActiveCartEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Purchase/PurchaseActiveCartEndpoint.cs similarity index 91% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Purchase/PurchaseActiveCartEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Purchase/PurchaseActiveCartEndpoint.cs index e1febaa4b..f7aca692c 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Purchase/PurchaseActiveCartEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Purchase/PurchaseActiveCartEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Commands.Internal.Purchase.Normal; using CustomCADs.Shared.Application.Abstractions.Payment; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Post.Purchase; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Post.Purchase; public sealed class PurchaseActiveCartEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Purchase/PurchaseActiveCartRequest.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Purchase/PurchaseActiveCartRequest.cs similarity index 84% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Purchase/PurchaseActiveCartRequest.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Purchase/PurchaseActiveCartRequest.cs index 68d83c374..75f51c185 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/Purchase/PurchaseActiveCartRequest.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/Purchase/PurchaseActiveCartRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Post.Purchase; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Post.Purchase; public sealed record PurchaseActiveCartRequest( string PaymentMethodId diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/PurchaseWithDelivery/PurchaseActiveCartEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/PurchaseWithDelivery/PurchaseActiveCartEndpoint.cs similarity index 91% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Post/PurchaseWithDelivery/PurchaseActiveCartEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/PurchaseWithDelivery/PurchaseActiveCartEndpoint.cs index 34cbac0de..07a31f63d 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/PurchaseWithDelivery/PurchaseActiveCartEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/PurchaseWithDelivery/PurchaseActiveCartEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; using CustomCADs.Shared.Application.Abstractions.Payment; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Post.PurchaseWithDelivery; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Post.PurchaseWithDelivery; public sealed class PurchaseActiveCartEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/PurchaseWithDelivery/PurchaseActiveCartRequest.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/PurchaseWithDelivery/PurchaseActiveCartRequest.cs similarity index 66% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Post/PurchaseWithDelivery/PurchaseActiveCartRequest.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/PurchaseWithDelivery/PurchaseActiveCartRequest.cs index dbae9f758..3492d8ef2 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Post/PurchaseWithDelivery/PurchaseActiveCartRequest.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Mutations/Post/PurchaseWithDelivery/PurchaseActiveCartRequest.cs @@ -1,6 +1,6 @@ using CustomCADs.Shared.Application.Dtos.Delivery; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Post.PurchaseWithDelivery; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Mutations.Post.PurchaseWithDelivery; public sealed record PurchaseActiveCartRequest( string PaymentMethodId, diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/All/GetActiveCartItemsEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/All/GetActiveCartItemsEndpoint.cs similarity index 90% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Get/All/GetActiveCartItemsEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/All/GetActiveCartItemsEndpoint.cs index 9988f7ce3..77dfe948f 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/All/GetActiveCartItemsEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/All/GetActiveCartItemsEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Queries.Internal.GetAll; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Get.All; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Queries.Get.All; public sealed class GetActiveCartItemsEndpoint(IRequestSender sender) : EndpointWithoutRequest> diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentEndpoint.cs similarity index 91% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentEndpoint.cs index b7d1dc195..e9679d895 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Queries.Internal.CalculateShipment; using CustomCADs.Shared.Application.Dtos.Delivery; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Get.CalculateShipment; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Queries.Get.CalculateShipment; public class CalculateActiveCartShipmentEndpoint(IRequestSender sender) : Endpoint, CalculateActiveCartShipmentMappper> diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentMappper.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentMappper.cs similarity index 84% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentMappper.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentMappper.cs index 660c512c7..ac3490cb4 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentMappper.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentMappper.cs @@ -1,6 +1,6 @@ using CustomCADs.Shared.Application.Dtos.Delivery; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Get.CalculateShipment; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Queries.Get.CalculateShipment; public class CalculateActiveCartShipmentMappper : ResponseMapper { diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentRequest.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentRequest.cs similarity index 84% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentRequest.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentRequest.cs index 1da26d812..aa9825d75 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentRequest.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Get.CalculateShipment; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Queries.Get.CalculateShipment; public record CalculateActiveCartShipmentRequest( string Country, diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentResponse.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentResponse.cs similarity index 87% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentResponse.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentResponse.cs index e658b4c5d..4fef82d5e 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/CalculateShipment/CalculateActiveCartShipmentResponse.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/CalculateShipment/CalculateActiveCartShipmentResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Get.CalculateShipment; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Queries.Get.CalculateShipment; public record CalculateActiveCartShipmentResponse( string Service, diff --git a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/Count/CountActiveCartItemsEndpoint.cs b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/Count/CountActiveCartItemsEndpoint.cs similarity index 89% rename from src/Modules/Carts/API/ActiveCarts/Endpoints/Get/Count/CountActiveCartItemsEndpoint.cs rename to src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/Count/CountActiveCartItemsEndpoint.cs index 57cd0c3a3..f8629eee2 100644 --- a/src/Modules/Carts/API/ActiveCarts/Endpoints/Get/Count/CountActiveCartItemsEndpoint.cs +++ b/src/Modules/Carts/API/ActiveCarts/Endpoints/Queries/Get/Count/CountActiveCartItemsEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Queries.Internal.Count; -namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Get.Count; +namespace CustomCADs.Modules.Carts.API.ActiveCarts.Endpoints.Queries.Get.Count; public sealed class CountActiveCartItemsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsEndpoint.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsEndpoint.cs similarity index 98% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsEndpoint.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsEndpoint.cs index f95026065..732cc1907 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsEndpoint.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.PurchasedCarts.Queries.Internal.GetAll; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.All; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.All; public sealed class GetPurchasedCartsEndpoint(IRequestSender sender) : Endpoint, GetPurchasedCartsMapper> diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsMapper.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsMapper.cs similarity index 96% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsMapper.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsMapper.cs index 4e78c3552..bac1d84f6 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsMapper.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Carts.Application.PurchasedCarts.Queries.Internal.GetAll; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.All; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.All; public class GetPurchasedCartsMapper : ResponseMapper { diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsRequest.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsRequest.cs similarity index 96% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsRequest.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsRequest.cs index 531b0ee7d..9b9aa2afd 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsRequest.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Domain.PurchasedCarts.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.All; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.All; public sealed record GetPurchasedCartsRequest( PurchasedCartSortingType SortingType = PurchasedCartSortingType.PurchasedAt, diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsResponse.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsResponse.cs similarity index 90% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsResponse.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsResponse.cs index 2f4879e67..294e8f51d 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/All/GetPurchasedCartsResponse.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/All/GetPurchasedCartsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.All; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.All; public sealed record GetPurchasedCartsResponse( Guid Id, diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/PaymentStatuses/GetPurchasedCartPaymentStatusesEndpoint.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/PaymentStatuses/GetPurchasedCartPaymentStatusesEndpoint.cs similarity index 96% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/PaymentStatuses/GetPurchasedCartPaymentStatusesEndpoint.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/PaymentStatuses/GetPurchasedCartPaymentStatusesEndpoint.cs index a0c34fc16..60244b2ac 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/PaymentStatuses/GetPurchasedCartPaymentStatusesEndpoint.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/PaymentStatuses/GetPurchasedCartPaymentStatusesEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.PurchasedCarts.Queries.Internal.GetPaymentStatuses; using CustomCADs.Modules.Carts.Domain.PurchasedCarts.Enums; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.PaymentStatuses; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.PaymentStatuses; public sealed class GetPurchasedCartPaymentStatusesEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartEndpoint.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartEndpoint.cs similarity index 97% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartEndpoint.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartEndpoint.cs index 4b7d2f717..b384601ac 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartEndpoint.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.PurchasedCarts.Queries.Internal.GetById; using CustomCADs.Shared.Domain.TypedIds.Carts; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.Single; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.Single; public sealed class GetPurchasedCartEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartMappper.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartMappper.cs similarity index 96% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartMappper.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartMappper.cs index 2d70250a3..b8c7bc3eb 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartMappper.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartMappper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Carts.Application.PurchasedCarts.Queries.Internal.GetById; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.Single; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.Single; public class GetPurchasedCartMappper : ResponseMapper { diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartRequest.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartRequest.cs similarity index 83% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartRequest.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartRequest.cs index 7268eab88..3721458e1 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartRequest.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.Single; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.Single; public sealed record GetPurchasedCartRequest(Guid Id); diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartResponse.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartResponse.cs similarity index 94% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartResponse.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartResponse.cs index a2a6d8ad4..179980f82 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Single/GetPurchasedCartResponse.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Single/GetPurchasedCartResponse.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Carts.Domain.PurchasedCarts.Enums; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.Single; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.Single; public sealed record GetPurchasedCartResponse( Guid Id, diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Sortings/GetPurchasedCartSortingsEndpoint.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Sortings/GetPurchasedCartSortingsEndpoint.cs similarity index 97% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Sortings/GetPurchasedCartSortingsEndpoint.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Sortings/GetPurchasedCartSortingsEndpoint.cs index a225af36c..d332987b8 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Sortings/GetPurchasedCartSortingsEndpoint.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Sortings/GetPurchasedCartSortingsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Carts.Application.PurchasedCarts.Queries.Internal.GetSortings; using CustomCADs.Modules.Carts.Domain.PurchasedCarts.Enums; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.Sortings; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.Sortings; public sealed class GetPurchasedCartSortingsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Stats/PurchasedCartsStatsEndpoint.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Stats/PurchasedCartsStatsEndpoint.cs similarity index 98% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Stats/PurchasedCartsStatsEndpoint.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Stats/PurchasedCartsStatsEndpoint.cs index c670aeba4..837da761b 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Stats/PurchasedCartsStatsEndpoint.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Stats/PurchasedCartsStatsEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Carts.Application.PurchasedCarts.Queries.Internal.Count.Items; using CustomCADs.Shared.Domain.TypedIds.Carts; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.Stats; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.Stats; public sealed class PurchasedCartsStatsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Stats/PurchasedCartsStatsMappper.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Stats/PurchasedCartsStatsMappper.cs similarity index 96% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Stats/PurchasedCartsStatsMappper.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Stats/PurchasedCartsStatsMappper.cs index b46763ac8..899cc1829 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Stats/PurchasedCartsStatsMappper.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Stats/PurchasedCartsStatsMappper.cs @@ -1,6 +1,6 @@ using CustomCADs.Shared.Domain.TypedIds.Carts; -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.Stats; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.Stats; using CountPurchasedCartsDto = (int TotalCartCount, Dictionary Counts); diff --git a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Stats/PurchasedCartsStatsResponse.cs b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Stats/PurchasedCartsStatsResponse.cs similarity index 87% rename from src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Stats/PurchasedCartsStatsResponse.cs rename to src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Stats/PurchasedCartsStatsResponse.cs index a7419bb59..33a02ce22 100644 --- a/src/Modules/Carts/API/PurchasedCarts/Endpoints/Get/Stats/PurchasedCartsStatsResponse.cs +++ b/src/Modules/Carts/API/PurchasedCarts/Endpoints/Queries/Get/Stats/PurchasedCartsStatsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Get.Stats; +namespace CustomCADs.Modules.Carts.API.PurchasedCarts.Endpoints.Queries.Get.Stats; public sealed record PurchasedCartsStatsResponse( int Total, diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Id/GetCategoryRequest.cs b/src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Id/GetCategoryRequest.cs deleted file mode 100644 index dbaaea6c9..000000000 --- a/src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Id/GetCategoryRequest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Get.Single.Id; - -public sealed record GetCategoryRequest( - int Id -); diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Delete/DeleteCategoryEndpoint.cs b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Delete/DeleteCategoryEndpoint.cs similarity index 89% rename from src/Modules/Catalog/API/Categories/Endpoints/Delete/DeleteCategoryEndpoint.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Mutations/Delete/DeleteCategoryEndpoint.cs index 339fe4192..c34d5dbf8 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Delete/DeleteCategoryEndpoint.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Delete/DeleteCategoryEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Categories.Commands.Internal.Delete; -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Delete; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Mutations.Delete; public sealed class DeleteCategoryEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Delete/DeleteCategoryRequest.cs b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Delete/DeleteCategoryRequest.cs similarity index 86% rename from src/Modules/Catalog/API/Categories/Endpoints/Delete/DeleteCategoryRequest.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Mutations/Delete/DeleteCategoryRequest.cs index f90b565bc..43ac993bc 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Delete/DeleteCategoryRequest.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Delete/DeleteCategoryRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Delete; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Mutations.Delete; public sealed record DeleteCategoryRequest(int Id); diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Post/PostCategoryEndpoint.cs b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Post/PostCategoryEndpoint.cs similarity index 83% rename from src/Modules/Catalog/API/Categories/Endpoints/Post/PostCategoryEndpoint.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Mutations/Post/PostCategoryEndpoint.cs index ea0432996..6406c8042 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Post/PostCategoryEndpoint.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Post/PostCategoryEndpoint.cs @@ -1,7 +1,7 @@ -using CustomCADs.Modules.Catalog.API.Categories.Endpoints.Get.Single.Id; +using CustomCADs.Modules.Catalog.API.Categories.Endpoints.Queries.Get.Single.Id; using CustomCADs.Modules.Catalog.Application.Categories.Commands.Internal.Create; -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Post; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Mutations.Post; public sealed class PostCategoryEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Post/PostCategoryRequest.cs b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Post/PostCategoryRequest.cs similarity index 89% rename from src/Modules/Catalog/API/Categories/Endpoints/Post/PostCategoryRequest.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Mutations/Post/PostCategoryRequest.cs index 67834759c..bdd545266 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Post/PostCategoryRequest.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Post/PostCategoryRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Post; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Mutations.Post; public sealed record PostCategoryRequest( string Name, diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Put/PutCategoryEndpoint.cs b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Put/PutCategoryEndpoint.cs similarity index 90% rename from src/Modules/Catalog/API/Categories/Endpoints/Put/PutCategoryEndpoint.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Mutations/Put/PutCategoryEndpoint.cs index b193aeb84..433140fa7 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Put/PutCategoryEndpoint.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Put/PutCategoryEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Categories.Commands.Internal.Edit; -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Put; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Mutations.Put; public sealed class PutCategoryEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Put/PutCategoryRequest.cs b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Put/PutCategoryRequest.cs similarity index 90% rename from src/Modules/Catalog/API/Categories/Endpoints/Put/PutCategoryRequest.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Mutations/Put/PutCategoryRequest.cs index 7c5f9c3d6..a7883e2ca 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Put/PutCategoryRequest.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Mutations/Put/PutCategoryRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Put; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Mutations.Put; public sealed record PutCategoryRequest( int Id, diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Get/All/GetCategoriesEndpoint.cs b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/All/GetCategoriesEndpoint.cs similarity index 90% rename from src/Modules/Catalog/API/Categories/Endpoints/Get/All/GetCategoriesEndpoint.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/All/GetCategoriesEndpoint.cs index 7228fca10..0be7b7528 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Get/All/GetCategoriesEndpoint.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/All/GetCategoriesEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Categories.Queries.Internal.GetAll; -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Get.All; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Queries.Get.All; public sealed class GetCategoriesEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Id/GetCategoryEndpoint.cs b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Id/GetCategoryEndpoint.cs similarity index 90% rename from src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Id/GetCategoryEndpoint.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Id/GetCategoryEndpoint.cs index 3c8b4bff1..7e1748538 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Id/GetCategoryEndpoint.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Id/GetCategoryEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Categories.Queries.Internal.GetById; -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Get.Single.Id; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Queries.Get.Single.Id; public sealed class GetCategoryEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Id/GetCategoryRequest.cs b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Id/GetCategoryRequest.cs new file mode 100644 index 000000000..018cf8f83 --- /dev/null +++ b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Id/GetCategoryRequest.cs @@ -0,0 +1,5 @@ +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Queries.Get.Single.Id; + +public sealed record GetCategoryRequest( + int Id +); diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Name/GetCategoryEndpoint.cs b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Name/GetCategoryEndpoint.cs similarity index 89% rename from src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Name/GetCategoryEndpoint.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Name/GetCategoryEndpoint.cs index 0eb0699f4..76812d2e7 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Name/GetCategoryEndpoint.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Name/GetCategoryEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Categories.Queries.Internal.GetByName; -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Get.Single.Name; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Queries.Get.Single.Name; public sealed class GetCategoryEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Name/GetCategoryRequest.cs b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Name/GetCategoryRequest.cs similarity index 82% rename from src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Name/GetCategoryRequest.cs rename to src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Name/GetCategoryRequest.cs index 55c82f08a..653b2f44e 100644 --- a/src/Modules/Catalog/API/Categories/Endpoints/Get/Single/Name/GetCategoryRequest.cs +++ b/src/Modules/Catalog/API/Categories/Endpoints/Queries/Get/Single/Name/GetCategoryRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Get.Single.Name; +namespace CustomCADs.Modules.Catalog.API.Categories.Endpoints.Queries.Get.Single.Name; public sealed record GetCategoryRequest( string Name diff --git a/src/Modules/Catalog/API/Products/Endpoints/Admin/Remove/RemoveProductEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Admin/Mutations/Remove/RemoveProductEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Admin/Remove/RemoveProductEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Admin/Mutations/Remove/RemoveProductEndpoint.cs index ca56159ea..6f219e43c 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Admin/Remove/RemoveProductEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Admin/Mutations/Remove/RemoveProductEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Commands.Internal.Admin.Remove; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Admin.Remove; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Admin.Mutations.Remove; public sealed class RemoveProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Admin/Remove/RemoveProductRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Admin/Mutations/Remove/RemoveProductRequest.cs similarity index 83% rename from src/Modules/Catalog/API/Products/Endpoints/Admin/Remove/RemoveProductRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Admin/Mutations/Remove/RemoveProductRequest.cs index 7cefaa12a..e5612f268 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Admin/Remove/RemoveProductRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Admin/Mutations/Remove/RemoveProductRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Admin.Remove; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Admin.Mutations.Remove; public sealed record RemoveProductRequest(Guid Id); diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Delete/DeleteProductEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Delete/DeleteProductEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Delete/DeleteProductEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Delete/DeleteProductEndpoint.cs index 765236e1d..1703c801f 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Delete/DeleteProductEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Delete/DeleteProductEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Commands.Internal.Creator.Delete; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Delete; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Mutations.Delete; public sealed class DeleteProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Delete/DeleteProductRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Delete/DeleteProductRequest.cs similarity index 82% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Delete/DeleteProductRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Delete/DeleteProductRequest.cs index 683f3d1b3..e50973a76 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Delete/DeleteProductRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Delete/DeleteProductRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Delete; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Mutations.Delete; public sealed record DeleteProductRequest(Guid Id); diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductEndpoint.cs index 149be4436..1302a5ce7 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductEndpoint.cs @@ -1,9 +1,9 @@ -using CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Single; +using CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Single; using CustomCADs.Modules.Catalog.Application.Products.Commands.Internal.Creator.Create; using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.GetById; using CustomCADs.Shared.Domain.TypedIds.Files; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Post; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Mutations.Post; public sealed class PostProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductMapper.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductMapper.cs index 1d10ff78a..5b6fa3010 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.GetById; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Post; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Mutations.Post; public class PostProductMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductRequest.cs similarity index 89% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductRequest.cs index 228fdb75d..f759dafd6 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Post; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Mutations.Post; public sealed record PostProductRequest( string Name, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductResponse.cs similarity index 92% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductResponse.cs index 1e3166014..05b83224c 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Post/PostProductResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Post/PostProductResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Post; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Mutations.Post; public sealed record PostProductResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Put/PutProductEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Put/PutProductEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Put/PutProductEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Put/PutProductEndpoint.cs index a67da7da5..c9d97b417 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Put/PutProductEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Put/PutProductEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Commands.Internal.Creator.Edit; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Put; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Mutations.Put; public sealed class PutProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Put/PutProductRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Put/PutProductRequest.cs similarity index 89% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Put/PutProductRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Put/PutProductRequest.cs index ee4bf11ef..7f5570101 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Put/PutProductRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Mutations/Put/PutProductRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Put; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Mutations.Put; public sealed record PutProductRequest( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsEndpoint.cs similarity index 98% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsEndpoint.cs index 072965561..6a1bc8db3 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.GetAll; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.All; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.All; public sealed class GetProductsEndpoint(IRequestSender sender) : Endpoint, GetProductsMapper> diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsMapper.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsMapper.cs index e0813dfa8..ff489a575 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.GetAll; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.All; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.All; public class GetProductsMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsRequest.cs similarity index 95% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsRequest.cs index 4794f9f4c..dcb15c4a7 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.All; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.All; public sealed record GetProductsRequest( int? CategoryId = default, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsResponse.cs similarity index 89% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsResponse.cs index df1b651ae..c883d2801 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/All/GetProductsResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/All/GetProductsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.All; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.All; public sealed record GetProductsResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/GetProductsMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/GetProductsMapper.cs similarity index 95% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/GetProductsMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/GetProductsMapper.cs index 56d122bf5..d6e7651ba 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/GetProductsMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/GetProductsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.GetAll; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Recent; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Recent; public class RecentProductsMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/RecentProductsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/RecentProductsEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/RecentProductsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/RecentProductsEndpoint.cs index 4086f7ff5..7b1f5728d 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/RecentProductsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/RecentProductsEndpoint.cs @@ -3,7 +3,7 @@ using CustomCADs.Shared.Domain.Enums; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Recent; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Recent; public sealed class RecentProductsEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/RecentProductsRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/RecentProductsRequest.cs similarity index 82% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/RecentProductsRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/RecentProductsRequest.cs index 6e5afdd37..d53017d70 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/RecentProductsRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/RecentProductsRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Recent; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Recent; public sealed record RecentProductsRequest(int Limit = 4); diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/RecentProductsResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/RecentProductsResponse.cs similarity index 88% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/RecentProductsResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/RecentProductsResponse.cs index 422719612..14f545ed7 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Recent/RecentProductsResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Recent/RecentProductsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Recent; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Recent; public sealed record RecentProductsResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductEndpoint.cs index e8d3d0285..9ad8296a5 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.GetById; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Single; public sealed class CreatorSingleProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductMapper.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductMapper.cs index c7efe636d..6b4c11409 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.GetById; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Single; public class CreatorSingleProductMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductRequest.cs similarity index 82% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductRequest.cs index 9c41c4a1e..960d26a49 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Single; public sealed record CreatorSingleProductRequest(Guid Id); diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductResponse.cs similarity index 91% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductResponse.cs index 604af9c6d..9d91a2b54 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Single/CreatorSingleProductResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Single/CreatorSingleProductResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Single; public sealed record CreatorSingleProductResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Sortings/GetProductSortingsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Sortings/GetProductSortingsEndpoint.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Sortings/GetProductSortingsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Sortings/GetProductSortingsEndpoint.cs index 4dc666694..6f801356f 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Sortings/GetProductSortingsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Sortings/GetProductSortingsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Enums; using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.GetSortings; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Sortings; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Sortings; public sealed class GetProductSortingsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Stats/ProductsStatsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Stats/ProductsStatsEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Stats/ProductsStatsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Stats/ProductsStatsEndpoint.cs index d93fef686..4e405d167 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Stats/ProductsStatsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Stats/ProductsStatsEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.Count; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Stats; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Stats; public sealed class ProductsStatsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Stats/ProductsStatsMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Stats/ProductsStatsMapper.cs similarity index 95% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Stats/ProductsStatsMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Stats/ProductsStatsMapper.cs index 17c691465..26aa196c5 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Stats/ProductsStatsMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Stats/ProductsStatsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Creator.Count; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Stats; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Stats; public class ProductsStatsMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Stats/ProductsStatsResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Stats/ProductsStatsResponse.cs similarity index 88% rename from src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Stats/ProductsStatsResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Stats/ProductsStatsResponse.cs index 303c40e22..117458219 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Creator/Get/Stats/ProductsStatsResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Creator/Queries/Get/Stats/ProductsStatsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Get.Stats; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Creator.Queries.Get.Stats; public sealed record ProductsStatsResponse( int UncheckedCount, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Report/ReportProductEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Report/ReportProductEndpoint.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Report/ReportProductEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Report/ReportProductEndpoint.cs index c21605755..80155378d 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Report/ReportProductEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Report/ReportProductEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Commands.Internal.Designer.Report; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Patch.Report; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Mutations.Patch.Report; public sealed class ReportProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Report/ReportProductRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Report/ReportProductRequest.cs similarity index 78% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Report/ReportProductRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Report/ReportProductRequest.cs index b99c403c0..6638ab1a9 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Report/ReportProductRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Report/ReportProductRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Patch.Report; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Mutations.Patch.Report; public sealed record ReportProductRequest(Guid Id); diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Validate/ValidateProductEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Validate/ValidateProductEndpoint.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Validate/ValidateProductEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Validate/ValidateProductEndpoint.cs index 30e879a5d..09bd18227 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Validate/ValidateProductEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Validate/ValidateProductEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Commands.Internal.Designer.Validate; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Patch.Validate; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Mutations.Patch.Validate; public sealed class ValidateProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Validate/ValidateProductRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Validate/ValidateProductRequest.cs similarity index 77% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Validate/ValidateProductRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Validate/ValidateProductRequest.cs index aa7f57d23..0d68bc2ad 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Patch/Validate/ValidateProductRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Mutations/Patch/Validate/ValidateProductRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Patch.Validate; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Mutations.Patch.Validate; public sealed record ValidateProductRequest(Guid Id); diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsEndpoint.cs index b08e8f54a..65324cd1e 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Catalog.Domain.Products.Enums; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Reported; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Reported; public sealed class GetReportedProductsEndpoint(IRequestSender sender) : Endpoint, GetReportedProductsMapper> diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsMapper.cs similarity index 95% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsMapper.cs index 137f892f8..b6129dac2 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Designer.GetAll; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Reported; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Reported; public class GetReportedProductsMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsRequest.cs similarity index 94% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsRequest.cs index cb9bf0433..0bee606b1 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Reported; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Reported; public sealed record GetReportedProductsRequest( int? CategoryId = null, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsResponse.cs similarity index 88% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsResponse.cs index a7c5feb9c..67bc6bb30 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Reported/GetReportedProductsResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Reported/GetReportedProductsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Reported; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Reported; public sealed record GetReportedProductsResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductEndpoint.cs index c48504f2e..072ab9918 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Designer.GetById; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Single; public sealed class DesignerSingleProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductMapper.cs similarity index 95% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductMapper.cs index af1b66633..5b5e64e92 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Designer.GetById; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Single; public class DesignerSingleProductMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductRequest.cs similarity index 81% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductRequest.cs index a754ef5c1..8c0ae35ac 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Single; public sealed record DesignerSingleProductRequest(Guid Id); diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductResponse.cs similarity index 89% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductResponse.cs index 8c24854d0..9a66632f3 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Single/DesignerSingleProductResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Single/DesignerSingleProductResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Single; public sealed record DesignerSingleProductResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Sortings/GetProductSortingsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Sortings/GetProductSortingsEndpoint.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Sortings/GetProductSortingsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Sortings/GetProductSortingsEndpoint.cs index cc9cc0036..517cc2751 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Sortings/GetProductSortingsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Sortings/GetProductSortingsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Enums; using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Designer.GetSortings; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Sortings; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Sortings; public sealed class GetProductSortingsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsEndpoint.cs index 7d8d01435..40f9d4bbf 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Catalog.Domain.Products.Enums; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Unchecked; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Unchecked; public sealed class GetUncheckedProductsEndpoint(IRequestSender sender) : Endpoint, GetUncheckedProductsMapper> diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsMapper.cs similarity index 95% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsMapper.cs index 338296def..7c2204563 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Designer.GetAll; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Unchecked; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Unchecked; public class GetUncheckedProductsMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsRequest.cs similarity index 94% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsRequest.cs index 757312633..2365dfaaf 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Unchecked; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Unchecked; public sealed record GetUncheckedProductsRequest( int? CategoryId = null, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsResponse.cs similarity index 87% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsResponse.cs index 2a9b63c69..2f751c926 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Unchecked/GetUncheckedProductsResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Unchecked/GetUncheckedProductsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Unchecked; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Unchecked; public sealed record GetUncheckedProductsResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsEndpoint.cs index 59320dd41..796c42669 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Catalog.Domain.Products.Enums; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Validated; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Validated; public sealed class GetValidatedProductsEndpoint(IRequestSender sender) : Endpoint, GetValidatedProductsMapper> diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsMapper.cs similarity index 95% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsMapper.cs index 99d3520f7..637187902 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Designer.GetAll; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Validated; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Validated; public class GetValidatedProductsMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsRequest.cs similarity index 94% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsRequest.cs index 651ebd20d..bf412059a 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Validated; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Validated; public sealed record GetValidatedProductsRequest( int? CategoryId = null, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsResponse.cs similarity index 87% rename from src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsResponse.cs index b7ab3f643..7e262e342 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Designer/Get/Validated/GetValidatedProductsResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Designer/Queries/Get/Validated/GetValidatedProductsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Get.Validated; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Designer.Queries.Get.Validated; public sealed record GetValidatedProductsResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/AddTag/AddProductTagEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/AddTag/AddProductTagEndpoint.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/AddTag/AddProductTagEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/AddTag/AddProductTagEndpoint.cs index 078d86b6f..532b38cac 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/AddTag/AddProductTagEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/AddTag/AddProductTagEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Commands.Internal.Designer.AddTag; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Patch.AddTag; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Mutations.Patch.AddTag; using static DomainConstants.Users; diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/AddTag/AddProductTagRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/AddTag/AddProductTagRequest.cs similarity index 80% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/AddTag/AddProductTagRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/AddTag/AddProductTagRequest.cs index 38fc4c823..0fac1752e 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/AddTag/AddProductTagRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/AddTag/AddProductTagRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Patch.AddTag; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Mutations.Patch.AddTag; public record AddProductTagRequest( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/RemoveTag/RemoveProductTagEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/RemoveTag/RemoveProductTagEndpoint.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/RemoveTag/RemoveProductTagEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/RemoveTag/RemoveProductTagEndpoint.cs index 564ba36c5..8dbe57630 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/RemoveTag/RemoveProductTagEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/RemoveTag/RemoveProductTagEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Commands.Internal.Designer.RemoveTag; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Patch.RemoveTag; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Mutations.Patch.RemoveTag; using static DomainConstants.Users; diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/RemoveTag/RemoveProductTagRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/RemoveTag/RemoveProductTagRequest.cs similarity index 79% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/RemoveTag/RemoveProductTagRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/RemoveTag/RemoveProductTagRequest.cs index 0e7e4ba18..4b6bea800 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Patch/RemoveTag/RemoveProductTagRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Mutations/Patch/RemoveTag/RemoveProductTagRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Patch.RemoveTag; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Mutations.Patch.RemoveTag; public record RemoveProductTagRequest( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsEndpoint.cs similarity index 98% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsEndpoint.cs index 23a9e6d69..666c607b2 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Gallery.GetAll; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Get.All; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Queries.Get.All; public sealed class GetAllGalleryProductsEndpoint(IRequestSender sender) : Endpoint, GetAllGalleryProductsMapper> diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsMapper.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsMapper.cs index baf199598..a54264dfe 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Gallery.GetAll; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Get.All; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Queries.Get.All; public class GetAllGalleryProductsMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsRequest.cs similarity index 95% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsRequest.cs index 95d8c62d5..c8d0b6595 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Get.All; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Queries.Get.All; public sealed record GetAllGalleryProductsRequest( int? CategoryId = null, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsResponse.cs similarity index 89% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsResponse.cs index 19364c561..98c3bbe61 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/All/GetAllGalleryProductsResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/All/GetAllGalleryProductsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Get.All; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Queries.Get.All; public sealed record GetAllGalleryProductsResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductEndpoint.cs similarity index 97% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductEndpoint.cs index 104e45906..5b6daed45 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Gallery.GetById; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Queries.Get.Single; public sealed class GetGalleryProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductMapper.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductMapper.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductMapper.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductMapper.cs index 3b9e13ad6..aceaea631 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductMapper.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Gallery.GetById; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Queries.Get.Single; public class GetGalleryProductMapper : ResponseMapper { diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductRequest.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductRequest.cs similarity index 81% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductRequest.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductRequest.cs index c9d9ac0b1..ada4e846a 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductRequest.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Queries.Get.Single; public sealed record GetGalleryProductRequest(Guid Id); diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductResponse.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductResponse.cs similarity index 92% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductResponse.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductResponse.cs index 9fe4a7d43..7c7510d57 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Single/GetGalleryProductResponse.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Single/GetGalleryProductResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Queries.Get.Single; public sealed record GetGalleryProductResponse( Guid Id, diff --git a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Sortings/GetProductSortingsEndpoint.cs b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Sortings/GetProductSortingsEndpoint.cs similarity index 96% rename from src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Sortings/GetProductSortingsEndpoint.cs rename to src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Sortings/GetProductSortingsEndpoint.cs index 96b51d21e..76e693193 100644 --- a/src/Modules/Catalog/API/Products/Endpoints/Gallery/Get/Sortings/GetProductSortingsEndpoint.cs +++ b/src/Modules/Catalog/API/Products/Endpoints/Gallery/Queries/Get/Sortings/GetProductSortingsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Products.Enums; using CustomCADs.Modules.Catalog.Application.Products.Queries.Internal.Gallery.GetSortings; -namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Get.Sortings; +namespace CustomCADs.Modules.Catalog.API.Products.Endpoints.Gallery.Queries.Get.Sortings; public sealed class GetProductSortingsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Delete/DeleteTagRequest.cs b/src/Modules/Catalog/API/Tags/Endpoints/Delete/DeleteTagRequest.cs deleted file mode 100644 index 96c531b2a..000000000 --- a/src/Modules/Catalog/API/Tags/Endpoints/Delete/DeleteTagRequest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Delete; - -public record DeleteTagRequest( - Guid Id -); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Get/All/GetAllTagsResponse.cs b/src/Modules/Catalog/API/Tags/Endpoints/Get/All/GetAllTagsResponse.cs deleted file mode 100644 index b8acca03e..000000000 --- a/src/Modules/Catalog/API/Tags/Endpoints/Get/All/GetAllTagsResponse.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Get.All; - -public record GetAllTagsResponse( - Guid Id, - string Name -); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdRequest.cs b/src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdRequest.cs deleted file mode 100644 index 8facd37a2..000000000 --- a/src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdRequest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Get.Single; - -public record GetTagByIdRequest( - Guid Id -); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdResponse.cs b/src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdResponse.cs deleted file mode 100644 index 437fcb3b9..000000000 --- a/src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdResponse.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Get.Single; - -public record GetTagByIdResponse( - Guid Id, - string Name -); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Delete/DeleteTagEndpoint.cs b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Delete/DeleteTagEndpoint.cs similarity index 89% rename from src/Modules/Catalog/API/Tags/Endpoints/Delete/DeleteTagEndpoint.cs rename to src/Modules/Catalog/API/Tags/Endpoints/Mutations/Delete/DeleteTagEndpoint.cs index 1f4b4a431..43c7cea44 100644 --- a/src/Modules/Catalog/API/Tags/Endpoints/Delete/DeleteTagEndpoint.cs +++ b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Delete/DeleteTagEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Tags.Commands.Internal.Delete; -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Delete; +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Mutations.Delete; public class DeleteTagEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Delete/DeleteTagRequest.cs b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Delete/DeleteTagRequest.cs new file mode 100644 index 000000000..57eada2f2 --- /dev/null +++ b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Delete/DeleteTagRequest.cs @@ -0,0 +1,5 @@ +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Mutations.Delete; + +public record DeleteTagRequest( + Guid Id +); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagEndpoint.cs b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagEndpoint.cs similarity index 92% rename from src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagEndpoint.cs rename to src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagEndpoint.cs index 7f949a1b6..6a056ac95 100644 --- a/src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagEndpoint.cs +++ b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Catalog.Application.Tags.Dtos; using CustomCADs.Modules.Catalog.Application.Tags.Queries.Internal.GetById; -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Post; +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Mutations.Post; public class CreateTagEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagRequest.cs b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagRequest.cs new file mode 100644 index 000000000..bddddb5ed --- /dev/null +++ b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagRequest.cs @@ -0,0 +1,5 @@ +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Mutations.Post; + +public record CreateTagRequest( + string Name +); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagResponse.cs b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagResponse.cs new file mode 100644 index 000000000..e692bbd3b --- /dev/null +++ b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Post/CreateTagResponse.cs @@ -0,0 +1,6 @@ +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Mutations.Post; + +public record CreateTagResponse( + Guid Id, + string Name +); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Put/EditTagEndpoint.cs b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Put/EditTagEndpoint.cs similarity index 89% rename from src/Modules/Catalog/API/Tags/Endpoints/Put/EditTagEndpoint.cs rename to src/Modules/Catalog/API/Tags/Endpoints/Mutations/Put/EditTagEndpoint.cs index 9e5581810..be684b9af 100644 --- a/src/Modules/Catalog/API/Tags/Endpoints/Put/EditTagEndpoint.cs +++ b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Put/EditTagEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Catalog.Application.Tags.Commands.Internal.Edit; -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Put; +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Mutations.Put; public class EditTagEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Put/EditTagRequest.cs b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Put/EditTagRequest.cs new file mode 100644 index 000000000..40e96dbb0 --- /dev/null +++ b/src/Modules/Catalog/API/Tags/Endpoints/Mutations/Put/EditTagRequest.cs @@ -0,0 +1,6 @@ +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Mutations.Put; + +public record EditTagRequest( + Guid Id, + string Name +); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagRequest.cs b/src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagRequest.cs deleted file mode 100644 index bc3ed5bbd..000000000 --- a/src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagRequest.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Post; - -public record CreateTagRequest( - string Name -); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagResponse.cs b/src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagResponse.cs deleted file mode 100644 index 0c96eb676..000000000 --- a/src/Modules/Catalog/API/Tags/Endpoints/Post/CreateTagResponse.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Post; - -public record CreateTagResponse( - Guid Id, - string Name -); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Put/EditTagRequest.cs b/src/Modules/Catalog/API/Tags/Endpoints/Put/EditTagRequest.cs deleted file mode 100644 index 5178ddbf9..000000000 --- a/src/Modules/Catalog/API/Tags/Endpoints/Put/EditTagRequest.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Put; - -public record EditTagRequest( - Guid Id, - string Name -); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Get/All/GetAllTagsEndpoint.cs b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/All/GetAllTagsEndpoint.cs similarity index 91% rename from src/Modules/Catalog/API/Tags/Endpoints/Get/All/GetAllTagsEndpoint.cs rename to src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/All/GetAllTagsEndpoint.cs index e2754b701..c64679d94 100644 --- a/src/Modules/Catalog/API/Tags/Endpoints/Get/All/GetAllTagsEndpoint.cs +++ b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/All/GetAllTagsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Tags.Dtos; using CustomCADs.Modules.Catalog.Application.Tags.Queries.Internal.GetAll; -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Get.All; +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Queries.Get.All; public class GetAllTagsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/All/GetAllTagsResponse.cs b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/All/GetAllTagsResponse.cs new file mode 100644 index 000000000..c555e1cde --- /dev/null +++ b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/All/GetAllTagsResponse.cs @@ -0,0 +1,6 @@ +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Queries.Get.All; + +public record GetAllTagsResponse( + Guid Id, + string Name +); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdEndpoint.cs b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdEndpoint.cs similarity index 91% rename from src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdEndpoint.cs rename to src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdEndpoint.cs index ad5f18b6b..31ac50e6b 100644 --- a/src/Modules/Catalog/API/Tags/Endpoints/Get/Single/GetTagByIdEndpoint.cs +++ b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Catalog.Application.Tags.Dtos; using CustomCADs.Modules.Catalog.Application.Tags.Queries.Internal.GetById; -namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Get.Single; +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Queries.Get.Single; public class GetTagByIdEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdRequest.cs b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdRequest.cs new file mode 100644 index 000000000..916033e56 --- /dev/null +++ b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdRequest.cs @@ -0,0 +1,5 @@ +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Queries.Get.Single; + +public record GetTagByIdRequest( + Guid Id +); diff --git a/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdResponse.cs b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdResponse.cs new file mode 100644 index 000000000..c6e1f7b5e --- /dev/null +++ b/src/Modules/Catalog/API/Tags/Endpoints/Queries/Get/Single/GetTagByIdResponse.cs @@ -0,0 +1,6 @@ +namespace CustomCADs.Modules.Catalog.API.Tags.Endpoints.Queries.Get.Single; + +public record GetTagByIdResponse( + Guid Id, + string Name +); diff --git a/src/Modules/Catalog/API/Tags/Mapper.cs b/src/Modules/Catalog/API/Tags/Mapper.cs index 3bc1859f2..f5b36f89d 100644 --- a/src/Modules/Catalog/API/Tags/Mapper.cs +++ b/src/Modules/Catalog/API/Tags/Mapper.cs @@ -1,6 +1,6 @@ -using CustomCADs.Modules.Catalog.API.Tags.Endpoints.Get.All; -using CustomCADs.Modules.Catalog.API.Tags.Endpoints.Get.Single; -using CustomCADs.Modules.Catalog.API.Tags.Endpoints.Post; +using CustomCADs.Modules.Catalog.API.Tags.Endpoints.Queries.Get.All; +using CustomCADs.Modules.Catalog.API.Tags.Endpoints.Queries.Get.Single; +using CustomCADs.Modules.Catalog.API.Tags.Endpoints.Mutations.Post; using CustomCADs.Modules.Catalog.Application.Tags.Dtos; namespace CustomCADs.Modules.Catalog.API.Tags; diff --git a/src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs index cedb5fb25..f321536f1 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Admin.SetCategory; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Patch.PatchCategory; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Mutations.Patch.PatchCategory; public class PatchCustomCategoryEndpoint(IRequestSender sender) : Endpoint { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/PatchCategory/PatchCustomCategoryRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/PatchCategory/PatchCustomCategoryRequest.cs similarity index 80% rename from src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/PatchCategory/PatchCustomCategoryRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/PatchCategory/PatchCustomCategoryRequest.cs index f0e34afc7..aac55da70 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/PatchCategory/PatchCustomCategoryRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/PatchCategory/PatchCustomCategoryRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Patch.PatchCategory; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Mutations.Patch.PatchCategory; public record PatchCustomCategoryRequest( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/Remove/RemoveCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/Remove/RemoveCustomEndpoint.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/Remove/RemoveCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/Remove/RemoveCustomEndpoint.cs index 2334d7560..12e5ab30f 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/Remove/RemoveCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/Remove/RemoveCustomEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Admin.Remove; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Patch.Remove; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Mutations.Patch.Remove; public sealed class RemoveCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/Remove/RemoveCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/Remove/RemoveCustomRequest.cs similarity index 80% rename from src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/Remove/RemoveCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/Remove/RemoveCustomRequest.cs index 2631e7031..423e529f4 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Admins/Patch/Remove/RemoveCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Admins/Mutations/Patch/Remove/RemoveCustomRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Patch.Remove; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Mutations.Patch.Remove; public sealed record RemoveCustomRequest(Guid Id); diff --git a/src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsEndpoint.cs similarity index 98% rename from src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsEndpoint.cs index 2bd4d32ef..8f0946b6f 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsEndpoint.cs @@ -3,7 +3,7 @@ using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Queries.Get.All; public sealed class GetCustomsEndpoint(IRequestSender sender) : Endpoint, GetCustomsMapper> diff --git a/src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsMapper.cs b/src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsMapper.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsMapper.cs rename to src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsMapper.cs index e7f442cb6..5e740fbd3 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsMapper.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Shared.GetAll; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Queries.Get.All; public class GetCustomsMapper : ResponseMapper { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsRequest.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsRequest.cs index 7313be178..997708088 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Queries.Get.All; public sealed record GetCustomsRequest( bool? ForDelivery = null, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsResponse.cs b/src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsResponse.cs similarity index 94% rename from src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsResponse.cs rename to src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsResponse.cs index cbd8ddff2..94d44cb43 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Admins/Get/All/GetCustomsResponse.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Admins/Queries/Get/All/GetCustomsResponse.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Admins.Queries.Get.All; public sealed record GetCustomsResponse( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Delete/DeleteCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Delete/DeleteCustomEndpoint.cs similarity index 97% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Delete/DeleteCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Delete/DeleteCustomEndpoint.cs index cda21e7cf..03336cb0d 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Delete/DeleteCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Delete/DeleteCustomEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Customers.Delete; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Delete; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Delete; public sealed class DeleteCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Delete/DeleteCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Delete/DeleteCustomRequest.cs similarity index 82% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Delete/DeleteCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Delete/DeleteCustomRequest.cs index 6896910bc..af5de4477 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Delete/DeleteCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Delete/DeleteCustomRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Delete; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Delete; public sealed record DeleteCustomRequest( Guid Id diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomEndpoint.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomEndpoint.cs index 49548d3ae..1751fd3c6 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomEndpoint.cs @@ -1,9 +1,9 @@ -using CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Single; +using CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Single; using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Customers.Create; using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Customers.GetById; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Post.Create; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Post.Create; public sealed class PostCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomMapper.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomMapper.cs similarity index 95% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomMapper.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomMapper.cs index d3a4054fb..01464e3cb 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomMapper.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Customers.GetById; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Post.Create; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Post.Create; public class PostCustomMapper : ResponseMapper { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomRequest.cs similarity index 85% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomRequest.cs index 325c9bae1..f18670bf4 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Post.Create; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Post.Create; public sealed record PostCustomRequest( string Name, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomResponse.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomResponse.cs similarity index 92% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomResponse.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomResponse.cs index e1a6cb415..50bd75671 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Create/PostCustomResponse.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Create/PostCustomResponse.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.API.Customs.Dtos; using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Post.Create; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Post.Create; public sealed record PostCustomResponse( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/Normal/PurchaseCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/Normal/PurchaseCustomEndpoint.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/Normal/PurchaseCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/Normal/PurchaseCustomEndpoint.cs index a7640df9e..ac1d91e40 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/Normal/PurchaseCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/Normal/PurchaseCustomEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Customers.Purchase.Normal; using CustomCADs.Shared.Application.Abstractions.Payment; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Post.Purchase.Normal; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Post.Purchase.Normal; public sealed class PurchaseCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/Normal/PurchaseCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/Normal/PurchaseCustomRequest.cs similarity index 78% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/Normal/PurchaseCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/Normal/PurchaseCustomRequest.cs index 6851b2769..d666fbec3 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/Normal/PurchaseCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/Normal/PurchaseCustomRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Post.Purchase.Normal; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Post.Purchase.Normal; public sealed record PurchaseCustomRequest( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/WithDelivery/PurchasCustomWithDeliveryRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/WithDelivery/PurchasCustomWithDeliveryRequest.cs similarity index 87% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/WithDelivery/PurchasCustomWithDeliveryRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/WithDelivery/PurchasCustomWithDeliveryRequest.cs index 8636b8241..7f765031a 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/WithDelivery/PurchasCustomWithDeliveryRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/WithDelivery/PurchasCustomWithDeliveryRequest.cs @@ -1,6 +1,6 @@ using CustomCADs.Shared.Application.Dtos.Delivery; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Post.Purchase.WithDelivery; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Post.Purchase.WithDelivery; public sealed record PurchasCustomWithDeliveryRequest( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/WithDelivery/PurchaseCustomWithDeliveryEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/WithDelivery/PurchaseCustomWithDeliveryEndpoint.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/WithDelivery/PurchaseCustomWithDeliveryEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/WithDelivery/PurchaseCustomWithDeliveryEndpoint.cs index bd5011384..49a568802 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Post/Purchase/WithDelivery/PurchaseCustomWithDeliveryEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Post/Purchase/WithDelivery/PurchaseCustomWithDeliveryEndpoint.cs @@ -3,7 +3,7 @@ using CustomCADs.Shared.Application.Abstractions.Payment; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Post.Purchase.WithDelivery; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Post.Purchase.WithDelivery; public sealed class PurchaseCustomWithDeliveryEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Put/PutCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Put/PutCustomEndpoint.cs similarity index 97% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Put/PutCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Put/PutCustomEndpoint.cs index 65778d154..55d737651 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Put/PutCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Put/PutCustomEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Customers.Edit; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Put; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Put; public sealed class PutCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Put/PutCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Put/PutCustomRequest.cs similarity index 88% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Put/PutCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Put/PutCustomRequest.cs index 3f3189683..e2a81b4fd 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Put/PutCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Mutations/Put/PutCustomRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Put; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Mutations.Put; public sealed record PutCustomRequest( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsEndpoint.cs similarity index 98% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsEndpoint.cs index 7127e8e93..051b586b7 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Shared.Domain.Querying; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.All; public sealed class GetCustomsEndpoint(IRequestSender sender) : Endpoint, GetCustomsMapper> diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsMapper.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsMapper.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsMapper.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsMapper.cs index 4076d7b3f..d5a883258 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsMapper.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Shared.GetAll; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.All; public class GetCustomsMapper : ResponseMapper { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsRequest.cs similarity index 95% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsRequest.cs index f262a35da..3776b5601 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.All; public sealed record GetCustomsRequest( bool? ForDelivery = null, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsResponse.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsResponse.cs similarity index 93% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsResponse.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsResponse.cs index 2fb33d3f1..94c17b469 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/All/GetCustomsResponse.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/All/GetCustomsResponse.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.All; public sealed record GetCustomsResponse( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentEndpoint.cs similarity index 97% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentEndpoint.cs index ea9fe6127..178037e60 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Shared.Application.Dtos.Delivery; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.CalculateShipment; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.CalculateShipment; public class CalculateCustomShipmentEndpoint(IRequestSender sender) : Endpoint, CalculateCustomShipmentMapper> diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentMapper.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentMapper.cs similarity index 93% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentMapper.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentMapper.cs index f5e069e04..ab4bec0b7 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentMapper.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Shared.Application.Dtos.Delivery; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.CalculateShipment; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.CalculateShipment; public class CalculateCustomShipmentMapper : ResponseMapper { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentRequest.cs similarity index 84% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentRequest.cs index 9cb1144b1..4935ec41b 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.CalculateShipment; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.CalculateShipment; public record CalculateCustomShipmentRequest( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentResponse.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentResponse.cs similarity index 84% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentResponse.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentResponse.cs index 511a814f1..af3966bc6 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/CalculateShipment/CalculateCustomShipmentResponse.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/CalculateShipment/CalculateCustomShipmentResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.CalculateShipment; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.CalculateShipment; public record CalculateCustomShipmentResponse( string Service, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/PaymentStatuses/GetCustomPaymentStatusesEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/PaymentStatuses/GetCustomPaymentStatusesEndpoint.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/PaymentStatuses/GetCustomPaymentStatusesEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/PaymentStatuses/GetCustomPaymentStatusesEndpoint.cs index c6d1fa1a6..0a2950be2 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/PaymentStatuses/GetCustomPaymentStatusesEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/PaymentStatuses/GetCustomPaymentStatusesEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Shared.GetPaymentStatuses; using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.PaymentStatuses; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.PaymentStatuses; public sealed class GetCustomPaymentStatusesEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsEndpoint.cs similarity index 97% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsEndpoint.cs index 99554e1b5..2124b6e49 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsEndpoint.cs @@ -3,7 +3,7 @@ using CustomCADs.Shared.Domain.Enums; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Recent; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Recent; public sealed class RecentCustomsEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsMapper.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsMapper.cs similarity index 94% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsMapper.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsMapper.cs index dbd372d41..f6d8e41cb 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsMapper.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Shared.GetAll; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Recent; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Recent; public class RecentCustomsMapper : ResponseMapper { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsRequest.cs similarity index 81% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsRequest.cs index 0b00419a5..6d4f90338 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Recent; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Recent; public sealed record RecentCustomsRequest( int Limit = 5 diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsResponse.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsResponse.cs similarity index 86% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsResponse.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsResponse.cs index 3fa1d3e01..1f0ff3d1d 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Recent/RecentCustomsResponse.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Recent/RecentCustomsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Recent; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Recent; public sealed record RecentCustomsResponse( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomEndpoint.cs similarity index 97% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomEndpoint.cs index 2db7de2a9..cffccabf3 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Customers.GetById; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Single; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Single; public sealed class GetCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomMapper.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomMapper.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomMapper.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomMapper.cs index 864a1a7a1..632f7026f 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomMapper.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Customers.GetById; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Single; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Single; public class GetCustomsStatsMapper : ResponseMapper { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomRequest.cs similarity index 80% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomRequest.cs index 3f4bf5f9f..c38658d1c 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Single; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Single; public sealed record GetCustomRequest( Guid Id diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomResponse.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomResponse.cs similarity index 95% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomResponse.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomResponse.cs index 04d627493..ff03070a4 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Single/GetCustomResponse.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Single/GetCustomResponse.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.API.Customs.Dtos; using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Single; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Single; public sealed record GetCustomResponse( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Sortings/GetCustomSortingsEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Sortings/GetCustomSortingsEndpoint.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Sortings/GetCustomSortingsEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Sortings/GetCustomSortingsEndpoint.cs index c03b244cc..2e4f8bd2f 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Sortings/GetCustomSortingsEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Sortings/GetCustomSortingsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Shared.GetSortings; using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Sortings; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Sortings; public sealed class GetCustomSortingsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Stats/GetCustomMapper.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Stats/GetCustomMapper.cs similarity index 95% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Stats/GetCustomMapper.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Stats/GetCustomMapper.cs index c0ac2e19b..d176e31d0 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Stats/GetCustomMapper.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Stats/GetCustomMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Customers.Count; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Stats; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Stats; public class GetCustomsStatsMapper : ResponseMapper { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Stats/GetCustomsStatsEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Stats/GetCustomsStatsEndpoint.cs similarity index 97% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Stats/GetCustomsStatsEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Stats/GetCustomsStatsEndpoint.cs index da317f282..89cb1c474 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Stats/GetCustomsStatsEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Stats/GetCustomsStatsEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Customers.Count; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Stats; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Stats; public sealed class GetCustomsStatsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Stats/GetCustomsStatsResponse.cs b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Stats/GetCustomsStatsResponse.cs similarity index 89% rename from src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Stats/GetCustomsStatsResponse.cs rename to src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Stats/GetCustomsStatsResponse.cs index 9d630f018..ae12b860f 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Customers/Get/Stats/GetCustomsStatsResponse.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Customers/Queries/Get/Stats/GetCustomsStatsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Get.Stats; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Customers.Queries.Get.Stats; public sealed record GetCustomsStatsResponse( int PendingCount, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/DesignerGroup.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/DesignerGroup.cs similarity index 97% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/DesignerGroup.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/DesignerGroup.cs index 2227158b5..cf9e7955c 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/DesignerGroup.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/DesignerGroup.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers; using static APIConstants; using static DomainConstants.Users; diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Accept/AcceptCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Accept/AcceptCustomEndpoint.cs similarity index 78% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Accept/AcceptCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Accept/AcceptCustomEndpoint.cs index 99c364bb5..c9246b5e4 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Accept/AcceptCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Accept/AcceptCustomEndpoint.cs @@ -1,6 +1,7 @@ -using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Accept; +using CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers; +using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Accept; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Accept; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Accept; public sealed class AcceptCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Accept/AcceptCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Accept/AcceptCustomRequest.cs similarity index 78% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Accept/AcceptCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Accept/AcceptCustomRequest.cs index 20f557ef5..86e9f05e8 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Accept/AcceptCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Accept/AcceptCustomRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Accept; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Accept; public sealed record AcceptCustomRequest(Guid Id); diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Begin/BeginCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Begin/BeginCustomEndpoint.cs similarity index 78% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Begin/BeginCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Begin/BeginCustomEndpoint.cs index 5f8f7e712..fd24356d3 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Begin/BeginCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Begin/BeginCustomEndpoint.cs @@ -1,6 +1,7 @@ -using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Begin; +using CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers; +using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Begin; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Begin; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Begin; public sealed class BeginCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Begin/BeginCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Begin/BeginCustomRequest.cs similarity index 78% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Begin/BeginCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Begin/BeginCustomRequest.cs index f4c669ef2..e6d8a7ef4 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Begin/BeginCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Begin/BeginCustomRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Begin; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Begin; public sealed record BeginCustomRequest(Guid Id); diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Cancel/CancelCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Cancel/CancelCustomEndpoint.cs similarity index 78% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Cancel/CancelCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Cancel/CancelCustomEndpoint.cs index 54ea14a42..99d0f2a18 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Cancel/CancelCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Cancel/CancelCustomEndpoint.cs @@ -1,6 +1,7 @@ -using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Cancel; +using CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers; +using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Cancel; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Cancel; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Cancel; public sealed class CancelCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Cancel/CancelCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Cancel/CancelCustomRequest.cs similarity index 78% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Cancel/CancelCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Cancel/CancelCustomRequest.cs index 7da0ef157..d49b6ff33 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Cancel/CancelCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Cancel/CancelCustomRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Cancel; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Cancel; public sealed record CancelCustomRequest(Guid Id); diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Finish/FinishCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Finish/FinishCustomEndpoint.cs similarity index 80% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Finish/FinishCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Finish/FinishCustomEndpoint.cs index 57d31dbce..26ed14396 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Finish/FinishCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Finish/FinishCustomEndpoint.cs @@ -1,7 +1,8 @@ -using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Finish; +using CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers; +using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Finish; using CustomCADs.Shared.Domain.TypedIds.Files; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Finish; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Finish; public sealed class FinishCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Finish/FinishCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Finish/FinishCustomRequest.cs similarity index 82% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Finish/FinishCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Finish/FinishCustomRequest.cs index 2b4d5dff0..95048e6da 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Finish/FinishCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Finish/FinishCustomRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Finish; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Finish; public sealed record FinishCustomRequest( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs similarity index 89% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs index 6e43ae197..e8ebf02f6 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/PatchCategory/PatchCustomCategoryEndpoint.cs @@ -1,7 +1,8 @@ +using CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers; using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.SetCategory; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.PatchCategory; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.PatchCategory; public class PatchCustomCategoryEndpoint(IRequestSender sender) : Endpoint { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/PatchCategory/PatchCustomCategoryRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/PatchCategory/PatchCustomCategoryRequest.cs similarity index 79% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/PatchCategory/PatchCustomCategoryRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/PatchCategory/PatchCustomCategoryRequest.cs index 512f6e5d1..f4569258c 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/PatchCategory/PatchCustomCategoryRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/PatchCategory/PatchCustomCategoryRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.PatchCategory; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.PatchCategory; public record PatchCustomCategoryRequest( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Report/ReportCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Report/ReportCustomEndpoint.cs similarity index 78% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Report/ReportCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Report/ReportCustomEndpoint.cs index 8204505db..cb19281de 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Report/ReportCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Report/ReportCustomEndpoint.cs @@ -1,6 +1,7 @@ -using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Report; +using CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers; +using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Designer.Report; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Report; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Report; public sealed class ReportCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Report/ReportCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Report/ReportCustomRequest.cs similarity index 78% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Report/ReportCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Report/ReportCustomRequest.cs index 9f8240546..475b2d0c8 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Patch/Report/ReportCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Mutations/Patch/Report/ReportCustomRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Patch.Report; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Mutations.Patch.Report; public sealed record ReportCustomRequest(Guid Id); diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomMapper.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomMapper.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomMapper.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomMapper.cs index 3d09faa03..9b6e5fd67 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomMapper.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Shared.GetAll; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Queries.Get.All; public class GetCustomsMapper : ResponseMapper { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomsEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomsEndpoint.cs similarity index 86% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomsEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomsEndpoint.cs index cdf3f9bd0..2d9cc7bdc 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomsEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomsEndpoint.cs @@ -1,9 +1,10 @@ -using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Shared.GetAll; +using CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers; +using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Shared.GetAll; using CustomCADs.Modules.Customs.Domain.Customs.Enums; using CustomCADs.Shared.Domain.Querying; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Queries.Get.All; public sealed class GetCustomsEndpoint(IRequestSender sender) : Endpoint, GetCustomsMapper> diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomsRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomsRequest.cs similarity index 95% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomsRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomsRequest.cs index ae645e5d1..b79c8de44 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomsRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Queries.Get.All; public sealed record GetCustomsRequest( bool? ForDelivery = null, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomsResponse.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomsResponse.cs similarity index 93% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomsResponse.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomsResponse.cs index b367580f3..23ec14cf8 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/All/GetCustomsResponse.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/All/GetCustomsResponse.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Get.All; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Queries.Get.All; public sealed record GetCustomsResponse( Guid Id, diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomEndpoint.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomEndpoint.cs similarity index 80% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomEndpoint.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomEndpoint.cs index f3450c4f1..178e43270 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomEndpoint.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomEndpoint.cs @@ -1,6 +1,7 @@ -using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Designer.GetById; +using CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers; +using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Designer.GetById; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Get.Single; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Queries.Get.Single; public sealed class GetCustomEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomMapper.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomMapper.cs similarity index 96% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomMapper.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomMapper.cs index a7aa4a7b7..03c0046ab 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomMapper.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Customs.Application.Customs.Queries.Internal.Designer.GetById; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Get.Single; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Queries.Get.Single; public class GetCustomMapper : ResponseMapper { diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomRequest.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomRequest.cs similarity index 80% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomRequest.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomRequest.cs index ace29c94f..b5023ebb5 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomRequest.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Get.Single; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Queries.Get.Single; public sealed record GetCustomRequest(Guid Id); diff --git a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomResponse.cs b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomResponse.cs similarity index 95% rename from src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomResponse.cs rename to src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomResponse.cs index 299a7bfd6..fb48dc7cb 100644 --- a/src/Modules/Customs/API/Customs/Endpoints/Designer/Get/Single/GetCustomResponse.cs +++ b/src/Modules/Customs/API/Customs/Endpoints/Designers/Queries/Get/Single/GetCustomResponse.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Customs.API.Customs.Dtos; using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designer.Get.Single; +namespace CustomCADs.Modules.Customs.API.Customs.Endpoints.Designers.Queries.Get.Single; public sealed record GetCustomResponse( Guid Id, diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Patch/Cancel/CancelShipmentEndpoint.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Mutations/Patch/Cancel/CancelShipmentEndpoint.cs similarity index 88% rename from src/Modules/Delivery/API/Shipments/Endpoints/Patch/Cancel/CancelShipmentEndpoint.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Mutations/Patch/Cancel/CancelShipmentEndpoint.cs index 4f6aa059b..a4984a5c2 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Patch/Cancel/CancelShipmentEndpoint.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Mutations/Patch/Cancel/CancelShipmentEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Delivery.Application.Shipments.Commands.Internal.Cancel; -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Patch.Cancel; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Mutations.Patch.Cancel; public class CancelShipmentEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Patch/Cancel/CancelShipmentRequest.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Mutations/Patch/Cancel/CancelShipmentRequest.cs similarity index 83% rename from src/Modules/Delivery/API/Shipments/Endpoints/Patch/Cancel/CancelShipmentRequest.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Mutations/Patch/Cancel/CancelShipmentRequest.cs index 0d2003d9b..85175ab43 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Patch/Cancel/CancelShipmentRequest.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Mutations/Patch/Cancel/CancelShipmentRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Patch.Cancel; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Mutations.Patch.Cancel; public record CancelShipmentRequest( Guid Id, diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsEndpoint.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsEndpoint.cs similarity index 91% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsEndpoint.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsEndpoint.cs index 1927ba767..00fe38079 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsEndpoint.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Delivery.Application.Shipments.Queries.Internal.GetAll; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Shipment; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Shipment; public class GetShipmentsEndpoint(IRequestSender sender) : Endpoint, GetShipmentsMapper> diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsMapper.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsMapper.cs similarity index 84% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsMapper.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsMapper.cs index 8127a9391..e162fe48b 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsMapper.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Delivery.Application.Shipments.Queries.Internal.GetAll; -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Shipment; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Shipment; public class GetShipmentsMapper : ResponseMapper { diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsRequest.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsRequest.cs similarity index 78% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsRequest.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsRequest.cs index 5345ff9b6..7916e9c2d 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsRequest.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Delivery.Domain.Shipments.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Shipment; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Shipment; public record GetShipmentsRequest( ShipmentSortingType SortingType = ShipmentSortingType.RequestedAt, diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsResponse.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsResponse.cs similarity index 71% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsResponse.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsResponse.cs index b25bc307d..ffbdc8629 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Shipment/GetShipmentsResponse.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Shipment/GetShipmentsResponse.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Delivery.Domain.Shipments.Enums; -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Shipment; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Shipment; public record GetShipmentsResponse( Guid Id, diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Sortings/GetShipmentSortingsEndpoint.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Sortings/GetShipmentSortingsEndpoint.cs similarity index 89% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Sortings/GetShipmentSortingsEndpoint.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Sortings/GetShipmentSortingsEndpoint.cs index 9fbab4dd8..e34c12b62 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Sortings/GetShipmentSortingsEndpoint.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Sortings/GetShipmentSortingsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Delivery.Application.Shipments.Queries.Internal.GetSortings; using CustomCADs.Modules.Delivery.Domain.Shipments.Enums; -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Sortings; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Sortings; public sealed class GetShipmentSortingsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentEndpoint.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentEndpoint.cs similarity index 91% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentEndpoint.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentEndpoint.cs index 6cc85b510..9d827814a 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentEndpoint.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Delivery.Application.Shipments.Queries.Internal.GetTracks; -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Track; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Track; public class TrackShipmentEndpoint(IRequestSender sender) : Endpoint, TrackShipmentMapper> diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentMapper.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentMapper.cs similarity index 80% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentMapper.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentMapper.cs index 892f3f1ff..90fc2f5d5 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentMapper.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Delivery.Application.Shipments.Queries.Internal.GetTracks; -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Track; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Track; public class TrackShipmentMapper : ResponseMapper { diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentRequest.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentRequest.cs similarity index 84% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentRequest.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentRequest.cs index 10cce975d..5f0f53ad4 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentRequest.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Track; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Track; public record TrackShipmentRequest(Guid Id); diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentResponse.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentResponse.cs similarity index 87% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentResponse.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentResponse.cs index 119aaf225..b7c27f5b5 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Track/TrackShipmentResponse.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Track/TrackShipmentResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Track; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Track; public record TrackShipmentResponse( string Message, diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Waybill/GetShipmentGetWaybillEndpoint.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Waybill/GetShipmentGetWaybillEndpoint.cs similarity index 90% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Waybill/GetShipmentGetWaybillEndpoint.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Waybill/GetShipmentGetWaybillEndpoint.cs index c478d33df..cf631ac7b 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Waybill/GetShipmentGetWaybillEndpoint.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Waybill/GetShipmentGetWaybillEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Delivery.Application.Shipments.Queries.Internal.GetWaybill; -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Waybill; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Waybill; using static DomainConstants.Users; diff --git a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Waybill/GetShipmentWaybillRequest.cs b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Waybill/GetShipmentWaybillRequest.cs similarity index 83% rename from src/Modules/Delivery/API/Shipments/Endpoints/Get/Waybill/GetShipmentWaybillRequest.cs rename to src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Waybill/GetShipmentWaybillRequest.cs index 18f808068..2e8176729 100644 --- a/src/Modules/Delivery/API/Shipments/Endpoints/Get/Waybill/GetShipmentWaybillRequest.cs +++ b/src/Modules/Delivery/API/Shipments/Endpoints/Queries/Get/Waybill/GetShipmentWaybillRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Get.Waybill; +namespace CustomCADs.Modules.Delivery.API.Shipments.Endpoints.Queries.Get.Waybill; public record GetShipmentWaybillRequest(Guid Id); diff --git a/src/Modules/Files/API/Cads/Endpoints/Get/All/GetCadsRequest.cs b/src/Modules/Files/API/Cads/Endpoints/Get/All/GetCadsRequest.cs deleted file mode 100644 index c2f049f50..000000000 --- a/src/Modules/Files/API/Cads/Endpoints/Get/All/GetCadsRequest.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Get.All; - -public record GetCadsRequest( - int Page = 1, - int Limit = 20 -); diff --git a/src/Modules/Files/API/Cads/Endpoints/Get/Single/GetCadRequest.cs b/src/Modules/Files/API/Cads/Endpoints/Get/Single/GetCadRequest.cs deleted file mode 100644 index 8adcce1df..000000000 --- a/src/Modules/Files/API/Cads/Endpoints/Get/Single/GetCadRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Get.Single; - -public record GetCadRequest(Guid Id); diff --git a/src/Modules/Files/API/Cads/Endpoints/Patch/PatchCadEndpoint.cs b/src/Modules/Files/API/Cads/Endpoints/Mutations/Patch/PatchCadEndpoint.cs similarity index 91% rename from src/Modules/Files/API/Cads/Endpoints/Patch/PatchCadEndpoint.cs rename to src/Modules/Files/API/Cads/Endpoints/Mutations/Patch/PatchCadEndpoint.cs index 7bf8fd661..63fa63c84 100644 --- a/src/Modules/Files/API/Cads/Endpoints/Patch/PatchCadEndpoint.cs +++ b/src/Modules/Files/API/Cads/Endpoints/Mutations/Patch/PatchCadEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Files.Application.Cads.Commands.Internal.SetCoords; -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Patch; +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Mutations.Patch; public sealed class PatchCadEndpoint(IRequestSender sender) : Endpoint { diff --git a/src/Modules/Files/API/Cads/Endpoints/Patch/PatchCadRequest.cs b/src/Modules/Files/API/Cads/Endpoints/Mutations/Patch/PatchCadRequest.cs similarity index 70% rename from src/Modules/Files/API/Cads/Endpoints/Patch/PatchCadRequest.cs rename to src/Modules/Files/API/Cads/Endpoints/Mutations/Patch/PatchCadRequest.cs index 17d748af9..49d6fe1cf 100644 --- a/src/Modules/Files/API/Cads/Endpoints/Patch/PatchCadRequest.cs +++ b/src/Modules/Files/API/Cads/Endpoints/Mutations/Patch/PatchCadRequest.cs @@ -1,6 +1,6 @@ using CustomCADs.Shared.Application.Dtos.Files; -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Patch; +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Mutations.Patch; public sealed record PatchCadRequest( Guid Id, diff --git a/src/Modules/Files/API/Cads/Endpoints/Post/CreateCadEndpoint.cs b/src/Modules/Files/API/Cads/Endpoints/Mutations/Post/CreateCadEndpoint.cs similarity index 88% rename from src/Modules/Files/API/Cads/Endpoints/Post/CreateCadEndpoint.cs rename to src/Modules/Files/API/Cads/Endpoints/Mutations/Post/CreateCadEndpoint.cs index eadb06170..33d92b2b6 100644 --- a/src/Modules/Files/API/Cads/Endpoints/Post/CreateCadEndpoint.cs +++ b/src/Modules/Files/API/Cads/Endpoints/Mutations/Post/CreateCadEndpoint.cs @@ -1,11 +1,11 @@ -using CustomCADs.Modules.Files.API.Cads.Endpoints.Get.Single; +using CustomCADs.Modules.Files.API.Cads.Endpoints.Queries.Get.Single; using CustomCADs.Modules.Files.Application.Cads.Commands.Internal.Create; using CustomCADs.Modules.Files.Application.Cads.Dtos; using CustomCADs.Modules.Files.Application.Cads.Queries.Internal.GetById; using CustomCADs.Shared.API.Attributes; using Microsoft.AspNetCore.Builder; -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Post; +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Mutations.Post; public class CreateCadEndpoint(IRequestSender sender) : Endpoint { diff --git a/src/Modules/Files/API/Cads/Endpoints/Post/CreateCadRequest.cs b/src/Modules/Files/API/Cads/Endpoints/Mutations/Post/CreateCadRequest.cs similarity index 57% rename from src/Modules/Files/API/Cads/Endpoints/Post/CreateCadRequest.cs rename to src/Modules/Files/API/Cads/Endpoints/Mutations/Post/CreateCadRequest.cs index c561cd029..f078501e5 100644 --- a/src/Modules/Files/API/Cads/Endpoints/Post/CreateCadRequest.cs +++ b/src/Modules/Files/API/Cads/Endpoints/Mutations/Post/CreateCadRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Post; +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Mutations.Post; public record CreateCadRequest( string GeneratedKey, diff --git a/src/Modules/Files/API/Cads/Endpoints/Put/PutCadEndpoint.cs b/src/Modules/Files/API/Cads/Endpoints/Mutations/Put/PutCadEndpoint.cs similarity index 91% rename from src/Modules/Files/API/Cads/Endpoints/Put/PutCadEndpoint.cs rename to src/Modules/Files/API/Cads/Endpoints/Mutations/Put/PutCadEndpoint.cs index bbdd336e4..641166432 100644 --- a/src/Modules/Files/API/Cads/Endpoints/Put/PutCadEndpoint.cs +++ b/src/Modules/Files/API/Cads/Endpoints/Mutations/Put/PutCadEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Files.Application.Cads.Commands.Internal.Edit; -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Put; +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Mutations.Put; public sealed class PutCadEndpoint(IRequestSender sender) : Endpoint { diff --git a/src/Modules/Files/API/Cads/Endpoints/Put/PutCadRequest.cs b/src/Modules/Files/API/Cads/Endpoints/Mutations/Put/PutCadRequest.cs similarity index 54% rename from src/Modules/Files/API/Cads/Endpoints/Put/PutCadRequest.cs rename to src/Modules/Files/API/Cads/Endpoints/Mutations/Put/PutCadRequest.cs index abea0f02d..dfb33b9ad 100644 --- a/src/Modules/Files/API/Cads/Endpoints/Put/PutCadRequest.cs +++ b/src/Modules/Files/API/Cads/Endpoints/Mutations/Put/PutCadRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Put; +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Mutations.Put; public sealed record PutCadRequest( Guid Id, diff --git a/src/Modules/Files/API/Cads/Endpoints/Get/All/GetCadsEndpoint.cs b/src/Modules/Files/API/Cads/Endpoints/Queries/Get/All/GetCadsEndpoint.cs similarity index 92% rename from src/Modules/Files/API/Cads/Endpoints/Get/All/GetCadsEndpoint.cs rename to src/Modules/Files/API/Cads/Endpoints/Queries/Get/All/GetCadsEndpoint.cs index 2a1ab9dc5..a186bc9ac 100644 --- a/src/Modules/Files/API/Cads/Endpoints/Get/All/GetCadsEndpoint.cs +++ b/src/Modules/Files/API/Cads/Endpoints/Queries/Get/All/GetCadsEndpoint.cs @@ -3,7 +3,7 @@ using CustomCADs.Modules.Files.Application.Cads.Queries.Internal.GetAll; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Get.All; +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Queries.Get.All; public class GetCadsEndpoint(IRequestSender sender) : Endpoint> { diff --git a/src/Modules/Files/API/Cads/Endpoints/Queries/Get/All/GetCadsRequest.cs b/src/Modules/Files/API/Cads/Endpoints/Queries/Get/All/GetCadsRequest.cs new file mode 100644 index 000000000..b7359e110 --- /dev/null +++ b/src/Modules/Files/API/Cads/Endpoints/Queries/Get/All/GetCadsRequest.cs @@ -0,0 +1,6 @@ +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Queries.Get.All; + +public record GetCadsRequest( + int Page = 1, + int Limit = 20 +); diff --git a/src/Modules/Files/API/Cads/Endpoints/Get/Single/GetCadEndpoint.cs b/src/Modules/Files/API/Cads/Endpoints/Queries/Get/Single/GetCadEndpoint.cs similarity index 90% rename from src/Modules/Files/API/Cads/Endpoints/Get/Single/GetCadEndpoint.cs rename to src/Modules/Files/API/Cads/Endpoints/Queries/Get/Single/GetCadEndpoint.cs index 397ee563f..afca8ab62 100644 --- a/src/Modules/Files/API/Cads/Endpoints/Get/Single/GetCadEndpoint.cs +++ b/src/Modules/Files/API/Cads/Endpoints/Queries/Get/Single/GetCadEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Files.Application.Cads.Dtos; using CustomCADs.Modules.Files.Application.Cads.Queries.Internal.GetById; -namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Get.Single; +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Queries.Get.Single; public class GetCadEndpoint(IRequestSender sender) : Endpoint { diff --git a/src/Modules/Files/API/Cads/Endpoints/Queries/Get/Single/GetCadRequest.cs b/src/Modules/Files/API/Cads/Endpoints/Queries/Get/Single/GetCadRequest.cs new file mode 100644 index 000000000..37ed9929f --- /dev/null +++ b/src/Modules/Files/API/Cads/Endpoints/Queries/Get/Single/GetCadRequest.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.Modules.Files.API.Cads.Endpoints.Queries.Get.Single; + +public record GetCadRequest(Guid Id); diff --git a/src/Modules/Files/API/Images/Endpoints/Get/Single/GetImageRequest.cs b/src/Modules/Files/API/Images/Endpoints/Get/Single/GetImageRequest.cs deleted file mode 100644 index 336342699..000000000 --- a/src/Modules/Files/API/Images/Endpoints/Get/Single/GetImageRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.Modules.Files.API.Images.Endpoints.Get.Single; - -public record GetImageRequest(Guid Id); diff --git a/src/Modules/Files/API/Images/Endpoints/Post/CreateImageEndpoint.cs b/src/Modules/Files/API/Images/Endpoints/Mutations/Post/CreateImageEndpoint.cs similarity index 88% rename from src/Modules/Files/API/Images/Endpoints/Post/CreateImageEndpoint.cs rename to src/Modules/Files/API/Images/Endpoints/Mutations/Post/CreateImageEndpoint.cs index 41694d214..3ebf36f28 100644 --- a/src/Modules/Files/API/Images/Endpoints/Post/CreateImageEndpoint.cs +++ b/src/Modules/Files/API/Images/Endpoints/Mutations/Post/CreateImageEndpoint.cs @@ -1,11 +1,11 @@ -using CustomCADs.Modules.Files.API.Images.Endpoints.Get.Single; +using CustomCADs.Modules.Files.API.Images.Endpoints.Queries.Get.Single; using CustomCADs.Modules.Files.Application.Images.Commands.Internal.Create; using CustomCADs.Modules.Files.Application.Images.Dtos; using CustomCADs.Modules.Files.Application.Images.Queries.Internal.GetById; using CustomCADs.Shared.API.Attributes; using Microsoft.AspNetCore.Builder; -namespace CustomCADs.Modules.Files.API.Images.Endpoints.Post; +namespace CustomCADs.Modules.Files.API.Images.Endpoints.Mutations.Post; public class CreateImageEndpoint(IRequestSender sender) : Endpoint { diff --git a/src/Modules/Files/API/Images/Endpoints/Post/CreateImageRequest.cs b/src/Modules/Files/API/Images/Endpoints/Mutations/Post/CreateImageRequest.cs similarity index 52% rename from src/Modules/Files/API/Images/Endpoints/Post/CreateImageRequest.cs rename to src/Modules/Files/API/Images/Endpoints/Mutations/Post/CreateImageRequest.cs index 6d375f86d..3045ecd25 100644 --- a/src/Modules/Files/API/Images/Endpoints/Post/CreateImageRequest.cs +++ b/src/Modules/Files/API/Images/Endpoints/Mutations/Post/CreateImageRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Files.API.Images.Endpoints.Post; +namespace CustomCADs.Modules.Files.API.Images.Endpoints.Mutations.Post; public record CreateImageRequest( string GeneratedKey, diff --git a/src/Modules/Files/API/Images/Endpoints/Put/PutImageEndpoint.cs b/src/Modules/Files/API/Images/Endpoints/Mutations/Put/PutImageEndpoint.cs similarity index 90% rename from src/Modules/Files/API/Images/Endpoints/Put/PutImageEndpoint.cs rename to src/Modules/Files/API/Images/Endpoints/Mutations/Put/PutImageEndpoint.cs index e7f0edf3b..e48569395 100644 --- a/src/Modules/Files/API/Images/Endpoints/Put/PutImageEndpoint.cs +++ b/src/Modules/Files/API/Images/Endpoints/Mutations/Put/PutImageEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Files.Application.Images.Commands.Internal.Edit; -namespace CustomCADs.Modules.Files.API.Images.Endpoints.Put; +namespace CustomCADs.Modules.Files.API.Images.Endpoints.Mutations.Put; public sealed class PutImageEndpoint(IRequestSender sender) : Endpoint { diff --git a/src/Modules/Files/API/Images/Endpoints/Mutations/Put/PutImageRequest.cs b/src/Modules/Files/API/Images/Endpoints/Mutations/Put/PutImageRequest.cs new file mode 100644 index 000000000..346198832 --- /dev/null +++ b/src/Modules/Files/API/Images/Endpoints/Mutations/Put/PutImageRequest.cs @@ -0,0 +1,6 @@ +namespace CustomCADs.Modules.Files.API.Images.Endpoints.Mutations.Put; + +public sealed record PutImageRequest( + Guid Id, + string ContentType +); diff --git a/src/Modules/Files/API/Images/Endpoints/Put/PutImageRequest.cs b/src/Modules/Files/API/Images/Endpoints/Put/PutImageRequest.cs deleted file mode 100644 index 105d5c6a9..000000000 --- a/src/Modules/Files/API/Images/Endpoints/Put/PutImageRequest.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CustomCADs.Modules.Files.API.Images.Endpoints.Put; - -public sealed record PutImageRequest( - Guid Id, - string ContentType -); diff --git a/src/Modules/Files/API/Images/Endpoints/Get/Single/GetImageEndpoint.cs b/src/Modules/Files/API/Images/Endpoints/Queries/Get/Single/GetImageEndpoint.cs similarity index 90% rename from src/Modules/Files/API/Images/Endpoints/Get/Single/GetImageEndpoint.cs rename to src/Modules/Files/API/Images/Endpoints/Queries/Get/Single/GetImageEndpoint.cs index bf22e6180..5c88d95e2 100644 --- a/src/Modules/Files/API/Images/Endpoints/Get/Single/GetImageEndpoint.cs +++ b/src/Modules/Files/API/Images/Endpoints/Queries/Get/Single/GetImageEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Files.Application.Images.Dtos; using CustomCADs.Modules.Files.Application.Images.Queries.Internal.GetById; -namespace CustomCADs.Modules.Files.API.Images.Endpoints.Get.Single; +namespace CustomCADs.Modules.Files.API.Images.Endpoints.Queries.Get.Single; public class GetImageEndpoint(IRequestSender sender) : Endpoint { diff --git a/src/Modules/Files/API/Images/Endpoints/Queries/Get/Single/GetImageRequest.cs b/src/Modules/Files/API/Images/Endpoints/Queries/Get/Single/GetImageRequest.cs new file mode 100644 index 000000000..c6cef2814 --- /dev/null +++ b/src/Modules/Files/API/Images/Endpoints/Queries/Get/Single/GetImageRequest.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.Modules.Files.API.Images.Endpoints.Queries.Get.Single; + +public record GetImageRequest(Guid Id); diff --git a/src/Modules/Identity/API/Identity/Delete/Fingerprints/DeleteViewedProductRequest.cs b/src/Modules/Identity/API/Identity/Delete/Fingerprints/DeleteViewedProductRequest.cs deleted file mode 100644 index 9f6f22bc9..000000000 --- a/src/Modules/Identity/API/Identity/Delete/Fingerprints/DeleteViewedProductRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Delete.Fingerprints; - -public sealed record DeleteFingerprintsRequest(Guid RefreshTokenId); diff --git a/src/Modules/Identity/API/Identity/Delete/ViewedProducts/DeleteViewedProductRequest.cs b/src/Modules/Identity/API/Identity/Delete/ViewedProducts/DeleteViewedProductRequest.cs deleted file mode 100644 index 9f79a962f..000000000 --- a/src/Modules/Identity/API/Identity/Delete/ViewedProducts/DeleteViewedProductRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Delete.ViewedProducts; - -public sealed record DeleteViewedProductRequest(Guid ProductId); diff --git a/src/Modules/Identity/API/Identity/Post/ForgotPassword/ForgotPasswordRequest.cs b/src/Modules/Identity/API/Identity/Post/ForgotPassword/ForgotPasswordRequest.cs deleted file mode 100644 index 9c86e4350..000000000 --- a/src/Modules/Identity/API/Identity/Post/ForgotPassword/ForgotPasswordRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Post.ForgotPassword; - -public sealed record ForgotPasswordRequest(string Email); diff --git a/src/Modules/Identity/API/Identity/Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs b/src/Modules/Identity/API/Identity/Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs deleted file mode 100644 index dc1b2fa37..000000000 --- a/src/Modules/Identity/API/Identity/Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Post.RetryVerifyEmail; - -public sealed record RetryConfirmEmailRequest(string Username); diff --git a/src/Modules/Identity/API/Identity/Post/VerifyEmail/ConfirmEmailRequest.cs b/src/Modules/Identity/API/Identity/Post/VerifyEmail/ConfirmEmailRequest.cs deleted file mode 100644 index ea7b6726a..000000000 --- a/src/Modules/Identity/API/Identity/Post/VerifyEmail/ConfirmEmailRequest.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Post.VerifyEmail; - -public sealed record ConfirmEmailRequest( - string Username, - string Token -); diff --git a/src/Modules/Identity/API/Dtos/FingerprintResponse.cs b/src/Modules/Identity/API/Users/Dtos/FingerprintResponse.cs similarity index 70% rename from src/Modules/Identity/API/Dtos/FingerprintResponse.cs rename to src/Modules/Identity/API/Users/Dtos/FingerprintResponse.cs index 6172672bd..9f00310eb 100644 --- a/src/Modules/Identity/API/Dtos/FingerprintResponse.cs +++ b/src/Modules/Identity/API/Users/Dtos/FingerprintResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Identity.API.Dtos; +namespace CustomCADs.Modules.Identity.API.Users.Dtos; public record FingerprintResponse( Guid Id, diff --git a/src/Modules/Identity/API/Dtos/ViewedProductResponse.cs b/src/Modules/Identity/API/Users/Dtos/ViewedProductResponse.cs similarity index 57% rename from src/Modules/Identity/API/Dtos/ViewedProductResponse.cs rename to src/Modules/Identity/API/Users/Dtos/ViewedProductResponse.cs index 5325c19f3..fe4830319 100644 --- a/src/Modules/Identity/API/Dtos/ViewedProductResponse.cs +++ b/src/Modules/Identity/API/Users/Dtos/ViewedProductResponse.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Identity.API.Dtos; +namespace CustomCADs.Modules.Identity.API.Users.Dtos; public record ViewedProductResponse(Guid Id, DateTimeOffset ViewedAt); diff --git a/src/Modules/Identity/API/Identity/IdentityGroup.cs b/src/Modules/Identity/API/Users/Endpoints/IdentityGroup.cs similarity index 76% rename from src/Modules/Identity/API/Identity/IdentityGroup.cs rename to src/Modules/Identity/API/Users/Endpoints/IdentityGroup.cs index 383755415..e514c3513 100644 --- a/src/Modules/Identity/API/Identity/IdentityGroup.cs +++ b/src/Modules/Identity/API/Users/Endpoints/IdentityGroup.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Identity.API.Identity; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints; using static APIConstants; diff --git a/src/Modules/Identity/API/Identity/Delete/DeleteAccountEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/DeleteAccountEndpoint.cs similarity index 90% rename from src/Modules/Identity/API/Identity/Delete/DeleteAccountEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/DeleteAccountEndpoint.cs index ef54d3abe..7a58bfadd 100644 --- a/src/Modules/Identity/API/Identity/Delete/DeleteAccountEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/DeleteAccountEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Identity.Application.Users.Dtos; using Microsoft.Extensions.Options; -namespace CustomCADs.Modules.Identity.API.Identity.Delete; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Delete; public sealed class DeleteAccountEndpoint(IRequestSender sender, IOptions settings) : EndpointWithoutRequest diff --git a/src/Modules/Identity/API/Identity/Delete/Fingerprints/DeleteFingerprintsEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/Fingerprints/DeleteFingerprintsEndpoint.cs similarity index 90% rename from src/Modules/Identity/API/Identity/Delete/Fingerprints/DeleteFingerprintsEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/Fingerprints/DeleteFingerprintsEndpoint.cs index 680e4362c..aa77480aa 100644 --- a/src/Modules/Identity/API/Identity/Delete/Fingerprints/DeleteFingerprintsEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/Fingerprints/DeleteFingerprintsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Identity.Application.Users.Commands.Internal.Delete.Fingerprints; using CustomCADs.Shared.Domain.TypedIds.Identity; -namespace CustomCADs.Modules.Identity.API.Identity.Delete.Fingerprints; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Delete.Fingerprints; public sealed class DeleteFingerprintsEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/Fingerprints/DeleteViewedProductRequest.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/Fingerprints/DeleteViewedProductRequest.cs new file mode 100644 index 000000000..896a3d2e0 --- /dev/null +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/Fingerprints/DeleteViewedProductRequest.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Delete.Fingerprints; + +public sealed record DeleteFingerprintsRequest(Guid RefreshTokenId); diff --git a/src/Modules/Identity/API/Identity/Delete/ViewedProducts/DeleteViewedProductEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/ViewedProducts/DeleteViewedProductEndpoint.cs similarity index 89% rename from src/Modules/Identity/API/Identity/Delete/ViewedProducts/DeleteViewedProductEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/ViewedProducts/DeleteViewedProductEndpoint.cs index 95c1eed1d..da76bae25 100644 --- a/src/Modules/Identity/API/Identity/Delete/ViewedProducts/DeleteViewedProductEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/ViewedProducts/DeleteViewedProductEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Shared.Application.UseCases.Accounts.Commands; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.Modules.Identity.API.Identity.Delete.ViewedProducts; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Delete.ViewedProducts; public sealed class DeleteViewedProductEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/ViewedProducts/DeleteViewedProductRequest.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/ViewedProducts/DeleteViewedProductRequest.cs new file mode 100644 index 000000000..1de42eb84 --- /dev/null +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Delete/ViewedProducts/DeleteViewedProductRequest.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Delete.ViewedProducts; + +public sealed record DeleteViewedProductRequest(Guid ProductId); diff --git a/src/Modules/Identity/API/Identity/Patch/Names/ChangeNamesEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Patch/Names/ChangeNamesEndpoint.cs similarity index 89% rename from src/Modules/Identity/API/Identity/Patch/Names/ChangeNamesEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Patch/Names/ChangeNamesEndpoint.cs index 42716b5f7..5272289a3 100644 --- a/src/Modules/Identity/API/Identity/Patch/Names/ChangeNamesEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Patch/Names/ChangeNamesEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Identity.Application.Users.Commands.Internal.ChangeUsername; -namespace CustomCADs.Modules.Identity.API.Identity.Patch.Names; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Patch.Names; public sealed class ChangeNamesEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Identity/API/Identity/Patch/Names/ChangeUsernameRequest.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Patch/Names/ChangeUsernameRequest.cs similarity index 54% rename from src/Modules/Identity/API/Identity/Patch/Names/ChangeUsernameRequest.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Patch/Names/ChangeUsernameRequest.cs index 6187bd24e..dbb354177 100644 --- a/src/Modules/Identity/API/Identity/Patch/Names/ChangeUsernameRequest.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Patch/Names/ChangeUsernameRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Patch.Names; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Patch.Names; public sealed record ChangeNamesRequest( string Username, diff --git a/src/Modules/Identity/API/Identity/Patch/ToggleViewedProductsTracking/ToggleViewedProductsTrackingEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Patch/ToggleViewedProductsTracking/ToggleViewedProductsTrackingEndpoint.cs similarity index 87% rename from src/Modules/Identity/API/Identity/Patch/ToggleViewedProductsTracking/ToggleViewedProductsTrackingEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Patch/ToggleViewedProductsTracking/ToggleViewedProductsTrackingEndpoint.cs index 9ca86b99f..455e60880 100644 --- a/src/Modules/Identity/API/Identity/Patch/ToggleViewedProductsTracking/ToggleViewedProductsTrackingEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Patch/ToggleViewedProductsTracking/ToggleViewedProductsTrackingEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Identity.Application.Users.Commands.Internal.ToggleViewedProductsTracking; -namespace CustomCADs.Modules.Identity.API.Identity.Patch.ToggleViewedProductsTracking; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Patch.ToggleViewedProductsTracking; public sealed class ToggleViewedProductsTrackingEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Identity/API/Identity/Post/ForgotPassword/ForgotPasswordEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ForgotPassword/ForgotPasswordEndpoint.cs similarity index 90% rename from src/Modules/Identity/API/Identity/Post/ForgotPassword/ForgotPasswordEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ForgotPassword/ForgotPasswordEndpoint.cs index 38f94c914..a8ae45edc 100644 --- a/src/Modules/Identity/API/Identity/Post/ForgotPassword/ForgotPasswordEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ForgotPassword/ForgotPasswordEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Identity.Application.Users.Commands.Internal.ResetPasswordEmail; using CustomCADs.Shared.API.Attributes; -namespace CustomCADs.Modules.Identity.API.Identity.Post.ForgotPassword; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.ForgotPassword; public sealed class ForgotPasswordEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ForgotPassword/ForgotPasswordRequest.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ForgotPassword/ForgotPasswordRequest.cs new file mode 100644 index 000000000..0f70ffbb8 --- /dev/null +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ForgotPassword/ForgotPasswordRequest.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.ForgotPassword; + +public sealed record ForgotPasswordRequest(string Email); diff --git a/src/Modules/Identity/API/Identity/Post/Login/LoginEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Login/LoginEndpoint.cs similarity index 94% rename from src/Modules/Identity/API/Identity/Post/Login/LoginEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Login/LoginEndpoint.cs index 33558dd2c..7e48fd56a 100644 --- a/src/Modules/Identity/API/Identity/Post/Login/LoginEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Login/LoginEndpoint.cs @@ -4,7 +4,7 @@ using CustomCADs.Shared.API.Attributes; using Microsoft.Extensions.Options; -namespace CustomCADs.Modules.Identity.API.Identity.Post.Login; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.Login; public sealed class LoginEndpoint(IRequestSender sender, IFingerprintService fingerprintService, IOptions settings) : Endpoint diff --git a/src/Modules/Identity/API/Identity/Post/Login/LoginRequest.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Login/LoginRequest.cs similarity index 55% rename from src/Modules/Identity/API/Identity/Post/Login/LoginRequest.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Login/LoginRequest.cs index 6b344e0a8..6efadba28 100644 --- a/src/Modules/Identity/API/Identity/Post/Login/LoginRequest.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Login/LoginRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Post.Login; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.Login; public sealed record LoginRequest( string Username, diff --git a/src/Modules/Identity/API/Identity/Post/Logout/LogoutEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Logout/LogoutEndpoint.cs similarity index 91% rename from src/Modules/Identity/API/Identity/Post/Logout/LogoutEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Logout/LogoutEndpoint.cs index b2fe18a25..baa35c0a5 100644 --- a/src/Modules/Identity/API/Identity/Post/Logout/LogoutEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Logout/LogoutEndpoint.cs @@ -3,7 +3,7 @@ using CustomCADs.Shared.API.Attributes; using Microsoft.Extensions.Options; -namespace CustomCADs.Modules.Identity.API.Identity.Post.Logout; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.Logout; public sealed class LogoutEndpoint(IRequestSender sender, IOptions settings) : EndpointWithoutRequest diff --git a/src/Modules/Identity/API/Identity/Post/RefreshToken/RefreshTokenEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RefreshToken/RefreshTokenEndpoint.cs similarity index 93% rename from src/Modules/Identity/API/Identity/Post/RefreshToken/RefreshTokenEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RefreshToken/RefreshTokenEndpoint.cs index bfe25e195..1d570e9e6 100644 --- a/src/Modules/Identity/API/Identity/Post/RefreshToken/RefreshTokenEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RefreshToken/RefreshTokenEndpoint.cs @@ -4,7 +4,7 @@ using CustomCADs.Shared.API.Attributes; using Microsoft.Extensions.Options; -namespace CustomCADs.Modules.Identity.API.Identity.Post.RefreshToken; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.RefreshToken; public sealed class RefreshTokenEndpoint(IRequestSender sender, IFingerprintService fingerprintService, IOptions settings) : EndpointWithoutRequest diff --git a/src/Modules/Identity/API/Identity/Post/Register/RegisterEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Register/RegisterEndpoint.cs similarity index 93% rename from src/Modules/Identity/API/Identity/Post/Register/RegisterEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Register/RegisterEndpoint.cs index ae4d3a373..1ee06d897 100644 --- a/src/Modules/Identity/API/Identity/Post/Register/RegisterEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Register/RegisterEndpoint.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Identity.Application.Users.Commands.Internal.VerificationEmail; using CustomCADs.Shared.API.Attributes; -namespace CustomCADs.Modules.Identity.API.Identity.Post.Register; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.Register; public sealed class RegisterEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Identity/API/Identity/Post/Register/RegisterRequest.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Register/RegisterRequest.cs similarity index 68% rename from src/Modules/Identity/API/Identity/Post/Register/RegisterRequest.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Register/RegisterRequest.cs index a8d4864b5..5994dc427 100644 --- a/src/Modules/Identity/API/Identity/Post/Register/RegisterRequest.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Register/RegisterRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Post.Register; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.Register; public sealed record RegisterRequest( string Role, diff --git a/src/Modules/Identity/API/Identity/Post/Register/RegisterValidator.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Register/RegisterValidator.cs similarity index 92% rename from src/Modules/Identity/API/Identity/Post/Register/RegisterValidator.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Register/RegisterValidator.cs index fb313056b..d4acfb118 100644 --- a/src/Modules/Identity/API/Identity/Post/Register/RegisterValidator.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/Register/RegisterValidator.cs @@ -3,7 +3,7 @@ using CustomCADs.Shared.Domain; using FluentValidation; -namespace CustomCADs.Modules.Identity.API.Identity.Post.Register; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.Register; using static ApplicationConstants.FluentMessages; using static DomainConstants.Users; diff --git a/src/Modules/Identity/API/Identity/Post/ResetPassword/ResetPasswordEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ResetPassword/ResetPasswordEndpoint.cs similarity index 90% rename from src/Modules/Identity/API/Identity/Post/ResetPassword/ResetPasswordEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ResetPassword/ResetPasswordEndpoint.cs index f3eb214f6..2dc95d022 100644 --- a/src/Modules/Identity/API/Identity/Post/ResetPassword/ResetPasswordEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ResetPassword/ResetPasswordEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Identity.Application.Users.Commands.Internal.ResetPassword; using CustomCADs.Shared.API.Attributes; -namespace CustomCADs.Modules.Identity.API.Identity.Post.ResetPassword; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.ResetPassword; public sealed class ResetPasswordEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Identity/API/Identity/Post/ResetPassword/ResetPasswordRequest.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ResetPassword/ResetPasswordRequest.cs similarity index 50% rename from src/Modules/Identity/API/Identity/Post/ResetPassword/ResetPasswordRequest.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ResetPassword/ResetPasswordRequest.cs index 87dab05b8..ffc8010dc 100644 --- a/src/Modules/Identity/API/Identity/Post/ResetPassword/ResetPasswordRequest.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/ResetPassword/ResetPasswordRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Post.ResetPassword; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.ResetPassword; public sealed record ResetPasswordRequest(string Email, string Token, string NewPassword); diff --git a/src/Modules/Identity/API/Identity/Post/RetryVerifyEmail/RetryConfirmEmailEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RetryVerifyEmail/RetryConfirmEmailEndpoint.cs similarity index 89% rename from src/Modules/Identity/API/Identity/Post/RetryVerifyEmail/RetryConfirmEmailEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RetryVerifyEmail/RetryConfirmEmailEndpoint.cs index 9f15451c0..97f5f7956 100644 --- a/src/Modules/Identity/API/Identity/Post/RetryVerifyEmail/RetryConfirmEmailEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RetryVerifyEmail/RetryConfirmEmailEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Identity.Application.Users.Commands.Internal.VerificationEmail; using CustomCADs.Shared.API.Attributes; -namespace CustomCADs.Modules.Identity.API.Identity.Post.RetryVerifyEmail; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.RetryVerifyEmail; public sealed class RetryConfirmEmailEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs new file mode 100644 index 000000000..ccec59da2 --- /dev/null +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/RetryVerifyEmail/RetryConfirmEmailRequest.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.RetryVerifyEmail; + +public sealed record RetryConfirmEmailRequest(string Username); diff --git a/src/Modules/Identity/API/Identity/Post/VerifyEmail/ConfirmEmailEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/VerifyEmail/ConfirmEmailEndpoint.cs similarity index 93% rename from src/Modules/Identity/API/Identity/Post/VerifyEmail/ConfirmEmailEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Mutations/Post/VerifyEmail/ConfirmEmailEndpoint.cs index bf66cb17e..24662fb9d 100644 --- a/src/Modules/Identity/API/Identity/Post/VerifyEmail/ConfirmEmailEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/VerifyEmail/ConfirmEmailEndpoint.cs @@ -4,7 +4,7 @@ using CustomCADs.Shared.API.Attributes; using Microsoft.Extensions.Options; -namespace CustomCADs.Modules.Identity.API.Identity.Post.VerifyEmail; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.VerifyEmail; public sealed class ConfirmEmailEndpoint(IRequestSender sender, IFingerprintService fingerprintService, IOptions settings) : Endpoint diff --git a/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/VerifyEmail/ConfirmEmailRequest.cs b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/VerifyEmail/ConfirmEmailRequest.cs new file mode 100644 index 000000000..933da1cea --- /dev/null +++ b/src/Modules/Identity/API/Users/Endpoints/Mutations/Post/VerifyEmail/ConfirmEmailRequest.cs @@ -0,0 +1,6 @@ +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Mutations.Post.VerifyEmail; + +public sealed record ConfirmEmailRequest( + string Username, + string Token +); diff --git a/src/Modules/Identity/API/Identity/Get/Authentication/AuthenticationEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/Authentication/AuthenticationEndpoint.cs similarity index 82% rename from src/Modules/Identity/API/Identity/Get/Authentication/AuthenticationEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Queries/Get/Authentication/AuthenticationEndpoint.cs index 689fa94cc..796e96c24 100644 --- a/src/Modules/Identity/API/Identity/Get/Authentication/AuthenticationEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/Authentication/AuthenticationEndpoint.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Get.Authentication; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Queries.Get.Authentication; public sealed class AuthenticationEndpoint : EndpointWithoutRequest diff --git a/src/Modules/Identity/API/Identity/Get/Authorization/AuthorizationEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/Authorization/AuthorizationEndpoint.cs similarity index 82% rename from src/Modules/Identity/API/Identity/Get/Authorization/AuthorizationEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Queries/Get/Authorization/AuthorizationEndpoint.cs index 517bed875..185b105ca 100644 --- a/src/Modules/Identity/API/Identity/Get/Authorization/AuthorizationEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/Authorization/AuthorizationEndpoint.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Identity.API.Identity.Get.Authorization; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Queries.Get.Authorization; public sealed class AuthorizationEndpoint : EndpointWithoutRequest diff --git a/src/Modules/Identity/API/Identity/Get/DownloadInfo/DownloadInfoEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/DownloadInfo/DownloadInfoEndpoint.cs similarity index 94% rename from src/Modules/Identity/API/Identity/Get/DownloadInfo/DownloadInfoEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Queries/Get/DownloadInfo/DownloadInfoEndpoint.cs index 1582bb8fd..91239873d 100644 --- a/src/Modules/Identity/API/Identity/Get/DownloadInfo/DownloadInfoEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/DownloadInfo/DownloadInfoEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Identity.Application.Users.Queries.Internal.GetByUsername; using System.Text.Json; -namespace CustomCADs.Modules.Identity.API.Identity.Get.DownloadInfo; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Queries.Get.DownloadInfo; public sealed class DownloadInfoEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Identity/API/Identity/Get/MyAccount/MyAccountEndpoint.cs b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/MyAccount/MyAccountEndpoint.cs similarity index 90% rename from src/Modules/Identity/API/Identity/Get/MyAccount/MyAccountEndpoint.cs rename to src/Modules/Identity/API/Users/Endpoints/Queries/Get/MyAccount/MyAccountEndpoint.cs index a55d5ddfb..9f39eadf7 100644 --- a/src/Modules/Identity/API/Identity/Get/MyAccount/MyAccountEndpoint.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/MyAccount/MyAccountEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Identity.Application.Users.Queries.Internal.GetByUsername; -namespace CustomCADs.Modules.Identity.API.Identity.Get.MyAccount; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Queries.Get.MyAccount; public sealed class MyAccountEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Identity/API/Identity/Get/MyAccount/MyAccountMapper.cs b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/MyAccount/MyAccountMapper.cs similarity index 89% rename from src/Modules/Identity/API/Identity/Get/MyAccount/MyAccountMapper.cs rename to src/Modules/Identity/API/Users/Endpoints/Queries/Get/MyAccount/MyAccountMapper.cs index 28a4eac76..9d1b75eae 100644 --- a/src/Modules/Identity/API/Identity/Get/MyAccount/MyAccountMapper.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/MyAccount/MyAccountMapper.cs @@ -1,9 +1,9 @@ -using CustomCADs.Modules.Identity.API.Dtos; +using CustomCADs.Modules.Identity.API.Users.Dtos; using CustomCADs.Modules.Identity.Application.Users.Dtos; using CustomCADs.Modules.Identity.Application.Users.Queries.Internal.GetByUsername; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -namespace CustomCADs.Modules.Identity.API.Identity.Get.MyAccount; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Queries.Get.MyAccount; public class MyAccountMapper : ResponseMapper { diff --git a/src/Modules/Identity/API/Identity/Get/MyAccount/MyAccountResponse.cs b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/MyAccount/MyAccountResponse.cs similarity index 66% rename from src/Modules/Identity/API/Identity/Get/MyAccount/MyAccountResponse.cs rename to src/Modules/Identity/API/Users/Endpoints/Queries/Get/MyAccount/MyAccountResponse.cs index fcc974ab3..a8b223cf5 100644 --- a/src/Modules/Identity/API/Identity/Get/MyAccount/MyAccountResponse.cs +++ b/src/Modules/Identity/API/Users/Endpoints/Queries/Get/MyAccount/MyAccountResponse.cs @@ -1,6 +1,6 @@ -using CustomCADs.Modules.Identity.API.Dtos; +using CustomCADs.Modules.Identity.API.Users.Dtos; -namespace CustomCADs.Modules.Identity.API.Identity.Get.MyAccount; +namespace CustomCADs.Modules.Identity.API.Users.Endpoints.Queries.Get.MyAccount; public record MyAccountResponse( Guid Id, diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Hide/HideNotificationEndpoint.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Hide/HideNotificationEndpoint.cs similarity index 96% rename from src/Modules/Notifications/API/Notifications/Endpoints/Patch/Hide/HideNotificationEndpoint.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Hide/HideNotificationEndpoint.cs index 9294caf2c..abb68c249 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Hide/HideNotificationEndpoint.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Hide/HideNotificationEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Commands.Internal.Hide; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Patch.Hide; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Mutations.Patch.Hide; public class HideNotificationEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Hide/HideNotificationRequest.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Hide/HideNotificationRequest.cs similarity index 79% rename from src/Modules/Notifications/API/Notifications/Endpoints/Patch/Hide/HideNotificationRequest.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Hide/HideNotificationRequest.cs index fe7ecff65..ba74f7623 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Hide/HideNotificationRequest.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Hide/HideNotificationRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Patch.Hide; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Mutations.Patch.Hide; public record HideNotificationRequest(Guid Id); diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Open/OpenNotificationEndpoint.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Open/OpenNotificationEndpoint.cs similarity index 96% rename from src/Modules/Notifications/API/Notifications/Endpoints/Patch/Open/OpenNotificationEndpoint.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Open/OpenNotificationEndpoint.cs index 21441a19a..0128ca9ca 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Open/OpenNotificationEndpoint.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Open/OpenNotificationEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Commands.Internal.Open; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Patch.Open; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Mutations.Patch.Open; public class OpenNotificationEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Open/OpenNotificationRequest.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Open/OpenNotificationRequest.cs similarity index 79% rename from src/Modules/Notifications/API/Notifications/Endpoints/Patch/Open/OpenNotificationRequest.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Open/OpenNotificationRequest.cs index fa51202cf..9e286624b 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Open/OpenNotificationRequest.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Open/OpenNotificationRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Patch.Open; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Mutations.Patch.Open; public record OpenNotificationRequest(Guid Id); diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Read/ReadNotificationEndpoint.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Read/ReadNotificationEndpoint.cs similarity index 96% rename from src/Modules/Notifications/API/Notifications/Endpoints/Patch/Read/ReadNotificationEndpoint.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Read/ReadNotificationEndpoint.cs index 485b29f95..54c3e4b38 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Read/ReadNotificationEndpoint.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Read/ReadNotificationEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Commands.Internal.Read; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Patch.Read; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Mutations.Patch.Read; public class ReadNotificationEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Read/ReadNotificationRequest.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Read/ReadNotificationRequest.cs similarity index 79% rename from src/Modules/Notifications/API/Notifications/Endpoints/Patch/Read/ReadNotificationRequest.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Read/ReadNotificationRequest.cs index 4ca9e8082..b9536a8e7 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Read/ReadNotificationRequest.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Read/ReadNotificationRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Patch.Read; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Mutations.Patch.Read; public record ReadNotificationRequest(Guid Id); diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Unhide/UnhideNotificationEndpoint.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Unhide/UnhideNotificationEndpoint.cs similarity index 96% rename from src/Modules/Notifications/API/Notifications/Endpoints/Patch/Unhide/UnhideNotificationEndpoint.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Unhide/UnhideNotificationEndpoint.cs index 1ee908aa8..68575ed0a 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Unhide/UnhideNotificationEndpoint.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Unhide/UnhideNotificationEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Commands.Internal.Unhide; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Patch.Unhide; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Mutations.Patch.Unhide; public class UnhideNotificationEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Unhide/UnhideNotificationRequest.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Unhide/UnhideNotificationRequest.cs similarity index 78% rename from src/Modules/Notifications/API/Notifications/Endpoints/Patch/Unhide/UnhideNotificationRequest.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Unhide/UnhideNotificationRequest.cs index fa3006b7e..f2253eeee 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Patch/Unhide/UnhideNotificationRequest.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Mutations/Patch/Unhide/UnhideNotificationRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Patch.Unhide; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Mutations.Patch.Unhide; public record UnhideNotificationRequest(Guid Id); diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsEndpoint.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsEndpoint.cs similarity index 97% rename from src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsEndpoint.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsEndpoint.cs index b01fb3008..ca326b168 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsEndpoint.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Queries.Internal.GetAll; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Get.All; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Queries.Get.All; public class GetNotificationsEndpoint(IRequestSender sender) : Endpoint, GetNotificationsMapper> diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsMapper.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsMapper.cs similarity index 96% rename from src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsMapper.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsMapper.cs index 0b787dc8f..83887cfd3 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsMapper.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Queries.Internal.GetAll; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Get.All; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Queries.Get.All; public class GetNotificationsMapper : ResponseMapper { diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsRequest.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsRequest.cs similarity index 94% rename from src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsRequest.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsRequest.cs index f204ce03f..5d417d1f2 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsRequest.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsRequest.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Notifications.Domain.Notifications.Enums; using CustomCADs.Shared.Domain.Enums; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Get.All; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Queries.Get.All; public record GetNotificationsRequest( NotificationStatus? Status = null, diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsResponse.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsResponse.cs similarity index 93% rename from src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsResponse.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsResponse.cs index 60787d5f7..d42f71fea 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Get/All/GetNotificationsResponse.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/All/GetNotificationsResponse.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Notifications.Domain.Notifications.Enums; using CustomCADs.Shared.Application.Dtos.Notifications; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Get.All; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Queries.Get.All; public record GetNotificationsResponse( Guid Id, diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Sortings/GetNotificationSortingsEndpoint.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Sortings/GetNotificationSortingsEndpoint.cs similarity index 96% rename from src/Modules/Notifications/API/Notifications/Endpoints/Get/Sortings/GetNotificationSortingsEndpoint.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Sortings/GetNotificationSortingsEndpoint.cs index 21647694e..37d42aa8f 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Sortings/GetNotificationSortingsEndpoint.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Sortings/GetNotificationSortingsEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Queries.Internal.GetSortings; using CustomCADs.Modules.Notifications.Domain.Notifications.Enums; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Get.Sortings; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Queries.Get.Sortings; public class GetNotificationSortingsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Stats/GetNotificationsStatsEndpoint.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Stats/GetNotificationsStatsEndpoint.cs similarity index 96% rename from src/Modules/Notifications/API/Notifications/Endpoints/Get/Stats/GetNotificationsStatsEndpoint.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Stats/GetNotificationsStatsEndpoint.cs index 2fcaa22bb..26734e913 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Stats/GetNotificationsStatsEndpoint.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Stats/GetNotificationsStatsEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Queries.Internal.Count; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Get.Stats; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Queries.Get.Stats; public sealed class GetNotificationsStatsEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Stats/GetNotificationsStatsMapper.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Stats/GetNotificationsStatsMapper.cs similarity index 94% rename from src/Modules/Notifications/API/Notifications/Endpoints/Get/Stats/GetNotificationsStatsMapper.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Stats/GetNotificationsStatsMapper.cs index 2256cc83c..e02ef6943 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Stats/GetNotificationsStatsMapper.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Stats/GetNotificationsStatsMapper.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Queries.Internal.Count; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Get.Stats; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Queries.Get.Stats; public class GetNotificationsStatsMapper : ResponseMapper { diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Stats/GetNotificationsStatsResponse.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Stats/GetNotificationsStatsResponse.cs similarity index 86% rename from src/Modules/Notifications/API/Notifications/Endpoints/Get/Stats/GetNotificationsStatsResponse.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Stats/GetNotificationsStatsResponse.cs index 54488d2ba..6456c5c98 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Stats/GetNotificationsStatsResponse.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Stats/GetNotificationsStatsResponse.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Get.Stats; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Queries.Get.Stats; public sealed record GetNotificationsStatsResponse( int Unread, diff --git a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Statuses/GetNotificationStatusesEndpoint.cs b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Statuses/GetNotificationStatusesEndpoint.cs similarity index 96% rename from src/Modules/Notifications/API/Notifications/Endpoints/Get/Statuses/GetNotificationStatusesEndpoint.cs rename to src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Statuses/GetNotificationStatusesEndpoint.cs index 728d6eb08..f49d67a66 100644 --- a/src/Modules/Notifications/API/Notifications/Endpoints/Get/Statuses/GetNotificationStatusesEndpoint.cs +++ b/src/Modules/Notifications/API/Notifications/Endpoints/Queries/Get/Statuses/GetNotificationStatusesEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Notifications.Application.Notifications.Queries.Internal.GetStatuses; using CustomCADs.Modules.Notifications.Domain.Notifications.Enums; -namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Get.Statuses; +namespace CustomCADs.Modules.Notifications.API.Notifications.Endpoints.Queries.Get.Statuses; public class GetNotificationStatusesEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Printing/API/Customizations/Endpoints/Post/CreateCustomizationEndpoint.cs b/src/Modules/Printing/API/Customizations/Endpoints/Mutations/Post/CreateCustomizationEndpoint.cs similarity index 97% rename from src/Modules/Printing/API/Customizations/Endpoints/Post/CreateCustomizationEndpoint.cs rename to src/Modules/Printing/API/Customizations/Endpoints/Mutations/Post/CreateCustomizationEndpoint.cs index f220fe93a..89f329608 100644 --- a/src/Modules/Printing/API/Customizations/Endpoints/Post/CreateCustomizationEndpoint.cs +++ b/src/Modules/Printing/API/Customizations/Endpoints/Mutations/Post/CreateCustomizationEndpoint.cs @@ -1,8 +1,8 @@ -using CustomCADs.Modules.Printing.API.Customizations.Endpoints.Get; +using CustomCADs.Modules.Printing.API.Customizations.Endpoints.Queries.Get; using CustomCADs.Modules.Printing.Application.Customizations.Commands.Internal.Create; using CustomCADs.Modules.Printing.Application.Customizations.Queries.Internal.GetById; -namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Post; +namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Mutations.Post; public class CreateCustomizationEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Printing/API/Customizations/Endpoints/Post/CreateCustomizationRequest.cs b/src/Modules/Printing/API/Customizations/Endpoints/Mutations/Post/CreateCustomizationRequest.cs similarity index 89% rename from src/Modules/Printing/API/Customizations/Endpoints/Post/CreateCustomizationRequest.cs rename to src/Modules/Printing/API/Customizations/Endpoints/Mutations/Post/CreateCustomizationRequest.cs index a3a218e76..3de9744e2 100644 --- a/src/Modules/Printing/API/Customizations/Endpoints/Post/CreateCustomizationRequest.cs +++ b/src/Modules/Printing/API/Customizations/Endpoints/Mutations/Post/CreateCustomizationRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Post; +namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Mutations.Post; public record CreateCustomizationRequest( decimal Scale, diff --git a/src/Modules/Printing/API/Customizations/Endpoints/Put/EditCustomizationEndpoint.cs b/src/Modules/Printing/API/Customizations/Endpoints/Mutations/Put/EditCustomizationEndpoint.cs similarity index 98% rename from src/Modules/Printing/API/Customizations/Endpoints/Put/EditCustomizationEndpoint.cs rename to src/Modules/Printing/API/Customizations/Endpoints/Mutations/Put/EditCustomizationEndpoint.cs index 0ab086a2a..761e35eb3 100644 --- a/src/Modules/Printing/API/Customizations/Endpoints/Put/EditCustomizationEndpoint.cs +++ b/src/Modules/Printing/API/Customizations/Endpoints/Mutations/Put/EditCustomizationEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Printing.Application.Customizations.Commands.Internal.Edit; -namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Put; +namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Mutations.Put; public class EditCustomizationEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Printing/API/Customizations/Endpoints/Put/EditCustomizationRequest.cs b/src/Modules/Printing/API/Customizations/Endpoints/Mutations/Put/EditCustomizationRequest.cs similarity index 90% rename from src/Modules/Printing/API/Customizations/Endpoints/Put/EditCustomizationRequest.cs rename to src/Modules/Printing/API/Customizations/Endpoints/Mutations/Put/EditCustomizationRequest.cs index fff6a5656..52e2b38d0 100644 --- a/src/Modules/Printing/API/Customizations/Endpoints/Put/EditCustomizationRequest.cs +++ b/src/Modules/Printing/API/Customizations/Endpoints/Mutations/Put/EditCustomizationRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Put; +namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Mutations.Put; public record EditCustomizationRequest( Guid Id, diff --git a/src/Modules/Printing/API/Customizations/Endpoints/Get/GetCustomizationEndpoint.cs b/src/Modules/Printing/API/Customizations/Endpoints/Queries/Get/GetCustomizationEndpoint.cs similarity index 98% rename from src/Modules/Printing/API/Customizations/Endpoints/Get/GetCustomizationEndpoint.cs rename to src/Modules/Printing/API/Customizations/Endpoints/Queries/Get/GetCustomizationEndpoint.cs index 31e78a5cb..9d5786876 100644 --- a/src/Modules/Printing/API/Customizations/Endpoints/Get/GetCustomizationEndpoint.cs +++ b/src/Modules/Printing/API/Customizations/Endpoints/Queries/Get/GetCustomizationEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Printing.Application.Customizations.Queries.Internal.GetById; -namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Get; +namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Queries.Get; public class GetCustomizationEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Printing/API/Customizations/Endpoints/Get/GetCustomizationRequest.cs b/src/Modules/Printing/API/Customizations/Endpoints/Queries/Get/GetCustomizationRequest.cs similarity index 85% rename from src/Modules/Printing/API/Customizations/Endpoints/Get/GetCustomizationRequest.cs rename to src/Modules/Printing/API/Customizations/Endpoints/Queries/Get/GetCustomizationRequest.cs index 191fafa93..347dda241 100644 --- a/src/Modules/Printing/API/Customizations/Endpoints/Get/GetCustomizationRequest.cs +++ b/src/Modules/Printing/API/Customizations/Endpoints/Queries/Get/GetCustomizationRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Get; +namespace CustomCADs.Modules.Printing.API.Customizations.Endpoints.Queries.Get; public record GetCustomizationRequest(Guid Id); diff --git a/src/Modules/Printing/API/Materials/Endpoints/Delete/DeleteMaterialEndpoint.cs b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Delete/DeleteMaterialEndpoint.cs similarity index 89% rename from src/Modules/Printing/API/Materials/Endpoints/Delete/DeleteMaterialEndpoint.cs rename to src/Modules/Printing/API/Materials/Endpoints/Mutations/Delete/DeleteMaterialEndpoint.cs index 9a20ce1fa..7cf505426 100644 --- a/src/Modules/Printing/API/Materials/Endpoints/Delete/DeleteMaterialEndpoint.cs +++ b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Delete/DeleteMaterialEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Printing.Application.Materials.Commands.Internal.Delete; -namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Delete; +namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Mutations.Delete; public sealed class DeleteMaterialEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Printing/API/Materials/Endpoints/Delete/DeleteMaterialRequest.cs b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Delete/DeleteMaterialRequest.cs similarity index 86% rename from src/Modules/Printing/API/Materials/Endpoints/Delete/DeleteMaterialRequest.cs rename to src/Modules/Printing/API/Materials/Endpoints/Mutations/Delete/DeleteMaterialRequest.cs index 13cb6f5b9..0a7699077 100644 --- a/src/Modules/Printing/API/Materials/Endpoints/Delete/DeleteMaterialRequest.cs +++ b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Delete/DeleteMaterialRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Delete; +namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Mutations.Delete; public sealed record DeleteMaterialRequest(int Id); diff --git a/src/Modules/Printing/API/Materials/Endpoints/Post/PostMaterialEndpoint.cs b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Post/PostMaterialEndpoint.cs similarity index 88% rename from src/Modules/Printing/API/Materials/Endpoints/Post/PostMaterialEndpoint.cs rename to src/Modules/Printing/API/Materials/Endpoints/Mutations/Post/PostMaterialEndpoint.cs index ca80ef0e5..cdaea8aa8 100644 --- a/src/Modules/Printing/API/Materials/Endpoints/Post/PostMaterialEndpoint.cs +++ b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Post/PostMaterialEndpoint.cs @@ -1,10 +1,10 @@ using CustomCADs.Modules.Printing.API.Materials.Dtos; -using CustomCADs.Modules.Printing.API.Materials.Endpoints.Get.Single; +using CustomCADs.Modules.Printing.API.Materials.Endpoints.Queries.Get.Single; using CustomCADs.Modules.Printing.Application.Materials.Commands.Internal.Create; using CustomCADs.Modules.Printing.Application.Materials.Queries.Internal.GetById; using CustomCADs.Shared.Domain.TypedIds.Files; -namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Post; +namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Mutations.Post; public sealed class PostMaterialEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Printing/API/Materials/Endpoints/Post/PostMaterialRequest.cs b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Post/PostMaterialRequest.cs similarity index 91% rename from src/Modules/Printing/API/Materials/Endpoints/Post/PostMaterialRequest.cs rename to src/Modules/Printing/API/Materials/Endpoints/Mutations/Post/PostMaterialRequest.cs index 473c1f259..57ee90946 100644 --- a/src/Modules/Printing/API/Materials/Endpoints/Post/PostMaterialRequest.cs +++ b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Post/PostMaterialRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Post; +namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Mutations.Post; public sealed record PostMaterialRequest( string Name, diff --git a/src/Modules/Printing/API/Materials/Endpoints/Put/PutMaterialEndpoint.cs b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Put/PutMaterialEndpoint.cs similarity index 90% rename from src/Modules/Printing/API/Materials/Endpoints/Put/PutMaterialEndpoint.cs rename to src/Modules/Printing/API/Materials/Endpoints/Mutations/Put/PutMaterialEndpoint.cs index 745195ec1..357a3ace3 100644 --- a/src/Modules/Printing/API/Materials/Endpoints/Put/PutMaterialEndpoint.cs +++ b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Put/PutMaterialEndpoint.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Printing.Application.Materials.Commands.Internal.Edit; -namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Put; +namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Mutations.Put; public sealed class PutMaterialEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Printing/API/Materials/Endpoints/Put/PutMaterialRequest.cs b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Put/PutMaterialRequest.cs similarity index 91% rename from src/Modules/Printing/API/Materials/Endpoints/Put/PutMaterialRequest.cs rename to src/Modules/Printing/API/Materials/Endpoints/Mutations/Put/PutMaterialRequest.cs index 047fc7420..d26658283 100644 --- a/src/Modules/Printing/API/Materials/Endpoints/Put/PutMaterialRequest.cs +++ b/src/Modules/Printing/API/Materials/Endpoints/Mutations/Put/PutMaterialRequest.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Put; +namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Mutations.Put; public sealed record PutMaterialRequest( int Id, diff --git a/src/Modules/Printing/API/Materials/Endpoints/Get/All/GetCategoriesEndpoint.cs b/src/Modules/Printing/API/Materials/Endpoints/Queries/Get/All/GetCategoriesEndpoint.cs similarity index 90% rename from src/Modules/Printing/API/Materials/Endpoints/Get/All/GetCategoriesEndpoint.cs rename to src/Modules/Printing/API/Materials/Endpoints/Queries/Get/All/GetCategoriesEndpoint.cs index 369618e7f..e77161d15 100644 --- a/src/Modules/Printing/API/Materials/Endpoints/Get/All/GetCategoriesEndpoint.cs +++ b/src/Modules/Printing/API/Materials/Endpoints/Queries/Get/All/GetCategoriesEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Printing.API.Materials.Dtos; using CustomCADs.Modules.Printing.Application.Materials.Queries.Internal.GetAll; -namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Get.All; +namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Queries.Get.All; public sealed class GetCategoriesEndpoint(IRequestSender sender) : EndpointWithoutRequest diff --git a/src/Modules/Printing/API/Materials/Endpoints/Get/Single/GetMaterialEndpoint.cs b/src/Modules/Printing/API/Materials/Endpoints/Queries/Get/Single/GetMaterialEndpoint.cs similarity index 90% rename from src/Modules/Printing/API/Materials/Endpoints/Get/Single/GetMaterialEndpoint.cs rename to src/Modules/Printing/API/Materials/Endpoints/Queries/Get/Single/GetMaterialEndpoint.cs index 98b234dc2..d977b2064 100644 --- a/src/Modules/Printing/API/Materials/Endpoints/Get/Single/GetMaterialEndpoint.cs +++ b/src/Modules/Printing/API/Materials/Endpoints/Queries/Get/Single/GetMaterialEndpoint.cs @@ -1,7 +1,7 @@ using CustomCADs.Modules.Printing.API.Materials.Dtos; using CustomCADs.Modules.Printing.Application.Materials.Queries.Internal.GetById; -namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Get.Single; +namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Queries.Get.Single; public sealed class GetMaterialEndpoint(IRequestSender sender) : Endpoint diff --git a/src/Modules/Printing/API/Materials/Endpoints/Get/Single/GetMaterialRequest.cs b/src/Modules/Printing/API/Materials/Endpoints/Queries/Get/Single/GetMaterialRequest.cs similarity index 84% rename from src/Modules/Printing/API/Materials/Endpoints/Get/Single/GetMaterialRequest.cs rename to src/Modules/Printing/API/Materials/Endpoints/Queries/Get/Single/GetMaterialRequest.cs index fb4e14389..15a63ce7a 100644 --- a/src/Modules/Printing/API/Materials/Endpoints/Get/Single/GetMaterialRequest.cs +++ b/src/Modules/Printing/API/Materials/Endpoints/Queries/Get/Single/GetMaterialRequest.cs @@ -1,3 +1,3 @@ -namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Get.Single; +namespace CustomCADs.Modules.Printing.API.Materials.Endpoints.Queries.Get.Single; public sealed record GetMaterialRequest(int Id); From dbb24aeff39ecbf240b58263e9d8e002afb9c8c0 Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Thu, 14 May 2026 04:34:28 +0300 Subject: [PATCH 02/15] Fixed SDK nullable responses --- sdk/js/react/src/api/accounts/common.ts | 4 ++-- sdk/js/react/src/api/carts/common.ts | 4 ++-- sdk/js/react/src/api/carts/purchased/single.ts | 2 +- sdk/js/react/src/api/customs/common.ts | 4 ++-- sdk/js/react/src/api/customs/customs/admin/all.ts | 4 ++-- sdk/js/react/src/api/customs/customs/customer/all.ts | 4 ++-- sdk/js/react/src/api/customs/customs/customer/create.ts | 2 +- sdk/js/react/src/api/customs/customs/customer/recent.ts | 2 +- sdk/js/react/src/api/customs/customs/customer/single.ts | 8 ++++---- sdk/js/react/src/api/customs/customs/designer/all.ts | 2 +- sdk/js/react/src/api/customs/customs/designer/single.ts | 8 ++++---- sdk/js/react/src/api/delivery/shipments/track.ts | 5 ++++- sdk/js/react/src/api/identity/common.ts | 2 +- sdk/js/react/src/api/identity/identity/my-account.ts | 4 ++-- sdk/js/react/src/api/notifications/notifications/all.ts | 2 +- 15 files changed, 30 insertions(+), 27 deletions(-) diff --git a/sdk/js/react/src/api/accounts/common.ts b/sdk/js/react/src/api/accounts/common.ts index f57e887dd..1a14572d5 100644 --- a/sdk/js/react/src/api/accounts/common.ts +++ b/sdk/js/react/src/api/accounts/common.ts @@ -8,8 +8,8 @@ export type AccountResponse = { email: string; role: string; createdAt: string; - firstName?: string; - lastName?: string; + firstName: string | null; + lastName: string | null; }; export const ACCOUNTS_BASE_PATH = '/account'; diff --git a/sdk/js/react/src/api/carts/common.ts b/sdk/js/react/src/api/carts/common.ts index e37b98444..7eaa63bd6 100644 --- a/sdk/js/react/src/api/carts/common.ts +++ b/sdk/js/react/src/api/carts/common.ts @@ -2,7 +2,7 @@ export type ActiveCartItem = { quantity: number; forDelivery: boolean; addedAt: string; - customizationId?: string; + customizationId: string | null; productId: string; }; @@ -15,7 +15,7 @@ export type PurchasedCartItem = { productId: string; cartId: string; cadId: string; - customizationId?: string; + customizationId: string | null; }; export const ACTIVE_CART_BASE_PATH = '/carts/active'; diff --git a/sdk/js/react/src/api/carts/purchased/single.ts b/sdk/js/react/src/api/carts/purchased/single.ts index 5b9cc87eb..a0f5c373a 100644 --- a/sdk/js/react/src/api/carts/purchased/single.ts +++ b/sdk/js/react/src/api/carts/purchased/single.ts @@ -13,7 +13,7 @@ export type Response = { purchasedAt: string; paymentStatus: string; buyerName: string; - shipmentId?: string; + shipmentId: string | null; items: PurchasedCartItem[]; }; diff --git a/sdk/js/react/src/api/customs/common.ts b/sdk/js/react/src/api/customs/common.ts index ea2867b70..7d11b5705 100644 --- a/sdk/js/react/src/api/customs/common.ts +++ b/sdk/js/react/src/api/customs/common.ts @@ -26,8 +26,8 @@ export type FinishedCustomDto = { export type CompletedCustomDto = { paymentStatus: string; - customizationId?: string; - shipmentId?: string; + customizationId: string | null; + shipmentId: string | null; }; export const CUSTOMS_CUSTOMER_BASE_PATH = 'customs/customer'; diff --git a/sdk/js/react/src/api/customs/customs/admin/all.ts b/sdk/js/react/src/api/customs/customs/admin/all.ts index 852c5c586..eb077f06f 100644 --- a/sdk/js/react/src/api/customs/customs/admin/all.ts +++ b/sdk/js/react/src/api/customs/customs/admin/all.ts @@ -21,8 +21,8 @@ export type Response = { status: CustomStatus; forDelivery: boolean; buyerName: string; - designerName?: string; - categoryName?: string; + designerName: string | null; + categoryName: string | null; }; export const url = (req: Request) => diff --git a/sdk/js/react/src/api/customs/customs/customer/all.ts b/sdk/js/react/src/api/customs/customs/customer/all.ts index 348f2d4ba..07586d427 100644 --- a/sdk/js/react/src/api/customs/customs/customer/all.ts +++ b/sdk/js/react/src/api/customs/customs/customer/all.ts @@ -18,8 +18,8 @@ export type Response = { orderedAt: string; status: CustomStatus; forDelivery: boolean; - designerName?: string; - categoryName?: string; + designerName: string | null; + categoryName: string | null; }; export const url = (req: Request) => diff --git a/sdk/js/react/src/api/customs/customs/customer/create.ts b/sdk/js/react/src/api/customs/customs/customer/create.ts index bf2b57372..b1d58a36f 100644 --- a/sdk/js/react/src/api/customs/customs/customer/create.ts +++ b/sdk/js/react/src/api/customs/customs/customer/create.ts @@ -18,7 +18,7 @@ export type Response = { orderedAt: string; forDelivery: boolean; status: string; - category?: CustomCategory; + category: CustomCategory | null; }; export const url = () => `${CUSTOMS_CUSTOMER_BASE_PATH}`; diff --git a/sdk/js/react/src/api/customs/customs/customer/recent.ts b/sdk/js/react/src/api/customs/customs/customer/recent.ts index 78bcc1921..ece2cf3be 100644 --- a/sdk/js/react/src/api/customs/customs/customer/recent.ts +++ b/sdk/js/react/src/api/customs/customs/customer/recent.ts @@ -9,7 +9,7 @@ export type Response = { id: string; name: string; orderedAt: string; - designerName?: string; + designerName: string | null; }; export const url = (req: Request) => diff --git a/sdk/js/react/src/api/customs/customs/customer/single.ts b/sdk/js/react/src/api/customs/customs/customer/single.ts index 61b1e4986..f4769632c 100644 --- a/sdk/js/react/src/api/customs/customs/customer/single.ts +++ b/sdk/js/react/src/api/customs/customs/customer/single.ts @@ -17,10 +17,10 @@ export type Response = { orderedAt: string; status: string; forDelivery: boolean; - category?: CustomCategory; - accepted?: AcceptedCustomDto; - finished?: FinishedCustomDto; - completed?: CompletedCustomDto; + category: CustomCategory | null; + accepted: AcceptedCustomDto | null; + finished: FinishedCustomDto | null; + completed: CompletedCustomDto | null; }; export const url = (req: Request) => `${CUSTOMS_CUSTOMER_BASE_PATH}/${req.id}`; diff --git a/sdk/js/react/src/api/customs/customs/designer/all.ts b/sdk/js/react/src/api/customs/customs/designer/all.ts index 58096356f..ce3e348a8 100644 --- a/sdk/js/react/src/api/customs/customs/designer/all.ts +++ b/sdk/js/react/src/api/customs/customs/designer/all.ts @@ -19,7 +19,7 @@ export type Response = { orderedAt: string; forDelivery: boolean; buyerName: string; - categoryName?: string; + categoryName: string | null; }; export const url = (req: Request) => diff --git a/sdk/js/react/src/api/customs/customs/designer/single.ts b/sdk/js/react/src/api/customs/customs/designer/single.ts index 1bc360f3f..ee0296300 100644 --- a/sdk/js/react/src/api/customs/customs/designer/single.ts +++ b/sdk/js/react/src/api/customs/customs/designer/single.ts @@ -18,10 +18,10 @@ export type Response = { status: string; forDelivery: boolean; buyerName: string; - category?: CustomCategory; - accepted?: AcceptedCustomDto; - finished?: FinishedCustomDto; - completed?: CompletedCustomDto; + category: CustomCategory | null; + accepted: AcceptedCustomDto | null; + finished: FinishedCustomDto | null; + completed: CompletedCustomDto | null; }; export const url = (req: Request) => `${CUSTOMS_DESIGNER_BASE_PATH}/${req.id}`; diff --git a/sdk/js/react/src/api/delivery/shipments/track.ts b/sdk/js/react/src/api/delivery/shipments/track.ts index 9979fe5f2..107deb4e6 100644 --- a/sdk/js/react/src/api/delivery/shipments/track.ts +++ b/sdk/js/react/src/api/delivery/shipments/track.ts @@ -4,6 +4,9 @@ export type Request = { id: string; }; -export type Response = Record; +export type Response = Record< + string, + { message: string; place: string | null } +>; export const url = (req: Request) => `${SHIPMENTS_BASE_PATH}/${req.id}/track`; diff --git a/sdk/js/react/src/api/identity/common.ts b/sdk/js/react/src/api/identity/common.ts index b591746f2..27889efa5 100644 --- a/sdk/js/react/src/api/identity/common.ts +++ b/sdk/js/react/src/api/identity/common.ts @@ -6,7 +6,7 @@ export type ViewedProduct = { export type Fingerprint = { id: string; device: string; - location?: string; + location: string | null; deleteAllowed: boolean; issuedAt: string; }; diff --git a/sdk/js/react/src/api/identity/identity/my-account.ts b/sdk/js/react/src/api/identity/identity/my-account.ts index 3d4129ce3..82885a164 100644 --- a/sdk/js/react/src/api/identity/identity/my-account.ts +++ b/sdk/js/react/src/api/identity/identity/my-account.ts @@ -4,8 +4,8 @@ export type Response = { id: string; role: string; username: string; - firstName?: string; - lastName?: string; + firstName: string | null; + lastName: string | null; email: string; trackViewedProducts: boolean; createdAt: string; diff --git a/sdk/js/react/src/api/notifications/notifications/all.ts b/sdk/js/react/src/api/notifications/notifications/all.ts index 443d91b6d..d84817bbe 100644 --- a/sdk/js/react/src/api/notifications/notifications/all.ts +++ b/sdk/js/react/src/api/notifications/notifications/all.ts @@ -16,7 +16,7 @@ export type Response = { createdAt: string; author: string; description: string; - link?: string; + link: string | null; }; export const url = (req: Request) => From 2a40ee94ad0f25051646fcb9c94aab061caf6ff8 Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Sat, 16 May 2026 03:02:42 +0300 Subject: [PATCH 03/15] Renamed `GetByIds` shared queries to `BatchGetById` pattern --- ...dler.cs => BatchGetUsernamesByIdHandler.cs} | 6 +++--- .../Normal/PurchaseActiveCartHandler.cs | 2 +- .../PurchaseActiveCartWithDeliveryHandler.cs | 6 +++--- .../CalculateActiveCartShipmentHandler.cs | 2 +- .../Create/CreatePurchasedCartHandler.cs | 4 ++-- ...ndler.cs => BatchGetCategoryByIdHandler.cs} | 6 +++--- .../GetAll/CreatorGetAllProductsHandler.cs | 2 +- .../GetAll/DesignerGetAllProductsHandler.cs | 4 ++-- .../GetAll/GalleryGetAllProductsHandler.cs | 4 ++-- ...r.cs => BatchGetProductCadIdByIdHandler.cs} | 6 +++--- ...r.cs => BatchGetProductPriceByIdHandler.cs} | 6 +++--- .../Shared/GetAll/GetAllCustomsHandler.cs | 6 +++--- .../BatchDuplicateCadByIdHandler.cs} | 8 ++++---- .../Internal/GetAll/GetAllCadsHandler.cs | 2 +- .../GetAll/GetAllNotificationsHandler.cs | 2 +- ...=> BatchGetCustomizationCostByIdHandler.cs} | 6 +++--- ... BatchGetCustomizationWeightByIdHandler.cs} | 6 +++--- ...sQuery.cs => BatchGetUsernamesByIdQuery.cs} | 2 +- ...mand.cs => BatchDuplicateCadByIdCommand.cs} | 2 +- ...IdsQuery.cs => BatchGetCategorByIdQuery.cs} | 2 +- ...s => BatchGetCustomizationCostByIdQuery.cs} | 2 +- ...=> BatchGetCustomizationWeightByIdQuery.cs} | 2 +- ...ery.cs => BatchGetProductCadIdByIdQuery.cs} | 2 +- ...ery.cs => BatchGetProductPriceByIdQuery.cs} | 2 +- ...> BatchGetUsernamesByIdHandlerUnitTests.cs} | 10 +++++----- .../PurchaseActiveCartHandlerUnitTests.cs | 4 ++-- ...seActiveCartWithDeliveryHandlerUnitTests.cs | 12 ++++++------ ...culateActiveCartShipmentHandlerUnitTests.cs | 4 ++-- .../CreatePurchasedCartHandlerUnitTests.cs | 8 ++++---- .../BatchGetCategoryByIdHandlerUnitTests.cs} | 12 ++++++------ .../CreatorGetAllProductsHandlerUnitTests.cs | 4 ++-- .../DesignerGetAllProductsHandlerUnitTests.cs | 8 ++++---- .../GalleryGetAllProductsHandlerUnitTests.cs | 8 ++++---- ...atchGetProductCadIdByIdHandlerUnitTests.cs} | 12 ++++++------ ...atchGetProductPriceByIdHandlerUnitTests.cs} | 12 ++++++------ .../GetAll/GetAllPurchasedCartsUnitTests.cs | 12 ++++++------ .../BatchDuplicateCadByIdHandlerUnitTests.cs} | 18 +++++++++--------- .../GetAllNotificationHandlerUnitTests.cs | 4 ++-- ...etCustomizationCostByIdHandlerUnitTests.cs} | 12 ++++++------ ...CustomizationWeightByIdHandlerUnitTests.cs} | 12 ++++++------ 40 files changed, 122 insertions(+), 122 deletions(-) rename src/Modules/Accounts/Application/Accounts/Queries/Shared/Username/{GetUsernamesByIdsHandler.cs => BatchGetUsernamesByIdHandler.cs} (66%) rename src/Modules/Catalog/Application/Categories/Queries/Shared/{GetCategoryNamesByIdsHandler.cs => BatchGetCategoryByIdHandler.cs} (70%) rename src/Modules/Catalog/Application/Products/Queries/Shared/{GetProductCadIdsByIdsHandler.cs => BatchGetProductCadIdByIdHandler.cs} (67%) rename src/Modules/Catalog/Application/Products/Queries/Shared/{GetProductPricesByIdsHandler.cs => BatchGetProductPriceByIdHandler.cs} (64%) rename src/Modules/Files/Application/Cads/Commands/Shared/{DuplicateByIds/DuplicateCadsByIdsHandler.cs => BatchDuplicateById/BatchDuplicateCadByIdHandler.cs} (82%) rename src/Modules/Printing/Application/Customizations/Queries/Shared/Cost/{GetCustomizationsCostByIdsHandler.cs => BatchGetCustomizationCostByIdHandler.cs} (82%) rename src/Modules/Printing/Application/Customizations/Queries/Shared/Weight/{GetCustomizationsWeightByIdsHandler.cs => BatchGetCustomizationWeightByIdHandler.cs} (78%) rename src/Shared/Application/UseCases/Accounts/Queries/{GetUsernamesByIdsQuery.cs => BatchGetUsernamesByIdQuery.cs} (72%) rename src/Shared/Application/UseCases/Cads/Commands/{DuplicateCadsByIdsCommand.cs => BatchDuplicateCadByIdCommand.cs} (73%) rename src/Shared/Application/UseCases/Categories/Queries/{GetCategoryNamesByIdsQuery.cs => BatchGetCategorByIdQuery.cs} (73%) rename src/Shared/Application/UseCases/Customizations/Queries/{GetCustomizationsCostByIdsQuery.cs => BatchGetCustomizationCostByIdQuery.cs} (72%) rename src/Shared/Application/UseCases/Customizations/Queries/{GetCustomizationsWeightByIdsQuery.cs => BatchGetCustomizationWeightByIdQuery.cs} (71%) rename src/Shared/Application/UseCases/Products/Queries/{GetProductCadIdsByIdsQuery.cs => BatchGetProductCadIdByIdQuery.cs} (82%) rename src/Shared/Application/UseCases/Products/Queries/{GetProductPricesByIdsQuery.cs => BatchGetProductPriceByIdQuery.cs} (71%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/{GetUsernamesByIdsHandlerUnitTests.cs => BatchGetUsernamesByIdHandlerUnitTests.cs} (87%) rename tests/UnitTests/Catalog/Application/Categories/Queries/Shared/{GetByIds/GetCategoryNamesByIdsHandlerUnitTests.cs => BatchGetById/BatchGetCategoryByIdHandlerUnitTests.cs} (81%) rename tests/UnitTests/Catalog/Application/Products/Queries/Shared/{CadIdsByIds/AddProductCadIdsByIdsHandlerUnitTests.cs => BatchCadIdById/BatchGetProductCadIdByIdHandlerUnitTests.cs} (82%) rename tests/UnitTests/Catalog/Application/Products/Queries/Shared/{PricesByIds/AddProductCadIdsByIdsHandlerUnitTests.cs => BatchPricesById/BatchGetProductPriceByIdHandlerUnitTests.cs} (82%) rename tests/UnitTests/Files/Application/Cads/Commands/Shared/{DuplicateByIds/DuplicateCadsByIdsHandlerUnitTests.cs => BatchDuplicateById/BatchDuplicateCadByIdHandlerUnitTests.cs} (80%) rename tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/{GetCustomizationsCostByIdsHandlerUnitTests.cs => BatchGetCustomizationCostByIdHandlerUnitTests.cs} (86%) rename tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/{GetCustomizationsWeightByIdsHandlerUnitTests.cs => BatchGetCustomizationWeightByIdHandlerUnitTests.cs} (85%) diff --git a/src/Modules/Accounts/Application/Accounts/Queries/Shared/Username/GetUsernamesByIdsHandler.cs b/src/Modules/Accounts/Application/Accounts/Queries/Shared/Username/BatchGetUsernamesByIdHandler.cs similarity index 66% rename from src/Modules/Accounts/Application/Accounts/Queries/Shared/Username/GetUsernamesByIdsHandler.cs rename to src/Modules/Accounts/Application/Accounts/Queries/Shared/Username/BatchGetUsernamesByIdHandler.cs index c393f13bc..f5c19527b 100644 --- a/src/Modules/Accounts/Application/Accounts/Queries/Shared/Username/GetUsernamesByIdsHandler.cs +++ b/src/Modules/Accounts/Application/Accounts/Queries/Shared/Username/BatchGetUsernamesByIdHandler.cs @@ -4,10 +4,10 @@ namespace CustomCADs.Modules.Accounts.Application.Accounts.Queries.Shared.Username; -public sealed class GetUsernamesByIdsHandler(IAccountReads reads) - : IQueryHandler> +public sealed class BatchGetUsernamesByIdHandler(IAccountReads reads) + : IQueryHandler> { - public async Task> Handle(GetUsernamesByIdsQuery req, CancellationToken ct) + public async Task> Handle(BatchGetUsernamesByIdQuery req, CancellationToken ct) { AccountQuery query = new( Ids: req.Ids, diff --git a/src/Modules/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandler.cs b/src/Modules/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandler.cs index 6bfccf480..1f7082d2b 100644 --- a/src/Modules/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandler.cs +++ b/src/Modules/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandler.cs @@ -34,7 +34,7 @@ public async Task Handle(PurchaseActiveCartCommand req, Cancellation } Dictionary prices = await sender.SendQueryAsync( - query: new GetProductPricesByIdsQuery( + query: new BatchGetProductPriceByIdQuery( Ids: [.. items.Select(x => x.ProductId)] ), ct: ct diff --git a/src/Modules/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandler.cs b/src/Modules/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandler.cs index 977c0ea9b..249b293b5 100644 --- a/src/Modules/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandler.cs +++ b/src/Modules/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandler.cs @@ -105,7 +105,7 @@ await raiser.RaiseApplicationEventAsync( private async Task> SnapshotWeightsAsync(ActiveCartItem[] items, CustomizationId[] customizationIds, CancellationToken ct) { Dictionary weights = await sender.SendQueryAsync( - query: new GetCustomizationsWeightByIdsQuery( + query: new BatchGetCustomizationWeightByIdQuery( Ids: customizationIds ), ct: ct @@ -126,7 +126,7 @@ private async Task> SnapshotWeightsAsync(Act private async Task> SnapshotCostsAsync(ActiveCartItem[] items, CustomizationId[] customizationIds, CancellationToken ct) { Dictionary costs = await sender.SendQueryAsync( - query: new GetCustomizationsCostByIdsQuery( + query: new BatchGetCustomizationCostByIdQuery( Ids: customizationIds ), ct: ct @@ -145,7 +145,7 @@ private async Task> SnapshotCostsAsync(Acti private async Task> SnapshotPricesAsync(ActiveCartItem[] items, CancellationToken ct) { Dictionary prices = await sender.SendQueryAsync( - query: new GetProductPricesByIdsQuery( + query: new BatchGetProductPriceByIdQuery( Ids: [.. items.Select(x => x.ProductId)] ), ct: ct diff --git a/src/Modules/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandler.cs b/src/Modules/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandler.cs index 2accfe613..da9faf5a5 100644 --- a/src/Modules/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandler.cs +++ b/src/Modules/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandler.cs @@ -20,7 +20,7 @@ public async Task Handle(CalculateActiveCartShipmentQuer } Dictionary weights = await sender.SendQueryAsync( - query: new GetCustomizationsWeightByIdsQuery( + query: new BatchGetCustomizationWeightByIdQuery( Ids: [.. items .Where(x => x.ForDelivery && x.CustomizationId is not null) .Select(x => x.CustomizationId!.Value) diff --git a/src/Modules/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandler.cs b/src/Modules/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandler.cs index 1db4d4461..046642ac4 100644 --- a/src/Modules/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandler.cs +++ b/src/Modules/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandler.cs @@ -47,12 +47,12 @@ private async Task SnapshotItemsAsync(Dictionary x.Key.ProductId)]; Dictionary productCads = await sender.SendQueryAsync( - query: new GetProductCadIdsByIdsQuery(productIds), + query: new BatchGetProductCadIdByIdQuery(productIds), ct: ct ).ConfigureAwait(false); Dictionary itemCads = await sender.SendCommandAsync( - command: new DuplicateCadsByIdsCommand( + command: new BatchDuplicateCadByIdCommand( Ids: [.. productCads.Select(x => x.Value)], CallerId: buyerId ), diff --git a/src/Modules/Catalog/Application/Categories/Queries/Shared/GetCategoryNamesByIdsHandler.cs b/src/Modules/Catalog/Application/Categories/Queries/Shared/BatchGetCategoryByIdHandler.cs similarity index 70% rename from src/Modules/Catalog/Application/Categories/Queries/Shared/GetCategoryNamesByIdsHandler.cs rename to src/Modules/Catalog/Application/Categories/Queries/Shared/BatchGetCategoryByIdHandler.cs index 0fc0acdf0..b6e43c68c 100644 --- a/src/Modules/Catalog/Application/Categories/Queries/Shared/GetCategoryNamesByIdsHandler.cs +++ b/src/Modules/Catalog/Application/Categories/Queries/Shared/BatchGetCategoryByIdHandler.cs @@ -3,12 +3,12 @@ namespace CustomCADs.Modules.Catalog.Application.Categories.Queries.Shared; -public sealed class GetCategoryNamesByIdsHandler( +public sealed class BatchGetCategoryByIdHandler( ICategoryReads reads, BaseCachingService cache -) : IQueryHandler> +) : IQueryHandler> { - public async Task> Handle(GetCategoryNamesByIdsQuery req, CancellationToken ct) + public async Task> Handle(BatchGetCategorByIdQuery req, CancellationToken ct) { IEnumerable categories = await cache.GetOrCreateAsync( factory: async () => [.. await reads.AllAsync(track: false, ct: ct).ConfigureAwait(false)] diff --git a/src/Modules/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandler.cs b/src/Modules/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandler.cs index a43f602c5..c559009c7 100644 --- a/src/Modules/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandler.cs +++ b/src/Modules/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandler.cs @@ -26,7 +26,7 @@ public async Task> Handle(CreatorGetAllProducts CategoryId[] categoryIds = [.. result.Items.Select(x => x.CategoryId).Distinct()]; Dictionary categories = await sender.SendQueryAsync( - query: new GetCategoryNamesByIdsQuery(categoryIds), + query: new BatchGetCategorByIdQuery(categoryIds), ct: ct ).ConfigureAwait(false); diff --git a/src/Modules/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandler.cs b/src/Modules/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandler.cs index 2c18081eb..061c64658 100644 --- a/src/Modules/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandler.cs +++ b/src/Modules/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandler.cs @@ -30,13 +30,13 @@ public async Task> Handle(DesignerGetAllProduc AccountId[] userIds = [.. result.Items.Select(x => x.CreatorId).Distinct()]; Dictionary users = await sender.SendQueryAsync( - query: new GetUsernamesByIdsQuery(userIds), + query: new BatchGetUsernamesByIdQuery(userIds), ct: ct ).ConfigureAwait(false); CategoryId[] categoryIds = [.. result.Items.Select(x => x.CategoryId).Distinct()]; Dictionary categories = await sender.SendQueryAsync( - query: new GetCategoryNamesByIdsQuery(categoryIds), + query: new BatchGetCategorByIdQuery(categoryIds), ct: ct ).ConfigureAwait(false); diff --git a/src/Modules/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandler.cs b/src/Modules/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandler.cs index 53ec2563b..7c2741720 100644 --- a/src/Modules/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandler.cs +++ b/src/Modules/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandler.cs @@ -31,13 +31,13 @@ public async Task> Handle(GalleryGetAllProducts AccountId[] userIds = [.. result.Items.Select(x => x.CreatorId).Distinct()]; Dictionary users = await sender.SendQueryAsync( - new GetUsernamesByIdsQuery(userIds), + new BatchGetUsernamesByIdQuery(userIds), ct: ct ).ConfigureAwait(false); CategoryId[] categoryIds = [.. result.Items.Select(x => x.CategoryId).Distinct()]; Dictionary categories = await sender.SendQueryAsync( - query: new GetCategoryNamesByIdsQuery(categoryIds), + query: new BatchGetCategorByIdQuery(categoryIds), ct: ct ).ConfigureAwait(false); diff --git a/src/Modules/Catalog/Application/Products/Queries/Shared/GetProductCadIdsByIdsHandler.cs b/src/Modules/Catalog/Application/Products/Queries/Shared/BatchGetProductCadIdByIdHandler.cs similarity index 67% rename from src/Modules/Catalog/Application/Products/Queries/Shared/GetProductCadIdsByIdsHandler.cs rename to src/Modules/Catalog/Application/Products/Queries/Shared/BatchGetProductCadIdByIdHandler.cs index c1856ed6c..fcafe64a4 100644 --- a/src/Modules/Catalog/Application/Products/Queries/Shared/GetProductCadIdsByIdsHandler.cs +++ b/src/Modules/Catalog/Application/Products/Queries/Shared/BatchGetProductCadIdByIdHandler.cs @@ -5,10 +5,10 @@ namespace CustomCADs.Modules.Catalog.Application.Products.Queries.Shared; -public class GetProductCadIdsByIdsHandler(IProductReads reads) - : IQueryHandler> +public class BatchGetProductCadIdByIdHandler(IProductReads reads) + : IQueryHandler> { - public async Task> Handle(GetProductCadIdsByIdsQuery req, CancellationToken ct) + public async Task> Handle(BatchGetProductCadIdByIdQuery req, CancellationToken ct) { Result result = await reads.AllAsync( query: new( diff --git a/src/Modules/Catalog/Application/Products/Queries/Shared/GetProductPricesByIdsHandler.cs b/src/Modules/Catalog/Application/Products/Queries/Shared/BatchGetProductPriceByIdHandler.cs similarity index 64% rename from src/Modules/Catalog/Application/Products/Queries/Shared/GetProductPricesByIdsHandler.cs rename to src/Modules/Catalog/Application/Products/Queries/Shared/BatchGetProductPriceByIdHandler.cs index 950b05764..262f5e6a9 100644 --- a/src/Modules/Catalog/Application/Products/Queries/Shared/GetProductPricesByIdsHandler.cs +++ b/src/Modules/Catalog/Application/Products/Queries/Shared/BatchGetProductPriceByIdHandler.cs @@ -4,10 +4,10 @@ namespace CustomCADs.Modules.Catalog.Application.Products.Queries.Shared; -public sealed class GetProductPricesByIdsHandler(IProductReads reads) - : IQueryHandler> +public sealed class BatchGetProductPriceByIdHandler(IProductReads reads) + : IQueryHandler> { - public async Task> Handle(GetProductPricesByIdsQuery req, CancellationToken ct) + public async Task> Handle(BatchGetProductPriceByIdQuery req, CancellationToken ct) { Result result = await reads.AllAsync( query: new( diff --git a/src/Modules/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllCustomsHandler.cs b/src/Modules/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllCustomsHandler.cs index b684863c2..c43bf54ab 100644 --- a/src/Modules/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllCustomsHandler.cs +++ b/src/Modules/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllCustomsHandler.cs @@ -31,7 +31,7 @@ public async Task> Handle(GetAllCustomsQuery req, Cance AccountId[] buyerIds = [.. result.Items.Select(x => x.BuyerId)]; Dictionary buyers = await sender.SendQueryAsync( - query: new GetUsernamesByIdsQuery(buyerIds), + query: new BatchGetUsernamesByIdQuery(buyerIds), ct: ct ).ConfigureAwait(false); @@ -40,7 +40,7 @@ public async Task> Handle(GetAllCustomsQuery req, Cance .Select(x => x.AcceptedCustom!.DesignerId) ]; Dictionary designers = await sender.SendQueryAsync( - query: new GetUsernamesByIdsQuery(designerIds), + query: new BatchGetUsernamesByIdQuery(designerIds), ct: ct ).ConfigureAwait(false); @@ -49,7 +49,7 @@ public async Task> Handle(GetAllCustomsQuery req, Cance .Select(x => x.Category!.Id) ]; Dictionary categories = await sender.SendQueryAsync( - query: new GetCategoryNamesByIdsQuery(categoryIds), + query: new BatchGetCategorByIdQuery(categoryIds), ct: ct ).ConfigureAwait(false); diff --git a/src/Modules/Files/Application/Cads/Commands/Shared/DuplicateByIds/DuplicateCadsByIdsHandler.cs b/src/Modules/Files/Application/Cads/Commands/Shared/BatchDuplicateById/BatchDuplicateCadByIdHandler.cs similarity index 82% rename from src/Modules/Files/Application/Cads/Commands/Shared/DuplicateByIds/DuplicateCadsByIdsHandler.cs rename to src/Modules/Files/Application/Cads/Commands/Shared/BatchDuplicateById/BatchDuplicateCadByIdHandler.cs index 630bc8567..1edabc859 100644 --- a/src/Modules/Files/Application/Cads/Commands/Shared/DuplicateByIds/DuplicateCadsByIdsHandler.cs +++ b/src/Modules/Files/Application/Cads/Commands/Shared/BatchDuplicateById/BatchDuplicateCadByIdHandler.cs @@ -4,16 +4,16 @@ using CustomCADs.Shared.Application.UseCases.Cads.Commands; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.Modules.Files.Application.Cads.Commands.Shared.DuplicateByIds; +namespace CustomCADs.Modules.Files.Application.Cads.Commands.Shared.BatchDuplicateById; -public sealed class DuplicateCadsByIdsHandler( +public sealed class BatchDuplicateCadByIdHandler( ICadReads reads, IWrites writes, IUnitOfWork uow, BaseCachingService cache -) : ICommandHandler> +) : ICommandHandler> { - public async Task> Handle(DuplicateCadsByIdsCommand req, CancellationToken ct) + public async Task> Handle(BatchDuplicateCadByIdCommand req, CancellationToken ct) { Result result = await reads.AllAsync( query: new( diff --git a/src/Modules/Files/Application/Cads/Queries/Internal/GetAll/GetAllCadsHandler.cs b/src/Modules/Files/Application/Cads/Queries/Internal/GetAll/GetAllCadsHandler.cs index eb0a18d0d..5f4c02e57 100644 --- a/src/Modules/Files/Application/Cads/Queries/Internal/GetAll/GetAllCadsHandler.cs +++ b/src/Modules/Files/Application/Cads/Queries/Internal/GetAll/GetAllCadsHandler.cs @@ -28,7 +28,7 @@ public async Task> Handle(GetAllCadsQuery req, CancellationToken ).ConfigureAwait(false); Dictionary ownersNames = await sender.SendQueryAsync( - query: new GetUsernamesByIdsQuery([.. result.Items.Select(x => x.OwnerId)]), + query: new BatchGetUsernamesByIdQuery([.. result.Items.Select(x => x.OwnerId)]), ct: ct ).ConfigureAwait(false); diff --git a/src/Modules/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationsHandler.cs b/src/Modules/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationsHandler.cs index c49a53a0b..831879db3 100644 --- a/src/Modules/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationsHandler.cs +++ b/src/Modules/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationsHandler.cs @@ -24,7 +24,7 @@ public async Task> Handle(GetAllNotificationsQuer ).ConfigureAwait(false); Dictionary usernames = await sender.SendQueryAsync( - query: new GetUsernamesByIdsQuery([.. result.Items.Select(x => x.AuthorId)]), + query: new BatchGetUsernamesByIdQuery([.. result.Items.Select(x => x.AuthorId)]), ct: ct ).ConfigureAwait(false); diff --git a/src/Modules/Printing/Application/Customizations/Queries/Shared/Cost/GetCustomizationsCostByIdsHandler.cs b/src/Modules/Printing/Application/Customizations/Queries/Shared/Cost/BatchGetCustomizationCostByIdHandler.cs similarity index 82% rename from src/Modules/Printing/Application/Customizations/Queries/Shared/Cost/GetCustomizationsCostByIdsHandler.cs rename to src/Modules/Printing/Application/Customizations/Queries/Shared/Cost/BatchGetCustomizationCostByIdHandler.cs index 9e113a7b6..6d4d1f636 100644 --- a/src/Modules/Printing/Application/Customizations/Queries/Shared/Cost/GetCustomizationsCostByIdsHandler.cs +++ b/src/Modules/Printing/Application/Customizations/Queries/Shared/Cost/BatchGetCustomizationCostByIdHandler.cs @@ -4,13 +4,13 @@ namespace CustomCADs.Modules.Printing.Application.Customizations.Queries.Shared.Cost; -public sealed class GetCustomizationsCostByIdsHandler( +public sealed class BatchGetCustomizationCostByIdHandler( ICustomizationReads customizationReads, IMaterialReads materialReads, IPrintCalculator calculator -) : IQueryHandler> +) : IQueryHandler> { - public async Task> Handle(GetCustomizationsCostByIdsQuery req, CancellationToken ct) + public async Task> Handle(BatchGetCustomizationCostByIdQuery req, CancellationToken ct) { ICollection customizations = await customizationReads.AllAsync(req.Ids, track: false, ct).ConfigureAwait(false); MaterialId[] materialIds = [.. customizations.Select(x => x.MaterialId).Distinct()]; diff --git a/src/Modules/Printing/Application/Customizations/Queries/Shared/Weight/GetCustomizationsWeightByIdsHandler.cs b/src/Modules/Printing/Application/Customizations/Queries/Shared/Weight/BatchGetCustomizationWeightByIdHandler.cs similarity index 78% rename from src/Modules/Printing/Application/Customizations/Queries/Shared/Weight/GetCustomizationsWeightByIdsHandler.cs rename to src/Modules/Printing/Application/Customizations/Queries/Shared/Weight/BatchGetCustomizationWeightByIdHandler.cs index fe0c32058..08a8f1d4c 100644 --- a/src/Modules/Printing/Application/Customizations/Queries/Shared/Weight/GetCustomizationsWeightByIdsHandler.cs +++ b/src/Modules/Printing/Application/Customizations/Queries/Shared/Weight/BatchGetCustomizationWeightByIdHandler.cs @@ -4,13 +4,13 @@ namespace CustomCADs.Modules.Printing.Application.Customizations.Queries.Shared.Weight; -public sealed class GetCustomizationsWeightByIdsHandler( +public sealed class BatchGetCustomizationWeightByIdHandler( ICustomizationReads customizationReads, IMaterialReads materialReads, IPrintCalculator calculator -) : IQueryHandler> +) : IQueryHandler> { - public async Task> Handle(GetCustomizationsWeightByIdsQuery req, CancellationToken ct) + public async Task> Handle(BatchGetCustomizationWeightByIdQuery req, CancellationToken ct) { ICollection customizations = await customizationReads.AllAsync(req.Ids, track: false, ct).ConfigureAwait(false); MaterialId[] materialIds = [.. customizations.Select(x => x.MaterialId).Distinct()]; diff --git a/src/Shared/Application/UseCases/Accounts/Queries/GetUsernamesByIdsQuery.cs b/src/Shared/Application/UseCases/Accounts/Queries/BatchGetUsernamesByIdQuery.cs similarity index 72% rename from src/Shared/Application/UseCases/Accounts/Queries/GetUsernamesByIdsQuery.cs rename to src/Shared/Application/UseCases/Accounts/Queries/BatchGetUsernamesByIdQuery.cs index 862536776..ab40bbc16 100644 --- a/src/Shared/Application/UseCases/Accounts/Queries/GetUsernamesByIdsQuery.cs +++ b/src/Shared/Application/UseCases/Accounts/Queries/BatchGetUsernamesByIdQuery.cs @@ -1,5 +1,5 @@ namespace CustomCADs.Shared.Application.UseCases.Accounts.Queries; -public sealed record GetUsernamesByIdsQuery( +public sealed record BatchGetUsernamesByIdQuery( AccountId[] Ids ) : IQuery>; diff --git a/src/Shared/Application/UseCases/Cads/Commands/DuplicateCadsByIdsCommand.cs b/src/Shared/Application/UseCases/Cads/Commands/BatchDuplicateCadByIdCommand.cs similarity index 73% rename from src/Shared/Application/UseCases/Cads/Commands/DuplicateCadsByIdsCommand.cs rename to src/Shared/Application/UseCases/Cads/Commands/BatchDuplicateCadByIdCommand.cs index 97c16c744..a3514ff41 100644 --- a/src/Shared/Application/UseCases/Cads/Commands/DuplicateCadsByIdsCommand.cs +++ b/src/Shared/Application/UseCases/Cads/Commands/BatchDuplicateCadByIdCommand.cs @@ -1,6 +1,6 @@ namespace CustomCADs.Shared.Application.UseCases.Cads.Commands; -public sealed record DuplicateCadsByIdsCommand( +public sealed record BatchDuplicateCadByIdCommand( CadId[] Ids, AccountId CallerId ) : ICommand>; diff --git a/src/Shared/Application/UseCases/Categories/Queries/GetCategoryNamesByIdsQuery.cs b/src/Shared/Application/UseCases/Categories/Queries/BatchGetCategorByIdQuery.cs similarity index 73% rename from src/Shared/Application/UseCases/Categories/Queries/GetCategoryNamesByIdsQuery.cs rename to src/Shared/Application/UseCases/Categories/Queries/BatchGetCategorByIdQuery.cs index 7566325cf..ef1299d1c 100644 --- a/src/Shared/Application/UseCases/Categories/Queries/GetCategoryNamesByIdsQuery.cs +++ b/src/Shared/Application/UseCases/Categories/Queries/BatchGetCategorByIdQuery.cs @@ -1,5 +1,5 @@ namespace CustomCADs.Shared.Application.UseCases.Categories.Queries; -public sealed record GetCategoryNamesByIdsQuery( +public sealed record BatchGetCategorByIdQuery( CategoryId[] Ids ) : IQuery>; diff --git a/src/Shared/Application/UseCases/Customizations/Queries/GetCustomizationsCostByIdsQuery.cs b/src/Shared/Application/UseCases/Customizations/Queries/BatchGetCustomizationCostByIdQuery.cs similarity index 72% rename from src/Shared/Application/UseCases/Customizations/Queries/GetCustomizationsCostByIdsQuery.cs rename to src/Shared/Application/UseCases/Customizations/Queries/BatchGetCustomizationCostByIdQuery.cs index edadcbf99..43bf92d45 100644 --- a/src/Shared/Application/UseCases/Customizations/Queries/GetCustomizationsCostByIdsQuery.cs +++ b/src/Shared/Application/UseCases/Customizations/Queries/BatchGetCustomizationCostByIdQuery.cs @@ -1,5 +1,5 @@ namespace CustomCADs.Shared.Application.UseCases.Customizations.Queries; -public sealed record GetCustomizationsCostByIdsQuery( +public sealed record BatchGetCustomizationCostByIdQuery( CustomizationId[] Ids ) : IQuery>; diff --git a/src/Shared/Application/UseCases/Customizations/Queries/GetCustomizationsWeightByIdsQuery.cs b/src/Shared/Application/UseCases/Customizations/Queries/BatchGetCustomizationWeightByIdQuery.cs similarity index 71% rename from src/Shared/Application/UseCases/Customizations/Queries/GetCustomizationsWeightByIdsQuery.cs rename to src/Shared/Application/UseCases/Customizations/Queries/BatchGetCustomizationWeightByIdQuery.cs index 0dc3e2c4d..6af344058 100644 --- a/src/Shared/Application/UseCases/Customizations/Queries/GetCustomizationsWeightByIdsQuery.cs +++ b/src/Shared/Application/UseCases/Customizations/Queries/BatchGetCustomizationWeightByIdQuery.cs @@ -1,5 +1,5 @@ namespace CustomCADs.Shared.Application.UseCases.Customizations.Queries; -public sealed record GetCustomizationsWeightByIdsQuery( +public sealed record BatchGetCustomizationWeightByIdQuery( CustomizationId[] Ids ) : IQuery>; diff --git a/src/Shared/Application/UseCases/Products/Queries/GetProductCadIdsByIdsQuery.cs b/src/Shared/Application/UseCases/Products/Queries/BatchGetProductCadIdByIdQuery.cs similarity index 82% rename from src/Shared/Application/UseCases/Products/Queries/GetProductCadIdsByIdsQuery.cs rename to src/Shared/Application/UseCases/Products/Queries/BatchGetProductCadIdByIdQuery.cs index e3e77f7d7..afab01ea2 100644 --- a/src/Shared/Application/UseCases/Products/Queries/GetProductCadIdsByIdsQuery.cs +++ b/src/Shared/Application/UseCases/Products/Queries/BatchGetProductCadIdByIdQuery.cs @@ -3,6 +3,6 @@ namespace CustomCADs.Shared.Application.UseCases.Products.Queries; [AddRequestCaching(ExpirationType.Absolute)] -public sealed record GetProductCadIdsByIdsQuery( +public sealed record BatchGetProductCadIdByIdQuery( ProductId[] Ids ) : IQuery>; diff --git a/src/Shared/Application/UseCases/Products/Queries/GetProductPricesByIdsQuery.cs b/src/Shared/Application/UseCases/Products/Queries/BatchGetProductPriceByIdQuery.cs similarity index 71% rename from src/Shared/Application/UseCases/Products/Queries/GetProductPricesByIdsQuery.cs rename to src/Shared/Application/UseCases/Products/Queries/BatchGetProductPriceByIdQuery.cs index 9a21db872..91227115b 100644 --- a/src/Shared/Application/UseCases/Products/Queries/GetProductPricesByIdsQuery.cs +++ b/src/Shared/Application/UseCases/Products/Queries/BatchGetProductPriceByIdQuery.cs @@ -1,5 +1,5 @@ namespace CustomCADs.Shared.Application.UseCases.Products.Queries; -public sealed record GetProductPricesByIdsQuery( +public sealed record BatchGetProductPriceByIdQuery( ProductId[] Ids ) : IQuery>; diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/GetUsernamesByIdsHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/BatchGetUsernamesByIdHandlerUnitTests.cs similarity index 87% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/GetUsernamesByIdsHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/BatchGetUsernamesByIdHandlerUnitTests.cs index f94f9cb7e..4c33ea6c5 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/GetUsernamesByIdsHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/BatchGetUsernamesByIdHandlerUnitTests.cs @@ -9,16 +9,16 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetU using static AccountsData; using static DomainConstants.Users; -public class GetUsernamesByIdsHandlerUnitTests : AccountsBaseUnitTests +public class BatchGetUsernamesByIdHandlerUnitTests : AccountsBaseUnitTests { - private readonly GetUsernamesByIdsHandler handler; + private readonly BatchGetUsernamesByIdHandler handler; private readonly Mock reads = new(); private static readonly AccountId[] ids = [ValidId, ValidId, ValidId, ValidId]; private static readonly string[] usernames = [CustomerUsername, ContributorUsername, DesignerUsername, HeadDesignerUsername, AdminUsername]; private static readonly AccountQuery accountQuery = new(Pagination: new(1, ids.Length), Ids: ids); - public GetUsernamesByIdsHandlerUnitTests() + public BatchGetUsernamesByIdHandlerUnitTests() { handler = new(reads.Object); @@ -38,7 +38,7 @@ public GetUsernamesByIdsHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetUsernamesByIdsQuery query = new(ids); + BatchGetUsernamesByIdQuery query = new(ids); // Act await handler.Handle(query, ct); @@ -51,7 +51,7 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetUsernamesByIdsQuery query = new(ids); + BatchGetUsernamesByIdQuery query = new(ids); // Act Dictionary result = await handler.Handle(query, ct); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandlerUnitTests.cs index 15cce088c..d0dbfa1e6 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandlerUnitTests.cs @@ -44,7 +44,7 @@ public PurchaseActiveCartHandlerUnitTests() .ReturnsAsync(items); sender.Setup(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct )).ReturnsAsync(items.ToDictionary(x => x.ProductId, x => 0m)); } @@ -74,7 +74,7 @@ public async Task Handle_ShouldSendRequests() // Assert sender.Verify(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandlerUnitTests.cs index 99448f973..37ffc702e 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandlerUnitTests.cs @@ -51,12 +51,12 @@ public PurchaseActiveCartWithDeliveryWithDeliveryHandlerUnitTests() .ReturnsAsync(items); sender.Setup(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct )).ReturnsAsync(items.ToDictionary(x => x.ProductId, x => 0m)); sender.Setup(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct )).ReturnsAsync( items @@ -65,7 +65,7 @@ public PurchaseActiveCartWithDeliveryWithDeliveryHandlerUnitTests() ); sender.Setup(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct )).ReturnsAsync( items @@ -111,11 +111,11 @@ public async Task Handle_ShouldSendRequests() // Assert sender.Verify(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( @@ -127,7 +127,7 @@ public async Task Handle_ShouldSendRequests() ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct ), Times.Once()); } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandlerUnitTests.cs index 3ae190b5c..c48db7978 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandlerUnitTests.cs @@ -31,7 +31,7 @@ public CalculateActiveCartShipmentHandlerUnitTests() ]); sender.Setup(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct )).ReturnsAsync([]); @@ -65,7 +65,7 @@ public async Task Handle_ShouldSendRequests() // Assert sender.Verify(x => x.SendQueryAsync( - It.IsAny(), + It.IsAny(), ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs index e35d7f3fd..7adfd3eb9 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs @@ -46,12 +46,12 @@ public CreatePurchasedCartHandlerUnitTests() )).ReturnsAsync(true); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == productIds), + It.Is(x => x.Ids == productIds), ct )).ReturnsAsync(cads); sender.Setup(x => x.SendCommandAsync( - It.Is(x => x.Ids == cadIds), + It.Is(x => x.Ids == cadIds), ct )).ReturnsAsync([]); } @@ -94,11 +94,11 @@ public async Task Handle_ShouldSendRequests() ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == productIds), + It.Is(x => x.Ids == productIds), ct ), Times.Once()); sender.Verify(x => x.SendCommandAsync( - It.Is(x => x.Ids == cadIds), + It.Is(x => x.Ids == cadIds), ct ), Times.Once()); } diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetByIds/GetCategoryNamesByIdsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/BatchGetCategoryByIdHandlerUnitTests.cs similarity index 81% rename from tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetByIds/GetCategoryNamesByIdsHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/BatchGetCategoryByIdHandlerUnitTests.cs index 629bc0c62..cd5fc110d 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetByIds/GetCategoryNamesByIdsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/BatchGetCategoryByIdHandlerUnitTests.cs @@ -2,13 +2,13 @@ using CustomCADs.Modules.Catalog.Domain.Repositories.Reads; using CustomCADs.Shared.Application.UseCases.Categories.Queries; -namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Shared.GetByIds; +namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Shared.BatchGetById; using static CategoriesData; -public class GetCategoryNamesByIdsHandlerUnitTests : CategoriesBaseUnitTests +public class BatchGetCategoryByIdHandlerUnitTests : CategoriesBaseUnitTests { - private readonly GetCategoryNamesByIdsHandler handler; + private readonly BatchGetCategoryByIdHandler handler; private readonly Mock reads = new(); private readonly Mock> cache = new(); @@ -19,7 +19,7 @@ public class GetCategoryNamesByIdsHandlerUnitTests : CategoriesBaseUnitTests ]; private static readonly Category[] categories = [.. ids.Select(id => CreateCategory(id, ValidName, ValidDescription))]; - public GetCategoryNamesByIdsHandlerUnitTests() + public BatchGetCategoryByIdHandlerUnitTests() { handler = new(reads.Object, cache.Object); cache.Setup(x => x.GetOrCreateAsync(It.IsAny>>>())).ReturnsAsync(categories); @@ -29,7 +29,7 @@ public GetCategoryNamesByIdsHandlerUnitTests() public async Task Handle_ShouldReadCache() { // Arrange - GetCategoryNamesByIdsQuery query = new(ids); + BatchGetCategorByIdQuery query = new(ids); // Act await handler.Handle(query, ct); @@ -42,7 +42,7 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - GetCategoryNamesByIdsQuery query = new(ids); + BatchGetCategorByIdQuery query = new(ids); // Act var actualCategories = (await handler.Handle(query, ct)).Select(x => (x.Key, x.Value)); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandlerUnitTests.cs index d603e1604..240057e04 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandlerUnitTests.cs @@ -37,7 +37,7 @@ public CreatorGetAllProductsHandlerUnitTests() )).ReturnsAsync(result); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == products.Select(x => x.CategoryId)), ct )).ReturnsAsync(products.ToDictionary(x => x.CategoryId, x => "Cateogry123")); } @@ -82,7 +82,7 @@ public async Task Handle_ShouldSendRequests() // Assert sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == products.Select(x => x.CategoryId)), ct ), Times.Once()); } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandlerUnitTests.cs index d1b7f1bd3..7182dff6e 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandlerUnitTests.cs @@ -40,12 +40,12 @@ public DesignerGetAllProductsHandlerUnitTests() )).ReturnsAsync(result); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + It.Is(x => x.Ids == products.Select(x => x.CreatorId)), ct )).ReturnsAsync(products.ToDictionary(x => x.CreatorId, x => "Username123")); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == products.Select(x => x.CategoryId)), ct )).ReturnsAsync(products.ToDictionary(x => x.CategoryId, x => "Cateogry123")); } @@ -92,11 +92,11 @@ public async Task Handle_ShouldSendRequests() // Assert sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + It.Is(x => x.Ids == products.Select(x => x.CreatorId)), ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == products.Select(x => x.CategoryId)), ct ), Times.Once()); } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandlerUnitTests.cs index feb2de7cb..7a954a929 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandlerUnitTests.cs @@ -38,12 +38,12 @@ public GalleryGetAllProductsHandlerUnitTests() )).ReturnsAsync(result); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + It.Is(x => x.Ids == products.Select(x => x.CreatorId)), ct )).ReturnsAsync(products.ToDictionary(x => x.CreatorId, x => "Username123")); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == products.Select(x => x.CategoryId)), ct )).ReturnsAsync(products.ToDictionary(x => x.CategoryId, x => "Cateogry123")); } @@ -88,11 +88,11 @@ public async Task Handle_ShouldSendRequests() // Assert sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + It.Is(x => x.Ids == products.Select(x => x.CreatorId)), ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == products.Select(x => x.CategoryId)), ct ), Times.Once()); } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/CadIdsByIds/AddProductCadIdsByIdsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/BatchGetProductCadIdByIdHandlerUnitTests.cs similarity index 82% rename from tests/UnitTests/Catalog/Application/Products/Queries/Shared/CadIdsByIds/AddProductCadIdsByIdsHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/BatchGetProductCadIdByIdHandlerUnitTests.cs index c73bfb69e..cf15fb949 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/CadIdsByIds/AddProductCadIdsByIdsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/BatchGetProductCadIdByIdHandlerUnitTests.cs @@ -3,13 +3,13 @@ using CustomCADs.Shared.Application.UseCases.Products.Queries; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.CadIdsByIds; +namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.BatchCadIdById; using static ProductsData; -public class GetProductCadIdsByIdsHandlerUnitTests : ProductsBaseUnitTests +public class BatchGetProductCadIdByIdHandlerUnitTests : ProductsBaseUnitTests { - private readonly GetProductCadIdsByIdsHandler handler; + private readonly BatchGetProductCadIdByIdHandler handler; private readonly Mock reads = new(); private readonly ProductId[] ids = [ValidId, ValidId, ValidId]; @@ -20,7 +20,7 @@ public class GetProductCadIdsByIdsHandlerUnitTests : ProductsBaseUnitTests CreateProductWithId(MaxValidName, MaxValidDescription, MaxValidPrice, id: ProductId.New()), ]; - public GetProductCadIdsByIdsHandlerUnitTests() + public BatchGetProductCadIdByIdHandlerUnitTests() { handler = new(reads.Object); @@ -40,7 +40,7 @@ public GetProductCadIdsByIdsHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetProductCadIdsByIdsQuery query = new(ids); + BatchGetProductCadIdByIdQuery query = new(ids); // Act await handler.Handle(query, ct); @@ -53,7 +53,7 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetProductCadIdsByIdsQuery query = new(ids); + BatchGetProductCadIdByIdQuery query = new(ids); // Act var result = await handler.Handle(query, ct); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/PricesByIds/AddProductCadIdsByIdsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPricesById/BatchGetProductPriceByIdHandlerUnitTests.cs similarity index 82% rename from tests/UnitTests/Catalog/Application/Products/Queries/Shared/PricesByIds/AddProductCadIdsByIdsHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPricesById/BatchGetProductPriceByIdHandlerUnitTests.cs index 46f844f3f..a10875aeb 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/PricesByIds/AddProductCadIdsByIdsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPricesById/BatchGetProductPriceByIdHandlerUnitTests.cs @@ -3,13 +3,13 @@ using CustomCADs.Shared.Application.UseCases.Products.Queries; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.PricesByIds; +namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.BatchPricesById; using static ProductsData; -public class GetProductPricesByIdsHandlerUnitTests : ProductsBaseUnitTests +public class BatchGetProductPriceByIdHandlerUnitTests : ProductsBaseUnitTests { - private readonly GetProductPricesByIdsHandler handler; + private readonly BatchGetProductPriceByIdHandler handler; private readonly Mock reads = new(); private readonly ProductId[] ids = [ValidId, ValidId, ValidId]; @@ -20,7 +20,7 @@ public class GetProductPricesByIdsHandlerUnitTests : ProductsBaseUnitTests CreateProductWithId(MaxValidName, MaxValidDescription, MaxValidPrice, id: ProductId.New()), ]; - public GetProductPricesByIdsHandlerUnitTests() + public BatchGetProductPriceByIdHandlerUnitTests() { handler = new(reads.Object); @@ -40,7 +40,7 @@ public GetProductPricesByIdsHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetProductPricesByIdsQuery query = new(ids); + BatchGetProductPriceByIdQuery query = new(ids); // Act await handler.Handle(query, ct); @@ -53,7 +53,7 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetProductPricesByIdsQuery query = new(ids); + BatchGetProductPriceByIdQuery query = new(ids); // Act var result = await handler.Handle(query, ct); diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllPurchasedCartsUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllPurchasedCartsUnitTests.cs index 92d83cc02..9b489bf17 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllPurchasedCartsUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllPurchasedCartsUnitTests.cs @@ -53,17 +53,17 @@ public GetAllCustomsUnitTests() )); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids.Contains(ValidBuyerId)), + It.Is(x => x.Ids.Contains(ValidBuyerId)), ct )).ReturnsAsync(customers); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids.Contains(ValidDesignerId)), + It.Is(x => x.Ids.Contains(ValidDesignerId)), ct )).ReturnsAsync(designers); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids.Contains(ValidCategoryId)), + It.Is(x => x.Ids.Contains(ValidCategoryId)), ct )).ReturnsAsync(categories); } @@ -92,15 +92,15 @@ public async Task Handle_ShouldSendRequests() // Assert sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids.Contains(ValidBuyerId)), + It.Is(x => x.Ids.Contains(ValidBuyerId)), ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids.Contains(ValidDesignerId)), + It.Is(x => x.Ids.Contains(ValidDesignerId)), ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids.Contains(ValidCategoryId)), + It.Is(x => x.Ids.Contains(ValidCategoryId)), ct ), Times.Once()); } diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Shared/DuplicateByIds/DuplicateCadsByIdsHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/BatchDuplicateCadByIdHandlerUnitTests.cs similarity index 80% rename from tests/UnitTests/Files/Application/Cads/Commands/Shared/DuplicateByIds/DuplicateCadsByIdsHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/BatchDuplicateCadByIdHandlerUnitTests.cs index 36ee5bdd4..f1bfd0ec4 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Shared/DuplicateByIds/DuplicateCadsByIdsHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/BatchDuplicateCadByIdHandlerUnitTests.cs @@ -1,16 +1,16 @@ -using CustomCADs.Modules.Files.Application.Cads.Commands.Shared.DuplicateByIds; +using CustomCADs.Modules.Files.Application.Cads.Commands.Shared.BatchDuplicateById; using CustomCADs.Modules.Files.Domain.Repositories; using CustomCADs.Modules.Files.Domain.Repositories.Reads; using CustomCADs.Shared.Application.UseCases.Cads.Commands; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Shared.DuplicateByIds; +namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Shared.BatchDuplicateById; using static CadsData; -public class DuplicateCadsByIdsHandlerUnitTests : CadsBaseUnitTests +public class BatchDuplicateCadByIdHandlerUnitTests : CadsBaseUnitTests { - private readonly DuplicateCadsByIdsHandler handler; + private readonly BatchDuplicateCadByIdHandler handler; private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); @@ -23,7 +23,7 @@ public class DuplicateCadsByIdsHandlerUnitTests : CadsBaseUnitTests private readonly CadQuery query; private readonly Result result; - public DuplicateCadsByIdsHandlerUnitTests() + public BatchDuplicateCadByIdHandlerUnitTests() { handler = new(reads.Object, writes.Object, uow.Object, cache.Object); @@ -38,7 +38,7 @@ public DuplicateCadsByIdsHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DuplicateCadsByIdsCommand command = new(Ids, ValidOwnerId); + BatchDuplicateCadByIdCommand command = new(Ids, ValidOwnerId); // Act await handler.Handle(command, ct); @@ -51,7 +51,7 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DuplicateCadsByIdsCommand command = new(Ids, ValidOwnerId); + BatchDuplicateCadByIdCommand command = new(Ids, ValidOwnerId); // Act await handler.Handle(command, ct); @@ -65,7 +65,7 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - DuplicateCadsByIdsCommand command = new(Ids, ValidOwnerId); + BatchDuplicateCadByIdCommand command = new(Ids, ValidOwnerId); // Act await handler.Handle(command, ct); @@ -84,7 +84,7 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldReturnResult() { // Arrange - DuplicateCadsByIdsCommand command = new(Ids, ValidOwnerId); + BatchDuplicateCadByIdCommand command = new(Ids, ValidOwnerId); // Act var result = await handler.Handle(command, ct); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationHandlerUnitTests.cs index 3aa76cb0d..a5aa05dd2 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationHandlerUnitTests.cs @@ -40,7 +40,7 @@ public GetAllNotificationHandlerUnitTests() ct )).ReturnsAsync(result); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids.Length == notifications.Length), + It.Is(x => x.Ids.Length == notifications.Length), ct )).ReturnsAsync(notifications.ToDictionary(x => x.AuthorId, x => "Username123")); } @@ -81,7 +81,7 @@ public async Task Handle_ShouldSendRequests() // Assert sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids.Length == notifications.Length), + It.Is(x => x.Ids.Length == notifications.Length), ct ), Times.Once()); } diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/GetCustomizationsCostByIdsHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/BatchGetCustomizationCostByIdHandlerUnitTests.cs similarity index 86% rename from tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/GetCustomizationsCostByIdsHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/BatchGetCustomizationCostByIdHandlerUnitTests.cs index 8ce67242b..ced6d6c98 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/GetCustomizationsCostByIdsHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/BatchGetCustomizationCostByIdHandlerUnitTests.cs @@ -9,9 +9,9 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Share using static CustomizationsData; -public class GetCustomizationsCostByIdsHandlerUnitTests : CustomizationsBaseUnitTests +public class BatchGetCustomizationCostByIdHandlerUnitTests : CustomizationsBaseUnitTests { - private readonly GetCustomizationsCostByIdsHandler handler; + private readonly BatchGetCustomizationCostByIdHandler handler; private readonly Mock reads = new(); private readonly Mock materialReads = new(); private readonly Mock calculator = new(); @@ -25,7 +25,7 @@ public class GetCustomizationsCostByIdsHandlerUnitTests : CustomizationsBaseUnit [ValidMaterialId] = CreateMaterial(), }; - public GetCustomizationsCostByIdsHandlerUnitTests() + public BatchGetCustomizationCostByIdHandlerUnitTests() { handler = new(reads.Object, materialReads.Object, calculator.Object); @@ -43,7 +43,7 @@ public GetCustomizationsCostByIdsHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetCustomizationsCostByIdsQuery query = new(ids); + BatchGetCustomizationCostByIdQuery query = new(ids); // Act await handler.Handle(query, ct); @@ -57,7 +57,7 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldCalculateCost() { // Arrange - GetCustomizationsCostByIdsQuery query = new(ids); + BatchGetCustomizationCostByIdQuery query = new(ids); // Act await handler.Handle(query, ct); @@ -73,7 +73,7 @@ public async Task Handle_ShouldCalculateCost() public async Task Handle_ShouldReturnResult() { // Arrange - GetCustomizationsCostByIdsQuery query = new(ids); + BatchGetCustomizationCostByIdQuery query = new(ids); // Act var result = await handler.Handle(query, ct); diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/GetCustomizationsWeightByIdsHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/BatchGetCustomizationWeightByIdHandlerUnitTests.cs similarity index 85% rename from tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/GetCustomizationsWeightByIdsHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/BatchGetCustomizationWeightByIdHandlerUnitTests.cs index 8c111835f..11a287188 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/GetCustomizationsWeightByIdsHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/BatchGetCustomizationWeightByIdHandlerUnitTests.cs @@ -9,9 +9,9 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Share using static CustomizationsData; -public class GetCustomizationsWeightByIdsHandlerUnitTests : CustomizationsBaseUnitTests +public class BatchGetCustomizationWeightByIdHandlerUnitTests : CustomizationsBaseUnitTests { - private readonly GetCustomizationsWeightByIdsHandler handler; + private readonly BatchGetCustomizationWeightByIdHandler handler; private readonly Mock reads = new(); private readonly Mock materialReads = new(); private readonly Mock calculator = new(); @@ -25,7 +25,7 @@ public class GetCustomizationsWeightByIdsHandlerUnitTests : CustomizationsBaseUn [ValidMaterialId] = CreateMaterial(), }; - public GetCustomizationsWeightByIdsHandlerUnitTests() + public BatchGetCustomizationWeightByIdHandlerUnitTests() { handler = new(reads.Object, materialReads.Object, calculator.Object); @@ -43,7 +43,7 @@ public GetCustomizationsWeightByIdsHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetCustomizationsWeightByIdsQuery query = new(ids); + BatchGetCustomizationWeightByIdQuery query = new(ids); // Act await handler.Handle(query, ct); @@ -57,7 +57,7 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldCalculateWeight() { // Arrange - GetCustomizationsWeightByIdsQuery query = new(ids); + BatchGetCustomizationWeightByIdQuery query = new(ids); // Act await handler.Handle(query, ct); @@ -73,7 +73,7 @@ public async Task Handle_ShouldCalculateWeight() public async Task Handle_ShouldReturnResult() { // Arrange - GetCustomizationsWeightByIdsQuery query = new(ids); + BatchGetCustomizationWeightByIdQuery query = new(ids); // Act var result = await handler.Handle(query, ct); From 678d86e6e98bed6dcefd89e931186da41d2576a9 Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Sat, 16 May 2026 03:34:35 +0300 Subject: [PATCH 04/15] Normalized Application Event conventions --- .../Events/Application/UserDeletedHandler.cs | 6 +-- .../Events/Application/UserEditedHandler.cs | 26 ++++++------- .../Application/UserViewedProductHandler.cs | 4 +- .../ProductDeleted/ProductDeletedHandler.cs | 6 +-- .../Create/CreatePurchasedCartHandler.cs | 2 +- ...eliveryRequestedApplicationEventHandler.cs | 16 ++++---- ...PaymentCompletedApplicationEventHandler.cs | 10 ++--- .../Creator/Delete/DeleteProductHandler.cs | 2 +- .../ProductCreated/ProductCreatedHandler.cs | 6 +-- .../ProductsPurchasedHandler.cs | 12 ++++++ .../UserPurchasedProductHandler.cs | 12 ------ .../ProductViewedApplicationEvent.cs | 10 ----- .../ProductViewed/ProductViewedHandler.cs | 18 ++++----- .../GetById/GalleryGetProductByIdHandler.cs | 4 +- .../Domain/Repositories/IUnitOfWork.cs | 2 +- .../Persistence/Repositories/UnitOfWork.cs | 2 +- ...eliveryRequestedApplicationEventHandler.cs | 16 ++++---- ...PaymentCompletedApplicationEventHandler.cs | 8 ++-- .../Application/ProductDeletedHandler.cs | 10 ++--- .../Application/ProductDeletedHandler.cs | 10 ++--- .../EmailVerificationRequestedEventHandler.cs | 4 +- .../PasswordResetRequestedEventHandler.cs | 4 +- .../Application/Roles/RoleCreatedHandler.cs | 4 +- .../Application/Roles/RoleDeletedHandler.cs | 4 +- .../Users/AccountCreatedHandler.cs | 19 ++++++++++ .../Users/AccountDeletedHandler.cs | 11 ++++++ .../Application/Users/UserCreatedHandler.cs | 19 ---------- .../Application/Users/UserDeletedHandler.cs | 11 ------ .../Events/NotificationRequestedHandler.cs | 22 +++++------ .../ProductDeletedApplicationEvent.cs | 2 +- ...nt.cs => ProductViewedApplicationEvent.cs} | 4 +- ...s => ProductsPurchasedApplicationEvent.cs} | 2 +- .../UserDeletedHandlerUnitTests.cs | 12 +++--- .../Application/UserEditedHandlerUnitTests.cs | 12 +++--- .../UserViewedProductHandlerUnitTests.cs | 4 +- ...DeletedApplicationEventHandlerUnitTests.cs | 2 +- .../CreatePurchasedCartHandlerUnitTests.cs | 2 +- ...questedApplicationEventHandlerUnitTests.cs | 12 +++--- ...mpletedApplicationEventHandlerUnitTests.cs | 24 ++++++------ .../Delete/DeleteProductHandlerUnitTests.cs | 2 +- .../ProductCreatedHandlerUnitTests.cs | 4 +- .../ProductViewedHandlerUnitTests.cs | 38 +++++++++---------- ...s => ProductsPurchasedHandlerUnitTests.cs} | 12 +++--- .../GalleryGetProductByIdHandlerUnitTests.cs | 2 +- ...questedApplicationEventHandlerUnitTests.cs | 20 +++++----- ...mpletedApplicationEventHandlerUnitTests.cs | 24 ++++++------ .../ProductDeletedHandlerUnitTests.cs | 22 +++++------ .../ProductDeletedHandlerUnitTests.cs | 2 +- ...ilVerificationRequestedHandlerUnitTests.cs | 4 +- .../PasswordResetRequestedHandlerUnitTests.cs | 4 +- ...copy.cs => RoleCreatedHandlerUnitTests.cs} | 4 +- .../Roles/RoleDeletedHandlerUnitTests.cs | 4 +- ...s.cs => AccountCreatedHandlerUnitTests.cs} | 20 +++++----- ...s.cs => AccountDeletedHandlerUnitTests.cs} | 10 ++--- .../NotificationRequestedHandlerUnitTests.cs | 26 ++++++------- 55 files changed, 272 insertions(+), 282 deletions(-) create mode 100644 src/Modules/Catalog/Application/Products/Events/Application/ProductPurchased/ProductsPurchasedHandler.cs delete mode 100644 src/Modules/Catalog/Application/Products/Events/Application/ProductPurchased/UserPurchasedProductHandler.cs delete mode 100644 src/Modules/Catalog/Application/Products/Events/Application/ProductViewed/ProductViewedApplicationEvent.cs create mode 100644 src/Modules/Identity/Application/Users/Events/Application/Users/AccountCreatedHandler.cs create mode 100644 src/Modules/Identity/Application/Users/Events/Application/Users/AccountDeletedHandler.cs delete mode 100644 src/Modules/Identity/Application/Users/Events/Application/Users/UserCreatedHandler.cs delete mode 100644 src/Modules/Identity/Application/Users/Events/Application/Users/UserDeletedHandler.cs rename src/Shared/Application/Events/{Files => Catalog}/ProductDeletedApplicationEvent.cs (67%) rename src/Shared/Application/Events/Catalog/{UserViewedProductApplicationEvent.cs => ProductViewedApplicationEvent.cs} (75%) rename src/Shared/Application/Events/Catalog/{UserPurchasedProductApplicationEvent.cs => ProductsPurchasedApplicationEvent.cs} (62%) rename tests/UnitTests/Catalog/Application/Products/Events/Application/{UserPurchasedProductHandlerUnitTests.cs => ProductsPurchasedHandlerUnitTests.cs} (60%) rename tests/UnitTests/Identity/Application/Users/Events/Application/Roles/{RoleDeletedHandlerUnitTests copy.cs => RoleCreatedHandlerUnitTests.cs} (90%) rename tests/UnitTests/Identity/Application/Users/Events/Application/Users/{UserCreatedHandlerUnitTests.cs => AccountCreatedHandlerUnitTests.cs} (66%) rename tests/UnitTests/Identity/Application/Users/Events/Application/Users/{UserDeletedHandlerUnitTests.cs => AccountDeletedHandlerUnitTests.cs} (69%) diff --git a/src/Modules/Accounts/Application/Accounts/Events/Application/UserDeletedHandler.cs b/src/Modules/Accounts/Application/Accounts/Events/Application/UserDeletedHandler.cs index 6ae3fa03d..21e09f5e2 100644 --- a/src/Modules/Accounts/Application/Accounts/Events/Application/UserDeletedHandler.cs +++ b/src/Modules/Accounts/Application/Accounts/Events/Application/UserDeletedHandler.cs @@ -7,10 +7,10 @@ namespace CustomCADs.Modules.Accounts.Application.Accounts.Events.Application; public class UserDeletedHandler(IAccountReads reads, IAccountWrites writes, IUnitOfWork uow) { - public async Task HandleAsync(UserDeletedApplicationEvent ae) + public async Task HandleAsync(UserDeletedApplicationEvent @event) { - Account account = await reads.SingleByIdAsync(ae.Id).ConfigureAwait(false) - ?? throw CustomNotFoundException.ById(ae.Id); + Account account = await reads.SingleByIdAsync(@event.Id).ConfigureAwait(false) + ?? throw CustomNotFoundException.ById(@event.Id); writes.Remove(account); await uow.SaveChangesAsync().ConfigureAwait(false); diff --git a/src/Modules/Accounts/Application/Accounts/Events/Application/UserEditedHandler.cs b/src/Modules/Accounts/Application/Accounts/Events/Application/UserEditedHandler.cs index 5486874dc..4bc2e6d73 100644 --- a/src/Modules/Accounts/Application/Accounts/Events/Application/UserEditedHandler.cs +++ b/src/Modules/Accounts/Application/Accounts/Events/Application/UserEditedHandler.cs @@ -6,33 +6,33 @@ namespace CustomCADs.Modules.Accounts.Application.Accounts.Events.Application; public class UserEditedHandler(IAccountReads reads, IUnitOfWork uow) { - public async Task HandleAsync(UserEditedApplicationEvent ae) + public async Task HandleAsync(UserEditedApplicationEvent @event) { - Account account = await reads.SingleByIdAsync(ae.Id).ConfigureAwait(false) - ?? throw CustomNotFoundException.ById(ae.Id); + Account account = await reads.SingleByIdAsync(@event.Id).ConfigureAwait(false) + ?? throw CustomNotFoundException.ById(@event.Id); - if (ae.Username is not null) + if (@event.Username is not null) { - if (ae.Username != account.Username) + if (@event.Username != account.Username) { - account.SetUsername(ae.Username); + account.SetUsername(@event.Username); } } - if (ae.TrackViewedProducts is not null) + if (@event.TrackViewedProducts is not null) { - account.SetTrackViewedProducts(ae.TrackViewedProducts.Value); + account.SetTrackViewedProducts(@event.TrackViewedProducts.Value); } - if (ae.Names is not null) + if (@event.Names is not null) { - if (ae.Names.FirstName != account.FirstName) + if (@event.Names.FirstName != account.FirstName) { - account.SetFirstName(ae.Names.FirstName); + account.SetFirstName(@event.Names.FirstName); } - if (ae.Names.LastName != account.LastName) + if (@event.Names.LastName != account.LastName) { - account.SetLastName(ae.Names.LastName); + account.SetLastName(@event.Names.LastName); } } diff --git a/src/Modules/Accounts/Application/Accounts/Events/Application/UserViewedProductHandler.cs b/src/Modules/Accounts/Application/Accounts/Events/Application/UserViewedProductHandler.cs index f67e576cb..e5965e141 100644 --- a/src/Modules/Accounts/Application/Accounts/Events/Application/UserViewedProductHandler.cs +++ b/src/Modules/Accounts/Application/Accounts/Events/Application/UserViewedProductHandler.cs @@ -6,9 +6,9 @@ namespace CustomCADs.Modules.Accounts.Application.Accounts.Events.Application; public class UserViewedProductHandler(IAccountWrites writes, IUnitOfWork uow) { - public async Task HandleAsync(UserViewedProductApplicationEvent ae) + public async Task HandleAsync(ProductViewedApplicationEvent @event) { - await writes.ViewProductAsync(ae.AccountId, ae.Id, ae.ViewedAt).ConfigureAwait(false); + await writes.ViewProductAsync(@event.AccountId, @event.Id, @event.ViewedAt).ConfigureAwait(false); await uow.SaveChangesAsync().ConfigureAwait(false); } } diff --git a/src/Modules/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedHandler.cs b/src/Modules/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedHandler.cs index 6b5f86ee6..a83ee115a 100644 --- a/src/Modules/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedHandler.cs +++ b/src/Modules/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedHandler.cs @@ -1,12 +1,12 @@ using CustomCADs.Modules.Carts.Domain.Repositories; -using CustomCADs.Shared.Application.Events.Files; +using CustomCADs.Shared.Application.Events.Catalog; namespace CustomCADs.Modules.Carts.Application.ActiveCarts.Events.Application.ProductDeleted; public class ProductDeletedHandler(IUnitOfWork uow) { - public async Task HandleAsync(ProductDeletedApplicationEvent ae) + public async Task HandleAsync(ProductDeletedApplicationEvent @event) { - await uow.BulkDeleteItemsByProductIdAsync(ae.Id).ConfigureAwait(false); + await uow.BulkDeleteItemsByProductIdAsync(@event.Id).ConfigureAwait(false); } } diff --git a/src/Modules/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandler.cs b/src/Modules/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandler.cs index 046642ac4..5ca4f5e70 100644 --- a/src/Modules/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandler.cs +++ b/src/Modules/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandler.cs @@ -34,7 +34,7 @@ public async Task Handle(CreatePurchasedCartCommand req, Cancel await uow.SaveChangesAsync(ct).ConfigureAwait(false); await raiser.RaiseApplicationEventAsync( - @event: new UserPurchasedProductApplicationEvent( + @event: new ProductsPurchasedApplicationEvent( Ids: [.. items.Select(x => x.ProductId)] ) ).ConfigureAwait(false); diff --git a/src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandler.cs b/src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandler.cs index 34c509e6d..f350896fa 100644 --- a/src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandler.cs +++ b/src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandler.cs @@ -14,23 +14,23 @@ public class ActiveCartDeliveryRequestedApplicationEventHandler( IRequestSender sender ) { - public async Task HandleAsync(ActiveCartDeliveryRequestedApplicationEvent ae) + public async Task HandleAsync(ActiveCartDeliveryRequestedApplicationEvent @event) { - PurchasedCart cart = await reads.SingleByIdAsync(ae.PurchasedCartId).ConfigureAwait(false) - ?? throw CustomNotFoundException.ById(ae.PurchasedCartId); + PurchasedCart cart = await reads.SingleByIdAsync(@event.PurchasedCartId).ConfigureAwait(false) + ?? throw CustomNotFoundException.ById(@event.PurchasedCartId); string buyer = await sender.SendQueryAsync( query: new GetUsernameByIdQuery(cart.BuyerId) ).ConfigureAwait(false); - double weight = ae.Weight; - int count = ae.Count; + double weight = @event.Weight; + int count = @event.Count; ShipmentId shipmentId = await sender.SendCommandAsync( command: new CreateShipmentCommand( Info: new(count, weight, buyer), - Service: ae.ShipmentService, - Address: ae.Address, - Contact: ae.Contact, + Service: @event.ShipmentService, + Address: @event.Address, + Contact: @event.Contact, BuyerId: cart.BuyerId ) ).ConfigureAwait(false); diff --git a/src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandler.cs b/src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandler.cs index 25fb3c7e9..eee1a5a20 100644 --- a/src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandler.cs +++ b/src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandler.cs @@ -17,18 +17,18 @@ public class CartPaymentCompletedApplicationEventHandler( IEmailService email ) { - public async Task HandleAsync(CartPaymentCompletedApplicationEvent ae) + public async Task HandleAsync(CartPaymentCompletedApplicationEvent @event) { - PurchasedCart cart = await reads.SingleByIdAsync(ae.CartId).ConfigureAwait(false) - ?? throw CustomNotFoundException.ById(ae.CartId); + PurchasedCart cart = await reads.SingleByIdAsync(@event.CartId).ConfigureAwait(false) + ?? throw CustomNotFoundException.ById(@event.CartId); cart.FinishPayment(success: true); await uow.SaveChangesAsync().ConfigureAwait(false); - await uow.BulkDeleteItemsByBuyerIdAsync(ae.BuyerId).ConfigureAwait(false); + await uow.BulkDeleteItemsByBuyerIdAsync(@event.BuyerId).ConfigureAwait(false); string to = await sender.SendQueryAsync( - query: new GetUserEmailByIdQuery(ae.BuyerId) + query: new GetUserEmailByIdQuery(@event.BuyerId) ).ConfigureAwait(false); string url = await sender.SendQueryAsync( diff --git a/src/Modules/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandler.cs b/src/Modules/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandler.cs index 645c7e012..bf137ee1d 100644 --- a/src/Modules/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandler.cs +++ b/src/Modules/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandler.cs @@ -4,7 +4,7 @@ using CustomCADs.Shared.Application.Abstractions.Events; using CustomCADs.Shared.Application.Abstractions.Requests.Sender; using CustomCADs.Shared.Application.Dtos.Notifications; -using CustomCADs.Shared.Application.Events.Files; +using CustomCADs.Shared.Application.Events.Catalog; using CustomCADs.Shared.Application.Events.Notifications; using CustomCADs.Shared.Application.UseCases.ActiveCarts.Queries; diff --git a/src/Modules/Catalog/Application/Products/Events/Application/ProductCreated/ProductCreatedHandler.cs b/src/Modules/Catalog/Application/Products/Events/Application/ProductCreated/ProductCreatedHandler.cs index 5cf5f887f..57b7dc8c0 100644 --- a/src/Modules/Catalog/Application/Products/Events/Application/ProductCreated/ProductCreatedHandler.cs +++ b/src/Modules/Catalog/Application/Products/Events/Application/ProductCreated/ProductCreatedHandler.cs @@ -5,11 +5,11 @@ namespace CustomCADs.Modules.Catalog.Application.Products.Events.Application.Pro public class ProductCreatedHandler(IProductWrites writes, IUnitOfWork uow) { - public async Task HandleAsync(ProductCreatedApplicationEvent ae) + public async Task HandleAsync(ProductCreatedApplicationEvent @event) { - foreach (TagId tagId in ae.TagIds) + foreach (TagId tagId in @event.TagIds) { - await writes.AddTagAsync(ae.Id, tagId).ConfigureAwait(false); + await writes.AddTagAsync(@event.Id, tagId).ConfigureAwait(false); } await uow.SaveChangesAsync().ConfigureAwait(false); diff --git a/src/Modules/Catalog/Application/Products/Events/Application/ProductPurchased/ProductsPurchasedHandler.cs b/src/Modules/Catalog/Application/Products/Events/Application/ProductPurchased/ProductsPurchasedHandler.cs new file mode 100644 index 000000000..a386a7446 --- /dev/null +++ b/src/Modules/Catalog/Application/Products/Events/Application/ProductPurchased/ProductsPurchasedHandler.cs @@ -0,0 +1,12 @@ +using CustomCADs.Modules.Catalog.Domain.Repositories; +using CustomCADs.Shared.Application.Events.Catalog; + +namespace CustomCADs.Modules.Catalog.Application.Products.Events.Application.ProductPurchased; + +public sealed class ProductsPurchasedHandler(IUnitOfWork uow) +{ + public async Task HandleAsync(ProductsPurchasedApplicationEvent req, CancellationToken ct) + { + await uow.AddProductsPurchasesAsync(req.Ids, count: 1, ct: ct).ConfigureAwait(false); + } +} diff --git a/src/Modules/Catalog/Application/Products/Events/Application/ProductPurchased/UserPurchasedProductHandler.cs b/src/Modules/Catalog/Application/Products/Events/Application/ProductPurchased/UserPurchasedProductHandler.cs deleted file mode 100644 index 66cf64fd0..000000000 --- a/src/Modules/Catalog/Application/Products/Events/Application/ProductPurchased/UserPurchasedProductHandler.cs +++ /dev/null @@ -1,12 +0,0 @@ -using CustomCADs.Modules.Catalog.Domain.Repositories; -using CustomCADs.Shared.Application.Events.Catalog; - -namespace CustomCADs.Modules.Catalog.Application.Products.Events.Application.ProductPurchased; - -public sealed class UserPurchasedProductHandler(IUnitOfWork uow) -{ - public async Task HandleAsync(UserPurchasedProductApplicationEvent req, CancellationToken ct) - { - await uow.AddProductPurchasesAsync(req.Ids, count: 1, ct: ct).ConfigureAwait(false); - } -} diff --git a/src/Modules/Catalog/Application/Products/Events/Application/ProductViewed/ProductViewedApplicationEvent.cs b/src/Modules/Catalog/Application/Products/Events/Application/ProductViewed/ProductViewedApplicationEvent.cs deleted file mode 100644 index dfdfe9784..000000000 --- a/src/Modules/Catalog/Application/Products/Events/Application/ProductViewed/ProductViewedApplicationEvent.cs +++ /dev/null @@ -1,10 +0,0 @@ -using CustomCADs.Shared.Domain.Bases.Events; -using CustomCADs.Shared.Domain.TypedIds.Accounts; - -namespace CustomCADs.Modules.Catalog.Application.Products.Events.Application.ProductViewed; - -public record ProductViewedApplicationEvent( - ProductId Id, - AccountId AccountId, - DateTimeOffset ViewedAt -) : BaseApplicationEvent; diff --git a/src/Modules/Catalog/Application/Products/Events/Application/ProductViewed/ProductViewedHandler.cs b/src/Modules/Catalog/Application/Products/Events/Application/ProductViewed/ProductViewedHandler.cs index ac559af70..4d4afb64c 100644 --- a/src/Modules/Catalog/Application/Products/Events/Application/ProductViewed/ProductViewedHandler.cs +++ b/src/Modules/Catalog/Application/Products/Events/Application/ProductViewed/ProductViewedHandler.cs @@ -9,34 +9,34 @@ namespace CustomCADs.Modules.Catalog.Application.Products.Events.Application.Pro public class ProductViewedHandler(IProductReads reads, IUnitOfWork uow, IRequestSender sender, IEventRaiser raiser) { - public async Task HandleAsync(ProductViewedApplicationEvent ae) + public async Task HandleAsync(ProductViewedApplicationEvent @event) { bool userAlreadyViewed = await sender.SendQueryAsync( - query: new GetAccountViewedProductQuery(ae.AccountId, ae.Id) + query: new GetAccountViewedProductQuery(@event.AccountId, @event.Id) ).ConfigureAwait(false); if (userAlreadyViewed) return; var account = await sender.SendQueryAsync( query: new GetAccountInfoByUsernameQuery( Username: await sender.SendQueryAsync( - query: new GetUsernameByIdQuery(ae.AccountId) + query: new GetUsernameByIdQuery(@event.AccountId) ).ConfigureAwait(false) ) ).ConfigureAwait(false); if (!account.TrackViewedProducts) return; - Product product = await reads.SingleByIdAsync(ae.Id).ConfigureAwait(false) - ?? throw CustomNotFoundException.ById(ae.Id); + Product product = await reads.SingleByIdAsync(@event.Id).ConfigureAwait(false) + ?? throw CustomNotFoundException.ById(@event.Id); product.AddToViewCount(); await uow.SaveChangesAsync().ConfigureAwait(false); await raiser.RaiseApplicationEventAsync( - @event: new UserViewedProductApplicationEvent( - Id: ae.Id, - AccountId: ae.AccountId, - ViewedAt: ae.ViewedAt + @event: new ProductViewedApplicationEvent( + Id: @event.Id, + AccountId: @event.AccountId, + ViewedAt: @event.ViewedAt ) ).ConfigureAwait(false); } diff --git a/src/Modules/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandler.cs b/src/Modules/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandler.cs index 44d1e294c..2090ac179 100644 --- a/src/Modules/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandler.cs +++ b/src/Modules/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandler.cs @@ -1,8 +1,8 @@ -using CustomCADs.Modules.Catalog.Application.Products.Events.Application.ProductViewed; -using CustomCADs.Modules.Catalog.Domain.Products.Enums; +using CustomCADs.Modules.Catalog.Domain.Products.Enums; using CustomCADs.Modules.Catalog.Domain.Repositories.Reads; using CustomCADs.Shared.Application.Abstractions.Events; using CustomCADs.Shared.Application.Abstractions.Requests.Sender; +using CustomCADs.Shared.Application.Events.Catalog; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; using CustomCADs.Shared.Application.UseCases.Categories.Queries; diff --git a/src/Modules/Catalog/Domain/Repositories/IUnitOfWork.cs b/src/Modules/Catalog/Domain/Repositories/IUnitOfWork.cs index 9917d0b13..ce075ebb1 100644 --- a/src/Modules/Catalog/Domain/Repositories/IUnitOfWork.cs +++ b/src/Modules/Catalog/Domain/Repositories/IUnitOfWork.cs @@ -4,5 +4,5 @@ public interface IUnitOfWork { Task SaveChangesAsync(CancellationToken ct = default); Task ClearProductTagsAsync(ProductId[] ids, string tag, CancellationToken ct = default); - Task AddProductPurchasesAsync(ProductId[] ids, int count = 1, CancellationToken ct = default); + Task AddProductsPurchasesAsync(ProductId[] ids, int count = 1, CancellationToken ct = default); } diff --git a/src/Modules/Catalog/Persistence/Repositories/UnitOfWork.cs b/src/Modules/Catalog/Persistence/Repositories/UnitOfWork.cs index ad77897c6..e667037ff 100644 --- a/src/Modules/Catalog/Persistence/Repositories/UnitOfWork.cs +++ b/src/Modules/Catalog/Persistence/Repositories/UnitOfWork.cs @@ -29,7 +29,7 @@ public async Task ClearProductTagsAsync(ProductId[] ids, string tag, Cancellatio .ExecuteDeleteAsync(ct) .ConfigureAwait(false); - public async Task AddProductPurchasesAsync(ProductId[] ids, int count = 1, CancellationToken ct = default) + public async Task AddProductsPurchasesAsync(ProductId[] ids, int count = 1, CancellationToken ct = default) => await context.Products .Where(x => ids.Contains(x.Id)) .ExecuteUpdateAsync(x => x diff --git a/src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandler.cs b/src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandler.cs index 5d3f9d12f..7e404d0cd 100644 --- a/src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandler.cs +++ b/src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandler.cs @@ -13,23 +13,23 @@ public class CustomDeliveryRequestedApplicationEventHandler( IRequestSender sender ) { - public async Task HandleAsync(CustomDeliveryRequestedApplicationEvent ae) + public async Task HandleAsync(CustomDeliveryRequestedApplicationEvent @event) { - Custom custom = await reads.SingleByIdAsync(ae.CustomId).ConfigureAwait(false) - ?? throw CustomNotFoundException.ById(ae.CustomId); + Custom custom = await reads.SingleByIdAsync(@event.CustomId).ConfigureAwait(false) + ?? throw CustomNotFoundException.ById(@event.CustomId); string buyer = await sender.SendQueryAsync( query: new GetUsernameByIdQuery(custom.BuyerId) ).ConfigureAwait(false); - int count = ae.Count; - double weight = ae.Weight; + int count = @event.Count; + double weight = @event.Weight; ShipmentId shipmentId = await sender.SendCommandAsync( command: new CreateShipmentCommand( Info: new(count, weight, buyer), - Service: ae.ShipmentService, - Address: ae.Address, - Contact: ae.Contact, + Service: @event.ShipmentService, + Address: @event.Address, + Contact: @event.Contact, BuyerId: custom.BuyerId ) ).ConfigureAwait(false); diff --git a/src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandler.cs b/src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandler.cs index 13ea454c8..f4ed4a4b1 100644 --- a/src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandler.cs +++ b/src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandler.cs @@ -17,16 +17,16 @@ public class CustomPaymentCompletedApplicationEventHandler( IEmailService email ) { - public async Task HandleAsync(CustomPaymentCompletedApplicationEvent ae) + public async Task HandleAsync(CustomPaymentCompletedApplicationEvent @event) { - Custom custom = await reads.SingleByIdAsync(ae.CustomId).ConfigureAwait(false) - ?? throw CustomNotFoundException.ById(ae.CustomId); + Custom custom = await reads.SingleByIdAsync(@event.CustomId).ConfigureAwait(false) + ?? throw CustomNotFoundException.ById(@event.CustomId); custom.FinishPayment(success: true); await uow.SaveChangesAsync().ConfigureAwait(false); string to = await sender.SendQueryAsync( - query: new GetUserEmailByIdQuery(ae.BuyerId) + query: new GetUserEmailByIdQuery(@event.BuyerId) ).ConfigureAwait(false); string url = await sender.SendQueryAsync( diff --git a/src/Modules/Files/Application/Cads/Events/Application/ProductDeletedHandler.cs b/src/Modules/Files/Application/Cads/Events/Application/ProductDeletedHandler.cs index 0d5402dab..b32e3f412 100644 --- a/src/Modules/Files/Application/Cads/Events/Application/ProductDeletedHandler.cs +++ b/src/Modules/Files/Application/Cads/Events/Application/ProductDeletedHandler.cs @@ -1,22 +1,22 @@ using CustomCADs.Modules.Files.Application.Cads.Storage; using CustomCADs.Modules.Files.Domain.Repositories; using CustomCADs.Modules.Files.Domain.Repositories.Reads; -using CustomCADs.Shared.Application.Events.Files; +using CustomCADs.Shared.Application.Events.Catalog; namespace CustomCADs.Modules.Files.Application.Cads.Events.Application; public class ProductDeletedHandler(ICadReads reads, IWrites writes, IUnitOfWork uow, ICadStorageService storage, BaseCachingService cache) { - public async Task HandleAsync(ProductDeletedApplicationEvent ae) + public async Task HandleAsync(ProductDeletedApplicationEvent @event) { - Cad cad = await reads.SingleByIdAsync(ae.CadId, track: true).ConfigureAwait(false) - ?? throw CustomNotFoundException.ById(ae.CadId); + Cad cad = await reads.SingleByIdAsync(@event.CadId, track: true).ConfigureAwait(false) + ?? throw CustomNotFoundException.ById(@event.CadId); await storage.DeleteFileAsync(cad.Key).ConfigureAwait(false); writes.Remove(cad); await uow.SaveChangesAsync().ConfigureAwait(false); - await cache.ClearAsync(ae.CadId).ConfigureAwait(false); + await cache.ClearAsync(@event.CadId).ConfigureAwait(false); } } diff --git a/src/Modules/Files/Application/Images/Events/Application/ProductDeletedHandler.cs b/src/Modules/Files/Application/Images/Events/Application/ProductDeletedHandler.cs index 7582d3484..27176b598 100644 --- a/src/Modules/Files/Application/Images/Events/Application/ProductDeletedHandler.cs +++ b/src/Modules/Files/Application/Images/Events/Application/ProductDeletedHandler.cs @@ -1,22 +1,22 @@ using CustomCADs.Modules.Files.Application.Images.Storage; using CustomCADs.Modules.Files.Domain.Repositories; using CustomCADs.Modules.Files.Domain.Repositories.Reads; -using CustomCADs.Shared.Application.Events.Files; +using CustomCADs.Shared.Application.Events.Catalog; namespace CustomCADs.Modules.Files.Application.Images.Events.Application; public class ProductDeletedHandler(IImageReads reads, IWrites writes, IUnitOfWork uow, IImageStorageService storage, BaseCachingService cache) { - public async Task HandleAsync(ProductDeletedApplicationEvent ae) + public async Task HandleAsync(ProductDeletedApplicationEvent @event) { - Image image = await reads.SingleByIdAsync(ae.ImageId, track: true).ConfigureAwait(false) - ?? throw CustomNotFoundException.ById(ae.ImageId); + Image image = await reads.SingleByIdAsync(@event.ImageId, track: true).ConfigureAwait(false) + ?? throw CustomNotFoundException.ById(@event.ImageId); await storage.DeleteFileAsync(image.Key).ConfigureAwait(false); writes.Remove(image); await uow.SaveChangesAsync().ConfigureAwait(false); - await cache.ClearAsync(ae.ImageId).ConfigureAwait(false); + await cache.ClearAsync(@event.ImageId).ConfigureAwait(false); } } diff --git a/src/Modules/Identity/Application/Users/Events/Application/Emails/EmailVerification/EmailVerificationRequestedEventHandler.cs b/src/Modules/Identity/Application/Users/Events/Application/Emails/EmailVerification/EmailVerificationRequestedEventHandler.cs index b840a8f20..5ae65946e 100644 --- a/src/Modules/Identity/Application/Users/Events/Application/Emails/EmailVerification/EmailVerificationRequestedEventHandler.cs +++ b/src/Modules/Identity/Application/Users/Events/Application/Emails/EmailVerification/EmailVerificationRequestedEventHandler.cs @@ -4,8 +4,8 @@ namespace CustomCADs.Modules.Identity.Application.Users.Events.Application.Email public class EmailVerificationRequestedEventHandler(IEmailService email) { - public async Task HandleAsync(EmailVerificationRequestedApplicationEvent ae) + public async Task HandleAsync(EmailVerificationRequestedApplicationEvent @event) { - await email.SendVerificationEmailAsync(ae.Email, ae.Endpoint).ConfigureAwait(false); + await email.SendVerificationEmailAsync(@event.Email, @event.Endpoint).ConfigureAwait(false); } } diff --git a/src/Modules/Identity/Application/Users/Events/Application/Emails/PasswordReset/PasswordResetRequestedEventHandler.cs b/src/Modules/Identity/Application/Users/Events/Application/Emails/PasswordReset/PasswordResetRequestedEventHandler.cs index 6efca4756..84c116549 100644 --- a/src/Modules/Identity/Application/Users/Events/Application/Emails/PasswordReset/PasswordResetRequestedEventHandler.cs +++ b/src/Modules/Identity/Application/Users/Events/Application/Emails/PasswordReset/PasswordResetRequestedEventHandler.cs @@ -4,8 +4,8 @@ namespace CustomCADs.Modules.Identity.Application.Users.Events.Application.Email public class PasswordResetRequestedEventHandler(IEmailService email) { - public async Task HandleAsync(PasswordResetRequestedApplicationEvent ae) + public async Task HandleAsync(PasswordResetRequestedApplicationEvent @event) { - await email.SendForgotPasswordEmailAsync(ae.Email, ae.Endpoint).ConfigureAwait(false); + await email.SendForgotPasswordEmailAsync(@event.Email, @event.Endpoint).ConfigureAwait(false); } } diff --git a/src/Modules/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandler.cs b/src/Modules/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandler.cs index 282acf2ac..cb0c1d535 100644 --- a/src/Modules/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandler.cs +++ b/src/Modules/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandler.cs @@ -4,8 +4,8 @@ namespace CustomCADs.Modules.Identity.Application.Users.Events.Application.Roles public class RoleCreatedHandler(IRoleService service) { - public async Task HandleAsync(RoleCreatedApplicationEvent ae) + public async Task HandleAsync(RoleCreatedApplicationEvent @event) => await service.CreateAsync( - name: ae.Name + name: @event.Name ).ConfigureAwait(false); } diff --git a/src/Modules/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandler.cs b/src/Modules/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandler.cs index 635a00996..1378ec79a 100644 --- a/src/Modules/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandler.cs +++ b/src/Modules/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandler.cs @@ -4,8 +4,8 @@ namespace CustomCADs.Modules.Identity.Application.Users.Events.Application.Roles public class RoleDeletedHandler(IRoleService service) { - public async Task HandleAsync(RoleDeletedApplicationEvent ae) + public async Task HandleAsync(RoleDeletedApplicationEvent @event) => await service.DeleteAsync( - name: ae.Name + name: @event.Name ).ConfigureAwait(false); } diff --git a/src/Modules/Identity/Application/Users/Events/Application/Users/AccountCreatedHandler.cs b/src/Modules/Identity/Application/Users/Events/Application/Users/AccountCreatedHandler.cs new file mode 100644 index 000000000..efe300e16 --- /dev/null +++ b/src/Modules/Identity/Application/Users/Events/Application/Users/AccountCreatedHandler.cs @@ -0,0 +1,19 @@ +using CustomCADs.Shared.Application.Events.Account.Accounts; + +namespace CustomCADs.Modules.Identity.Application.Users.Events.Application.Users; + +public class AccountCreatedHandler(IUserService service) +{ + public async Task HandleAsync(AccountCreatedApplicationEvent @event) + { + await service.CreateAsync( + user: User.Create( + role: @event.Role, + username: @event.Username, + email: new(@event.Email), + accountId: @event.Id + ), + password: @event.Password + ).ConfigureAwait(false); + } +} diff --git a/src/Modules/Identity/Application/Users/Events/Application/Users/AccountDeletedHandler.cs b/src/Modules/Identity/Application/Users/Events/Application/Users/AccountDeletedHandler.cs new file mode 100644 index 000000000..7855bfc6e --- /dev/null +++ b/src/Modules/Identity/Application/Users/Events/Application/Users/AccountDeletedHandler.cs @@ -0,0 +1,11 @@ +using CustomCADs.Shared.Application.Events.Account.Accounts; + +namespace CustomCADs.Modules.Identity.Application.Users.Events.Application.Users; + +public class AccountDeletedHandler(IUserService service) +{ + public async Task HandleAsync(AccountDeletedApplicationEvent @event) + { + await service.DeleteAsync(@event.Id).ConfigureAwait(false); + } +} diff --git a/src/Modules/Identity/Application/Users/Events/Application/Users/UserCreatedHandler.cs b/src/Modules/Identity/Application/Users/Events/Application/Users/UserCreatedHandler.cs deleted file mode 100644 index e8013c508..000000000 --- a/src/Modules/Identity/Application/Users/Events/Application/Users/UserCreatedHandler.cs +++ /dev/null @@ -1,19 +0,0 @@ -using CustomCADs.Shared.Application.Events.Account.Accounts; - -namespace CustomCADs.Modules.Identity.Application.Users.Events.Application.Users; - -public class UserCreatedHandler(IUserService service) -{ - public async Task HandleAsync(AccountCreatedApplicationEvent ae) - { - await service.CreateAsync( - user: User.Create( - role: ae.Role, - username: ae.Username, - email: new(ae.Email), - accountId: ae.Id - ), - password: ae.Password - ).ConfigureAwait(false); - } -} diff --git a/src/Modules/Identity/Application/Users/Events/Application/Users/UserDeletedHandler.cs b/src/Modules/Identity/Application/Users/Events/Application/Users/UserDeletedHandler.cs deleted file mode 100644 index 3b8c832ba..000000000 --- a/src/Modules/Identity/Application/Users/Events/Application/Users/UserDeletedHandler.cs +++ /dev/null @@ -1,11 +0,0 @@ -using CustomCADs.Shared.Application.Events.Account.Accounts; - -namespace CustomCADs.Modules.Identity.Application.Users.Events.Application.Users; - -public class UserDeletedHandler(IUserService service) -{ - public async Task HandleAsync(AccountDeletedApplicationEvent ae) - { - await service.DeleteAsync(ae.Id).ConfigureAwait(false); - } -} diff --git a/src/Modules/Notifications/Application/Notifications/Events/NotificationRequestedHandler.cs b/src/Modules/Notifications/Application/Notifications/Events/NotificationRequestedHandler.cs index 23fe5517a..5f33541bb 100644 --- a/src/Modules/Notifications/Application/Notifications/Events/NotificationRequestedHandler.cs +++ b/src/Modules/Notifications/Application/Notifications/Events/NotificationRequestedHandler.cs @@ -9,16 +9,16 @@ namespace CustomCADs.Modules.Notifications.Application.Notifications.Events; public class NotificationRequestedHandler(IWrites writes, IUnitOfWork uow, IRequestSender sender, INotificationsRealTimeNotifier notifier) { - public async Task HandleAsync(NotificationRequestedEvent ae) + public async Task HandleAsync(NotificationRequestedEvent @event) { List notifications = []; - if (ae.ReceiverIds is [AccountId receiverId]) + if (@event.ReceiverIds is [AccountId receiverId]) { Notification notification = await writes.AddAsync( entity: Notification.Create( - type: ae.Type.ToString(), - content: new(ae.Description, ae.Link), - authorId: ae.AuthorId, + type: @event.Type.ToString(), + content: new(@event.Description, @event.Link), + authorId: @event.AuthorId, receiverId: receiverId ) ).ConfigureAwait(false); @@ -29,17 +29,17 @@ public async Task HandleAsync(NotificationRequestedEvent ae) else notifications = [.. await uow.InsertNotificationsAsync( notifications: Notification.CreateBulk( - type: ae.Type.ToString(), - content: new(ae.Description, ae.Link), - authorId: ae.AuthorId, - receiverIds: [.. ae.ReceiverIds.Distinct()] + type: @event.Type.ToString(), + content: new(@event.Description, @event.Link), + authorId: @event.AuthorId, + receiverIds: [.. @event.ReceiverIds.Distinct()] ) ).ConfigureAwait(false) ]; - string author = await sender.SendQueryAsync(new GetUsernameByIdQuery(ae.AuthorId)).ConfigureAwait(false); + string author = await sender.SendQueryAsync(new GetUsernameByIdQuery(@event.AuthorId)).ConfigureAwait(false); await notifier.NotifyUsersAsync( - ids: ae.ReceiverIds, + ids: @event.ReceiverIds, message: "ReceiveNew", payload: notifications.Select(x => new { diff --git a/src/Shared/Application/Events/Files/ProductDeletedApplicationEvent.cs b/src/Shared/Application/Events/Catalog/ProductDeletedApplicationEvent.cs similarity index 67% rename from src/Shared/Application/Events/Files/ProductDeletedApplicationEvent.cs rename to src/Shared/Application/Events/Catalog/ProductDeletedApplicationEvent.cs index 393e37684..492120e94 100644 --- a/src/Shared/Application/Events/Files/ProductDeletedApplicationEvent.cs +++ b/src/Shared/Application/Events/Catalog/ProductDeletedApplicationEvent.cs @@ -1,4 +1,4 @@ -namespace CustomCADs.Shared.Application.Events.Files; +namespace CustomCADs.Shared.Application.Events.Catalog; public record ProductDeletedApplicationEvent( ProductId Id, diff --git a/src/Shared/Application/Events/Catalog/UserViewedProductApplicationEvent.cs b/src/Shared/Application/Events/Catalog/ProductViewedApplicationEvent.cs similarity index 75% rename from src/Shared/Application/Events/Catalog/UserViewedProductApplicationEvent.cs rename to src/Shared/Application/Events/Catalog/ProductViewedApplicationEvent.cs index 02485e742..fc966b4e7 100644 --- a/src/Shared/Application/Events/Catalog/UserViewedProductApplicationEvent.cs +++ b/src/Shared/Application/Events/Catalog/ProductViewedApplicationEvent.cs @@ -1,7 +1,7 @@ namespace CustomCADs.Shared.Application.Events.Catalog; -public record UserViewedProductApplicationEvent( - AccountId AccountId, +public record ProductViewedApplicationEvent( ProductId Id, + AccountId AccountId, DateTimeOffset ViewedAt ) : BaseApplicationEvent; diff --git a/src/Shared/Application/Events/Catalog/UserPurchasedProductApplicationEvent.cs b/src/Shared/Application/Events/Catalog/ProductsPurchasedApplicationEvent.cs similarity index 62% rename from src/Shared/Application/Events/Catalog/UserPurchasedProductApplicationEvent.cs rename to src/Shared/Application/Events/Catalog/ProductsPurchasedApplicationEvent.cs index fb868bf8b..4c1e690bb 100644 --- a/src/Shared/Application/Events/Catalog/UserPurchasedProductApplicationEvent.cs +++ b/src/Shared/Application/Events/Catalog/ProductsPurchasedApplicationEvent.cs @@ -1,5 +1,5 @@ namespace CustomCADs.Shared.Application.Events.Catalog; -public sealed record UserPurchasedProductApplicationEvent( +public sealed record ProductsPurchasedApplicationEvent( ProductId[] Ids ) : BaseApplicationEvent; diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserDeletedHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserDeletedHandlerUnitTests.cs index 467fd9858..95e88027c 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserDeletedHandlerUnitTests.cs @@ -30,10 +30,10 @@ public UserDeletedHandlerUnitTests() public async Task Handle_ShoulQueryDatabase() { // Arrange - UserDeletedApplicationEvent ae = new(ValidId); + UserDeletedApplicationEvent @event = new(ValidId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); @@ -43,10 +43,10 @@ public async Task Handle_ShoulQueryDatabase() public async Task Handle_ShoulPersistToDatabase() { // Arrange - UserDeletedApplicationEvent ae = new(ValidId); + UserDeletedApplicationEvent @event = new(ValidId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert writes.Verify(x => x.Remove(account), Times.Once()); @@ -58,12 +58,12 @@ public async Task Handle_ShoulThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Account); - UserDeletedApplicationEvent ae = new(ValidId); + UserDeletedApplicationEvent @event = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(ae) + async () => await handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserEditedHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserEditedHandlerUnitTests.cs index 40e1c3faa..c13bc385d 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserEditedHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserEditedHandlerUnitTests.cs @@ -26,14 +26,14 @@ public UserEditedHandlerUnitTests() public async Task Handle_ShoulQueryDatabase() { // Arrange - UserEditedApplicationEvent ae = new( + UserEditedApplicationEvent @event = new( Id: ValidId, Username: null, TrackViewedProducts: null ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); @@ -43,14 +43,14 @@ public async Task Handle_ShoulQueryDatabase() public async Task Handle_ShoulPersistToDatabase() { // Arrange - UserEditedApplicationEvent ae = new( + UserEditedApplicationEvent @event = new( Id: ValidId, Username: null, TrackViewedProducts: null ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); @@ -61,7 +61,7 @@ public async Task Handle_ShoulThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Account); - UserEditedApplicationEvent ae = new( + UserEditedApplicationEvent @event = new( Id: ValidId, Username: null, TrackViewedProducts: null @@ -70,7 +70,7 @@ public async Task Handle_ShoulThrowException_WhenNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(ae) + async () => await handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserViewedProductHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserViewedProductHandlerUnitTests.cs index 2745f7543..0e4677ebf 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserViewedProductHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserViewedProductHandlerUnitTests.cs @@ -26,10 +26,10 @@ public UserViewedProductHandlerUnitTests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - UserViewedProductApplicationEvent ie = new(id, productId, viewedAt); + ProductViewedApplicationEvent @event = new(productId, id, viewedAt); // Act - await handler.HandleAsync(ie); + await handler.HandleAsync(@event); // Assert writes.Verify(x => x.ViewProductAsync(id, productId, viewedAt, ct), Times.Once()); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedApplicationEventHandlerUnitTests.cs index ecf9a81c3..c6eef2c24 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedApplicationEventHandlerUnitTests.cs @@ -1,6 +1,6 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Events.Application.ProductDeleted; using CustomCADs.Modules.Carts.Domain.Repositories; -using CustomCADs.Shared.Application.Events.Files; +using CustomCADs.Shared.Application.Events.Catalog; namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Events.Application.ProductDeleted; diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs index 7adfd3eb9..fe485f410 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs @@ -117,7 +117,7 @@ public async Task Handle_ShouldRaiseEvents() // Assert raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Ids == productIds) + It.Is(x => x.Ids == productIds) ), Times.Once()); } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests.cs index 4e15054ef..222b52d65 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests.cs @@ -44,7 +44,7 @@ public ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ActiveCartDeliveryRequestedApplicationEvent de = new( + ActiveCartDeliveryRequestedApplicationEvent @event = new( PurchasedCartId: ValidId, ShipmentService: string.Empty, Weight: default, @@ -54,7 +54,7 @@ public async Task Handle_ShouldQueryDatabase() ); // Act - await handler.HandleAsync(de); + await handler.HandleAsync(@event); // Assert reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); @@ -64,7 +64,7 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - ActiveCartDeliveryRequestedApplicationEvent de = new( + ActiveCartDeliveryRequestedApplicationEvent @event = new( PurchasedCartId: ValidId, ShipmentService: string.Empty, Weight: default, @@ -74,7 +74,7 @@ public async Task Handle_ShouldSendRequests() ); // Act - await handler.HandleAsync(de); + await handler.HandleAsync(@event); // Assert sender.Verify(x => x.SendQueryAsync( @@ -94,7 +94,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as PurchasedCart); - ActiveCartDeliveryRequestedApplicationEvent de = new( + ActiveCartDeliveryRequestedApplicationEvent @event = new( PurchasedCartId: ValidId, ShipmentService: string.Empty, Weight: default, @@ -106,7 +106,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(de) + async () => await handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs index 1a1dd85aa..f45bb89b3 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs @@ -44,10 +44,10 @@ public CartPaymentCompletedApplicationEventHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CartPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); @@ -57,10 +57,10 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CartPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); @@ -71,10 +71,10 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CartPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert sender.Verify(x => x.SendQueryAsync( @@ -91,10 +91,10 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldSendEmail() { // Arrange - CartPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert email.Verify(x => x.SendRewardGrantedEmailAsync( @@ -116,10 +116,10 @@ public async Task Handle_ShouldIdk_WhenForDelivery() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(cart); - CartPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert email.Verify(x => x.SendRewardGrantedEmailAsync( @@ -134,12 +134,12 @@ public async Task Handle_ShouldThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as PurchasedCart); - CartPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(ae) + async () => await handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandlerUnitTests.cs index 1c573c4e1..998016a63 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandlerUnitTests.cs @@ -5,7 +5,7 @@ using CustomCADs.Shared.Application.Abstractions.Events; using CustomCADs.Shared.Application.Abstractions.Requests.Sender; using CustomCADs.Shared.Application.Dtos.Notifications; -using CustomCADs.Shared.Application.Events.Files; +using CustomCADs.Shared.Application.Events.Catalog; using CustomCADs.Shared.Application.Events.Notifications; using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.ActiveCarts.Queries; diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductCreatedHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductCreatedHandlerUnitTests.cs index 3c0bec0bf..5ba5e10e7 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductCreatedHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductCreatedHandlerUnitTests.cs @@ -23,10 +23,10 @@ public ProductCreatedHandlerUnitTests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductCreatedApplicationEvent ae = new(ValidId, TagIds); + ProductCreatedApplicationEvent @event = new(ValidId, TagIds); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert writes.Verify( diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductViewedHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductViewedHandlerUnitTests.cs index 66eef43e5..41107864f 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductViewedHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductViewedHandlerUnitTests.cs @@ -58,10 +58,10 @@ public ProductViewedHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ProductViewedApplicationEvent ae = new(ValidId, ValidCreatorId, viewedAt); + ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); @@ -71,10 +71,10 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductViewedApplicationEvent ae = new(ValidId, ValidCreatorId, viewedAt); + ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); @@ -84,10 +84,10 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - ProductViewedApplicationEvent ae = new(ValidId, ValidCreatorId, viewedAt); + ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert sender.Verify(x => x.SendQueryAsync( @@ -108,14 +108,14 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - ProductViewedApplicationEvent ae = new(ValidId, ValidCreatorId, viewedAt); + ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) + It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) ), Times.Once()); } @@ -123,10 +123,10 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldPopulateProperties() { // Arrange - ProductViewedApplicationEvent ae = new(ValidId, ValidCreatorId, viewedAt); + ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert Assert.Equal(1, product.Counts.Views); @@ -140,16 +140,16 @@ public async Task Handle_ShouldReturnEarly_WhenUserDoesNotTrackViewedProducts() It.Is(x => x.Username == Username), ct )).ReturnsAsync(info with { TrackViewedProducts = false }); - ProductViewedApplicationEvent ae = new(ValidId, ValidCreatorId, viewedAt); + ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Never()); uow.Verify(x => x.SaveChangesAsync(ct), Times.Never()); raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) + It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) ), Times.Never()); Assert.Equal(0, product.Counts.Views); } @@ -162,10 +162,10 @@ public async Task Handle_ShouldReturnEarly_WhenUserAlreadyViewedProduct() It.Is(x => x.Id == ValidCreatorId && x.ProductId == ValidId), ct )).ReturnsAsync(true); - ProductViewedApplicationEvent ae = new(ValidId, ValidCreatorId, viewedAt); + ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert sender.Verify(x => x.SendQueryAsync( @@ -177,7 +177,7 @@ public async Task Handle_ShouldReturnEarly_WhenUserAlreadyViewedProduct() uow.Verify(x => x.SaveChangesAsync(ct), Times.Never()); raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) + It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) ), Times.Never()); Assert.Equal(0, product.Counts.Views); } @@ -189,12 +189,12 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Product); - ProductViewedApplicationEvent ae = new(ValidId, ValidCreatorId, viewedAt); + ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(ae) + async () => await handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/UserPurchasedProductHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductsPurchasedHandlerUnitTests.cs similarity index 60% rename from tests/UnitTests/Catalog/Application/Products/Events/Application/UserPurchasedProductHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Events/Application/ProductsPurchasedHandlerUnitTests.cs index 7a6563ecb..22ab27041 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/UserPurchasedProductHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductsPurchasedHandlerUnitTests.cs @@ -4,14 +4,14 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application; -public class UserPurchasedProductHandlerUnitTests : ProductsBaseUnitTests +public class ProductsPurchasedHandlerUnitTests : ProductsBaseUnitTests { - private readonly UserPurchasedProductHandler handler; + private readonly ProductsPurchasedHandler handler; private readonly Mock uow = new(); private static readonly ProductId[] ids = []; - public UserPurchasedProductHandlerUnitTests() + public ProductsPurchasedHandlerUnitTests() { handler = new(uow.Object); } @@ -20,12 +20,12 @@ public UserPurchasedProductHandlerUnitTests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - UserPurchasedProductApplicationEvent ae = new(ids); + ProductsPurchasedApplicationEvent @event = new(ids); // Act - await handler.HandleAsync(ae, ct); + await handler.HandleAsync(@event, ct); // Assert - uow.Verify(x => x.AddProductPurchasesAsync(ids, 1, ct), Times.Once()); + uow.Verify(x => x.AddProductsPurchasesAsync(ids, 1, ct), Times.Once()); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandlerUnitTests.cs index 7f01efda7..e7898172d 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandlerUnitTests.cs @@ -4,6 +4,7 @@ using CustomCADs.Shared.Application.Abstractions.Events; using CustomCADs.Shared.Application.Abstractions.Requests.Sender; using CustomCADs.Shared.Application.Dtos.Files; +using CustomCADs.Shared.Application.Events.Catalog; using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; using CustomCADs.Shared.Application.UseCases.Categories.Queries; @@ -21,7 +22,6 @@ public class GalleryGetProductByIdHandlerUnitTests : ProductsBaseUnitTests private readonly Mock raiser = new(); private readonly Product product = CreateProductWithId(id: ValidId); - private static readonly DateTimeOffset viewedAt = DateTimeOffset.UtcNow; public GalleryGetProductByIdHandlerUnitTests() { diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandlerUnitTests.cs index 4dd2b5799..6bb633fbf 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandlerUnitTests.cs @@ -52,7 +52,7 @@ public CustomDeliveryRequestedApplicationEventHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CustomDeliveryRequestedApplicationEvent de = new( + CustomDeliveryRequestedApplicationEvent @event = new( CustomId: ValidId, ShipmentService: ShipmentService, Weight: Weight, @@ -62,7 +62,7 @@ public async Task Handle_ShouldQueryDatabase() ); // Act - await handler.HandleAsync(de); + await handler.HandleAsync(@event); // Assert reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); @@ -72,7 +72,7 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CustomDeliveryRequestedApplicationEvent de = new( + CustomDeliveryRequestedApplicationEvent @event = new( CustomId: ValidId, ShipmentService: ShipmentService, Weight: Weight, @@ -82,7 +82,7 @@ public async Task Handle_ShouldPersistToDatabase() ); // Act - await handler.HandleAsync(de); + await handler.HandleAsync(@event); // Assert uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); @@ -92,7 +92,7 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CustomDeliveryRequestedApplicationEvent de = new( + CustomDeliveryRequestedApplicationEvent @event = new( CustomId: ValidId, ShipmentService: ShipmentService, Weight: Weight, @@ -102,7 +102,7 @@ public async Task Handle_ShouldSendRequests() ); // Act - await handler.HandleAsync(de); + await handler.HandleAsync(@event); // Assert sender.Verify(x => x.SendQueryAsync( @@ -119,7 +119,7 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldPopulateProperties() { // Arrange - CustomDeliveryRequestedApplicationEvent de = new( + CustomDeliveryRequestedApplicationEvent @event = new( CustomId: ValidId, ShipmentService: ShipmentService, Weight: Weight, @@ -129,7 +129,7 @@ public async Task Handle_ShouldPopulateProperties() ); // Act - await handler.HandleAsync(de); + await handler.HandleAsync(@event); // Assert Assert.Equal(ValidShipmentId, custom.CompletedCustom?.ShipmentId); @@ -142,7 +142,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - CustomDeliveryRequestedApplicationEvent de = new( + CustomDeliveryRequestedApplicationEvent @event = new( CustomId: ValidId, ShipmentService: ShipmentService, Weight: Weight, @@ -154,7 +154,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(de) + async () => await handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandlerUnitTests.cs index 746c5d1cf..09a005dc6 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandlerUnitTests.cs @@ -49,10 +49,10 @@ public CustomPaymentCompletedApplicationEventHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CustomPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); @@ -62,10 +62,10 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CustomPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); @@ -75,10 +75,10 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CustomPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert sender.Verify(x => x.SendQueryAsync( @@ -95,10 +95,10 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldSendEmail() { // Arrange - CustomPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert email.Verify(x => x.SendRewardGrantedEmailAsync( @@ -122,10 +122,10 @@ public async Task Handle_ShouldGrantShipment_WhenForDelivery() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); - CustomPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert sender.Verify(x => x.SendCommandAsync( @@ -144,12 +144,12 @@ public async Task Handle_ShouldThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Custom); - CustomPaymentCompletedApplicationEvent ae = new(ValidId, ValidBuyerId); + CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(ae) + async () => await handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Files/Application/Cads/Events/Application/ProductDeletedHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Events/Application/ProductDeletedHandlerUnitTests.cs index a3c370cb7..ca734ce2e 100644 --- a/tests/UnitTests/Files/Application/Cads/Events/Application/ProductDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Events/Application/ProductDeletedHandlerUnitTests.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Files.Application.Cads.Storage; using CustomCADs.Modules.Files.Domain.Repositories; using CustomCADs.Modules.Files.Domain.Repositories.Reads; -using CustomCADs.Shared.Application.Events.Files; +using CustomCADs.Shared.Application.Events.Catalog; using CustomCADs.Shared.Application.Exceptions; namespace CustomCADs.UnitTests.Files.Application.Cads.Events.Application; @@ -30,14 +30,14 @@ public ProductDeletedHandlerUnitTests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ProductDeletedApplicationEvent ae = new( + ProductDeletedApplicationEvent @event = new( Id: default, CadId: ValidId, ImageId: default ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); @@ -47,14 +47,14 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductDeletedApplicationEvent ae = new( + ProductDeletedApplicationEvent @event = new( Id: default, CadId: ValidId, ImageId: default ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert writes.Verify(x => x.Remove(cad), Times.Once()); @@ -65,14 +65,14 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - ProductDeletedApplicationEvent ae = new( + ProductDeletedApplicationEvent @event = new( Id: default, CadId: ValidId, ImageId: default ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert cache.Verify( @@ -85,14 +85,14 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldCallStorage() { // Arrange - ProductDeletedApplicationEvent ae = new( + ProductDeletedApplicationEvent @event = new( Id: default, CadId: ValidId, ImageId: default ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert storage.Verify(x => x.DeleteFileAsync(cad.Key, ct), Times.Once()); @@ -105,7 +105,7 @@ public async Task Handle_ShouldThrowException_WhenCadNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Cad); - ProductDeletedApplicationEvent ae = new( + ProductDeletedApplicationEvent @event = new( Id: default, CadId: ValidId, ImageId: default @@ -114,7 +114,7 @@ public async Task Handle_ShouldThrowException_WhenCadNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(ae) + async () => await handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Files/Application/Images/Events/Application/ProductDeletedHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Images/Events/Application/ProductDeletedHandlerUnitTests.cs index bfa4b3ca4..2be0bf8dc 100644 --- a/tests/UnitTests/Files/Application/Images/Events/Application/ProductDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Images/Events/Application/ProductDeletedHandlerUnitTests.cs @@ -2,7 +2,7 @@ using CustomCADs.Modules.Files.Application.Images.Storage; using CustomCADs.Modules.Files.Domain.Repositories; using CustomCADs.Modules.Files.Domain.Repositories.Reads; -using CustomCADs.Shared.Application.Events.Files; +using CustomCADs.Shared.Application.Events.Catalog; using CustomCADs.Shared.Application.Exceptions; namespace CustomCADs.UnitTests.Files.Application.Images.Events.Application; diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerificationRequestedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerificationRequestedHandlerUnitTests.cs index 1344fece6..3b83e8407 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerificationRequestedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerificationRequestedHandlerUnitTests.cs @@ -20,10 +20,10 @@ public EmailVerificationRequestedHandlerUnitTests() public async Task Handle_ShouldSendEmails() { // Arrange - EmailVerificationRequestedApplicationEvent ae = new(Email, Endpoint); + EmailVerificationRequestedApplicationEvent @event = new(Email, Endpoint); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert email.Verify(x => x.SendVerificationEmailAsync(Email, Endpoint, ct), Times.Once()); diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordResetRequestedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordResetRequestedHandlerUnitTests.cs index 91397507a..97c480bc8 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordResetRequestedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordResetRequestedHandlerUnitTests.cs @@ -20,10 +20,10 @@ public PasswordResetRequestedHandlerUnitTests() public async Task Handle_ShouldSendEmails() { // Arrange - PasswordResetRequestedApplicationEvent ae = new(Email, Endpoint); + PasswordResetRequestedApplicationEvent @event = new(Email, Endpoint); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert email.Verify(x => x.SendForgotPasswordEmailAsync(Email, Endpoint, ct), Times.Once()); diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests copy.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandlerUnitTests.cs similarity index 90% rename from tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests copy.cs rename to tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandlerUnitTests.cs index c5cce1c77..2da252e3a 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests copy.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandlerUnitTests.cs @@ -20,13 +20,13 @@ public RoleCreatedHandlerUnitTests() public async Task Handle_ShouldCallService() { // Arrange - RoleCreatedApplicationEvent ae = new( + RoleCreatedApplicationEvent @event = new( Name: ValidRole, Description: string.Empty ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert service.Verify(x => x.CreateAsync(ValidRole), Times.Once()); diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests.cs index c9db1f10f..aafdd0127 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests.cs @@ -20,10 +20,10 @@ public RoleDeletedHandlerUnitTests() public async Task Handle_ShouldCallService() { // Arrange - RoleDeletedApplicationEvent ae = new(ValidRole); + RoleDeletedApplicationEvent @event = new(ValidRole); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert service.Verify(x => x.DeleteAsync(ValidRole), Times.Once()); diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/UserCreatedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountCreatedHandlerUnitTests.cs similarity index 66% rename from tests/UnitTests/Identity/Application/Users/Events/Application/Users/UserCreatedHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountCreatedHandlerUnitTests.cs index df008b5ff..ccf86ae5e 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/UserCreatedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountCreatedHandlerUnitTests.cs @@ -6,14 +6,14 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Use using static UsersData; -public class UserCreatedHandlerUnitTests : UsersBaseUnitTests +public class AccountCreatedHandlerUnitTests : UsersBaseUnitTests { - private readonly UserCreatedHandler handler; + private readonly AccountCreatedHandler handler; private readonly Mock service = new(); private readonly User user = CreateUser(); - public UserCreatedHandlerUnitTests() + public AccountCreatedHandlerUnitTests() { handler = new(service.Object); } @@ -22,7 +22,7 @@ public UserCreatedHandlerUnitTests() public async Task Handle_ShouldCallService() { // Arrange - AccountCreatedApplicationEvent ae = new( + AccountCreatedApplicationEvent @event = new( Id: user.AccountId, Role: user.Role, Username: user.Username, @@ -31,17 +31,17 @@ public async Task Handle_ShouldCallService() ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert service.Verify(x => x.CreateAsync( It.Is(x => - x.Role == ae.Role - && x.Username == ae.Username - && x.Email.Value == ae.Email - && x.AccountId == ae.Id + x.Role == @event.Role + && x.Username == @event.Username + && x.Email.Value == @event.Email + && x.AccountId == @event.Id ), - ae.Password + @event.Password ), Times.Once()); } } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/UserDeletedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountDeletedHandlerUnitTests.cs similarity index 69% rename from tests/UnitTests/Identity/Application/Users/Events/Application/Users/UserDeletedHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountDeletedHandlerUnitTests.cs index 3b3728fab..960cc2903 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/UserDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountDeletedHandlerUnitTests.cs @@ -6,12 +6,12 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Use using static UsersData; -public class UserDeletedHandlerUnitTests : UsersBaseUnitTests +public class AccountDeletedHandlerUnitTests : UsersBaseUnitTests { - private readonly UserDeletedHandler handler; + private readonly AccountDeletedHandler handler; private readonly Mock service = new(); - public UserDeletedHandlerUnitTests() + public AccountDeletedHandlerUnitTests() { handler = new(service.Object); } @@ -20,10 +20,10 @@ public UserDeletedHandlerUnitTests() public async Task Handle_ShouldCallService() { // Arrange - AccountDeletedApplicationEvent ae = new(ValidAccountId); + AccountDeletedApplicationEvent @event = new(ValidAccountId); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert service.Verify(x => x.DeleteAsync(ValidAccountId), Times.Once()); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequestedHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequestedHandlerUnitTests.cs index 7baa45927..ad092ba62 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequestedHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequestedHandlerUnitTests.cs @@ -43,7 +43,7 @@ public NotificationRequestedHandlerUnitTests() public async Task Handle_ShouldPersistToDatabase_WhenSingleReceiver() { // Arrange - NotificationRequestedEvent ae = new( + NotificationRequestedEvent @event = new( Type: NotificationType.Unkown, Description: MinValidDescription, Link: ValidLink, @@ -52,15 +52,15 @@ public async Task Handle_ShouldPersistToDatabase_WhenSingleReceiver() ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert writes.Verify(x => x.AddAsync( It.Is(x => - x.Type == ae.Type.ToString() - && x.Content == new NotificationContent(ae.Description, ae.Link) - && x.AuthorId == ae.AuthorId - && x.ReceiverId == ae.ReceiverIds.First() + x.Type == @event.Type.ToString() + && x.Content == new NotificationContent(@event.Description, @event.Link) + && x.AuthorId == @event.AuthorId + && x.ReceiverId == @event.ReceiverIds.First() ), ct ), Times.Once()); @@ -71,7 +71,7 @@ public async Task Handle_ShouldPersistToDatabase_WhenSingleReceiver() public async Task Handle_ShouldBulkInsert_WhenMultipleReceivers() { // Arrange - NotificationRequestedEvent ae = new( + NotificationRequestedEvent @event = new( Type: NotificationType.Unkown, Description: MinValidDescription, Link: ValidLink, @@ -80,7 +80,7 @@ public async Task Handle_ShouldBulkInsert_WhenMultipleReceivers() ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert uow.Verify(x => x.InsertNotificationsAsync( @@ -93,7 +93,7 @@ public async Task Handle_ShouldBulkInsert_WhenMultipleReceivers() public async Task Handle_ShouldSendRequests() { // Arrange - NotificationRequestedEvent ae = new( + NotificationRequestedEvent @event = new( Type: NotificationType.Unkown, Description: MinValidDescription, Link: ValidLink, @@ -102,7 +102,7 @@ public async Task Handle_ShouldSendRequests() ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert sender.Verify(x => x.SendQueryAsync( @@ -115,7 +115,7 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldNotifySubscribers() { // Arrange - NotificationRequestedEvent ae = new( + NotificationRequestedEvent @event = new( Type: NotificationType.Unkown, Description: MinValidDescription, Link: ValidLink, @@ -124,11 +124,11 @@ public async Task Handle_ShouldNotifySubscribers() ); // Act - await handler.HandleAsync(ae); + await handler.HandleAsync(@event); // Assert notifier.Verify(x => x.NotifyUsersAsync( - ae.ReceiverIds, + @event.ReceiverIds, It.IsAny(), It.IsAny(), ct From 29ab456499f50cb720a37689a3fa84fb5b67055b Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Wed, 20 May 2026 17:23:58 +0300 Subject: [PATCH 05/15] Normalized Entity SFMs and Unit Test Data setups --- .../Accounts/Domain/Accounts/Account.cs | 2 +- src/Modules/Accounts/Domain/Assembly.cs | 6 ++ src/Modules/Accounts/Domain/Roles/Role.cs | 2 +- src/Modules/Carts/Domain/Assembly.cs | 6 ++ .../Domain/PurchasedCarts/PurchasedCart.cs | 2 +- src/Modules/Catalog/Domain/Assembly.cs | 6 ++ .../Catalog/Domain/Categories/Category.cs | 2 +- .../Catalog/Domain/Products/Product.cs | 2 +- src/Modules/Catalog/Domain/Tags/Tag.cs | 2 +- src/Modules/Customs/Domain/Assembly.cs | 6 ++ src/Modules/Customs/Domain/Customs/Custom.cs | 2 +- src/Modules/Delivery/Domain/Assembly.cs | 6 ++ .../Delivery/Domain/Shipments/Shipment.cs | 2 +- src/Modules/Files/Domain/Assembly.cs | 6 ++ src/Modules/Files/Domain/Cads/Cad.cs | 2 +- src/Modules/Files/Domain/Images/Image.cs | 2 +- src/Modules/Idempotency/Domain/Assembly.cs | 6 ++ src/Modules/Identity/Domain/Assembly.cs | 6 ++ src/Modules/Identity/Domain/Users/User.cs | 2 +- src/Modules/Notifications/Domain/Assembly.cs | 6 ++ .../Domain/Notifications/Notification.cs | 2 +- src/Modules/Printing/Domain/Assembly.cs | 6 ++ .../Domain/Customizations/Customization.cs | 2 +- .../Printing/Domain/Materials/Material.cs | 2 +- .../Configurations/Materials/Utilities.cs | 10 +- .../Accounts/AccountsBaseUnitTests.cs | 16 --- ...ateAccountHandlerUnitTests.cs => Tests.cs} | 8 +- ...eteAccountHandlerUnitTests.cs => Tests.cs} | 14 +-- ...ateAccountHandlerUnitTests.cs => Tests.cs} | 11 +-- .../Tests.cs} | 8 +- .../Tests.cs} | 8 +- .../Tests.cs} | 6 +- ...llAccountsHandlerUnitTests.cs => Tests.cs} | 12 +-- ...ccountByIdHandlerUnitTests.cs => Tests.cs} | 8 +- ...ntSortingsHandlerUnitTests.cs => Tests.cs} | 2 +- .../{GetUserEmailByIdHandler.cs => Tests.cs} | 6 +- .../Tests.cs} | 8 +- .../Tests.cs} | 8 +- ...ByUsernameHandlerUnitTests.cs => Tests.cs} | 6 +- ...erRoleByIdHandlerUnitTests.cs => Tests.cs} | 8 +- .../Batch/Tests.cs} | 18 ++-- .../Tests.cs} | 8 +- .../Tests.cs} | 8 +- .../Tests.cs} | 8 +- ...CreateRoleHandlerUnitTests.cs => Tests.cs} | 8 +- ...DeleteRoleHandlerUnitTests.cs => Tests.cs} | 6 +- ...etAllRolesHandlerUnitTests.cs => Tests.cs} | 12 +-- ...etRoleByIdHandlerUnitTests.cs => Tests.cs} | 8 +- .../Application/Roles/RolesBaseUnitTests.cs | 15 --- .../Accounts/Data/Accounts/BaseUnitTests.cs | 14 +++ .../{AccountsData.cs => Accounts/TestData.cs} | 6 +- .../Accounts/Data/Roles/BaseUnitTests.cs | 21 ++++ .../Data/{RolesData.cs => Roles/TestData.cs} | 6 +- .../Domain/Accounts/AccountsBaseUnitTests.cs | 40 -------- .../Behaviors/Email/AccountEmailData.cs | 3 - ...ountEmailInvalidData.cs => InvalidData.cs} | 8 +- .../{AccountEmailUnitTests.cs => Tests.cs} | 13 ++- .../AccountEmailValidData.cs => ValidData.cs} | 8 +- .../FirstName/AccountFirstNameData.cs | 3 - .../Data/AccountFirstNameInvalidData.cs | 12 --- .../Data/AccountFirstNameValidData.cs | 12 --- .../Behaviors/FirstName/InvalidData.cs | 12 +++ ...{AccountFirstNameUnitTests.cs => Tests.cs} | 13 ++- .../Accounts/Behaviors/FirstName/ValidData.cs | 12 +++ .../Behaviors/LastName/AccountLastNameData.cs | 3 - .../LastName/AccountLastNameUnitTests.cs | 38 ------- .../Data/AccountLastNameInvalidData.cs | 12 --- .../LastName/Data/AccountLastNameValidData.cs | 12 --- .../Behaviors/LastName/InvalidData.cs | 12 +++ .../Accounts/Behaviors/LastName/Tests.cs | 37 +++++++ .../Accounts/Behaviors/LastName/ValidData.cs | 12 +++ .../AccountTrackViewedProductsValidData.cs | 10 -- ...ackViewedProductsUnitTests.cs => Tests.cs} | 6 +- .../TrackViewedProducts/ValidData.cs | 10 ++ .../Behaviors/Username/AccountUsernameData.cs | 3 - ...tUsernameInvalidData.cs => InvalidData.cs} | 8 +- .../{AccountUsernameUnitTests.cs => Tests.cs} | 13 ++- ...countUsernameValidData.cs => ValidData.cs} | 8 +- .../Accounts/Create/AccountCreateData.cs | 3 - .../Data/AccountCreateInvalidEmailData.cs | 13 --- .../Data/AccountCreateInvalidFirstNameData.cs | 12 --- .../Data/AccountCreateInvalidLastNameData.cs | 12 --- .../Data/AccountCreateInvalidRoleData.cs | 13 --- .../Data/AccountCreateInvalidUsernameData.cs | 13 --- .../Domain/Accounts/Create/InvalidData.cs | 33 +++++++ .../{AccountCreateUnitTests.cs => Tests.cs} | 23 ++--- ...AccountCreateValidData.cs => ValidData.cs} | 9 +- .../WithId/AccountCreateWithIdUnitTests.cs | 43 -------- .../Domain/Accounts/Create/WithId/Tests.cs | 40 ++++++++ ...oleCreateInvalidData.cs => InvalidData.cs} | 8 +- .../Description/RoleDescriptionData.cs | 3 - .../{RoleDescriptionUnitTests.cs => Tests.cs} | 14 +-- .../RoleCreateValidData.cs => ValidData.cs} | 8 +- .../RoleNameInvalidData.cs => InvalidData.cs} | 8 +- .../Roles/Behaviors/Name/RoleNameData.cs | 3 - .../Name/{RoleNameUnitTests.cs => Tests.cs} | 14 +-- .../RoleNameValidData.cs => ValidData.cs} | 8 +- .../Data/RoleCreateInvalidDescriptionData.cs | 13 --- .../Create/Data/RoleCreateInvalidNameData.cs | 13 --- .../Roles/Create/Data/RoleCreateValidData.cs | 13 --- .../Domain/Roles/Create/InvalidData.cs | 19 ++++ .../Create/Normal/RoleCreateUnitTests.cs | 44 --------- .../Domain/Roles/Create/Normal/Tests.cs | 35 +++++++ .../Domain/Roles/Create/RoleCreateData.cs | 3 - .../Accounts/Domain/Roles/Create/ValidData.cs | 13 +++ .../WithId/RoleCreateWithIdUnitTests.cs | 37 ------- .../Domain/Roles/Create/WithId/Tests.cs | 37 +++++++ .../Domain/Roles/RolesBaseUnitTests.cs | 25 ----- ...veCartItemHandlerUnitTests.cs => Tests.cs} | 19 ++-- ...AddActiveCartValidData.cs => ValidData.cs} | 8 +- ...ActiveCartHandlerUnitTests.cs => Tests.cs} | 6 +- ...yInvalidCityData.cs => InvalidCityData.cs} | 6 +- ...idCountryData.cs => InvalidCountryData.cs} | 6 +- ...nvalidEmailData.cs => InvalidEmailData.cs} | 6 +- ...nvalidPhoneData.cs => InvalidPhoneData.cs} | 6 +- ...eData.cs => InvalidShipmentServiceData.cs} | 6 +- .../PurchaseActiveCartWithDeliveryData.cs | 3 - ...thDeliveryHandlerUnitTests.cs => Tests.cs} | 6 +- .../Internal/Purchase/WithDelivery/Theory.cs | 3 + ...tWithDeliveryValidData.cs => ValidData.cs} | 6 +- ...veryValidatorUnitTests.cs => Validator.cs} | 27 +++-- ...emQuantityHandlerUnitTests.cs => Tests.cs} | 6 +- ...emQuantityHandlerUnitTests.cs => Tests.cs} | 6 +- ...veCartItemHandlerUnitTests.cs => Tests.cs} | 6 +- ...orDeliveryHandlerUnitTests.cs => Tests.cs} | 6 +- ...ationEventHandlerUnitTests.cs => Tests.cs} | 6 +- ...rtShipmentHandlerUnitTests.cs => Tests.cs} | 6 +- ...eCartItemsHandlerUnitTests.cs => Tests.cs} | 6 +- ...ActiveCartHandlerUnitTests.cs => Tests.cs} | 6 +- ...veCartItemHandlerUnitTests.cs => Tests.cs} | 6 +- ...chasedCartHandlerUnitTests.cs => Tests.cs} | 8 +- ...ationEventHandlerUnitTests.cs => Tests.cs} | 6 +- ...mpletedApplicationEventHandlerUnitTests.cs | 8 +- .../PurchasedCartsBaseUnitTests.cs | 60 ------------ ...hasedCartsHandlerUnitTests.cs => Tests.cs} | 6 +- ...dCartItemsHandlerUnitTests.cs => Tests.cs} | 6 +- ...AllPurchasedCartsUnitTests.cs => Tests.cs} | 10 +- ...PurchasedCartByIdUnitTests.cs => Tests.cs} | 8 +- ...ntStatusesHandlerUnitTests.cs => Tests.cs} | 2 +- ...rtSortingsHandlerUnitTests.cs => Tests.cs} | 2 +- .../ActiveCarts/BaseUnitTests.cs} | 9 +- .../TestData.cs} | 6 +- .../Data/PurchasedCarts/BaseUnitTests.cs | 98 +++++++++++++++++++ .../TestData.cs} | 6 +- .../ActiveCartItemsBaseUnitTests.cs | 28 ------ ...mDecreaseQuantityUnitTests.cs => Tests.cs} | 4 +- ...mIncreaseQuantityUnitTests.cs => Tests.cs} | 4 +- ...temSetForDeliveryUnitTests.cs => Tests.cs} | 4 +- ...ItemSetNoDeliveryUnitTests.cs => Tests.cs} | 2 +- ...iveCartItemCreateUnitTests.cs => Tests.cs} | 4 +- ...iveCartItemCreateUnitTests.cs => Tests.cs} | 4 +- ...hasedCartAddItemsUnitTests.cs => Tests.cs} | 8 +- ...CartSetShipmentIdUnitTests.cs => Tests.cs} | 8 +- ...rchasedCartCreateUnitTests.cs => Tests.cs} | 9 +- ...dCartCreateWithIdUnitTests.cs => Tests.cs} | 12 +-- .../PurchasedCartsBaseUnitTests.cs | 57 ----------- .../Categories/CategoriesBaseUnitTests.cs | 11 --- ...teCategoryHandlerUnitTests.cs => Tests.cs} | 6 +- ...teCategoryHandlerUnitTests.cs => Tests.cs} | 8 +- ...itCategoryHandlerUnitTests.cs => Tests.cs} | 6 +- ...CategoriesHandlerUnitTests.cs => Tests.cs} | 12 +-- ...tegoryByIdHandlerUnitTests.cs => Tests.cs} | 6 +- ...tegoryByIdHandlerUnitTests.cs => Tests.cs} | 8 +- ...tegoryByIdHandlerUnitTests.cs => Tests.cs} | 6 +- ...ExistsByIdHandlerUnitTests.cs => Tests.cs} | 6 +- ...oveProductHandlerUnitTests.cs => Tests.cs} | 6 +- ...ateProductHandlerUnitTests.cs => Tests.cs} | 8 +- ...eteProductHandlerUnitTests.cs => Tests.cs} | 8 +- ...ditProductHandlerUnitTests.cs => Tests.cs} | 8 +- ...ProductTagHandlerUnitTests.cs => Tests.cs} | 6 +- ...ProductTagHandlerUnitTests.cs => Tests.cs} | 6 +- ...ortProductHandlerUnitTests.cs => Tests.cs} | 6 +- ...ateProductHandlerUnitTests.cs => Tests.cs} | 6 +- .../Tests.cs} | 8 +- .../Tests.cs} | 6 +- .../Tests.cs} | 8 +- .../Products/ProductsBaseUnitTests.cs | 51 ---------- ...ductsCountHandlerUnitTests.cs => Tests.cs} | 6 +- ...llProductsHandlerUnitTests.cs => Tests.cs} | 6 +- ...roductByIdHandlerUnitTests.cs => Tests.cs} | 6 +- ...orSortingsHandlerUnitTests.cs => Tests.cs} | 2 +- ...llProductsHandlerUnitTests.cs => Tests.cs} | 6 +- ...roductByIdHandlerUnitTests.cs => Tests.cs} | 6 +- ...erSortingsHandlerUnitTests.cs => Tests.cs} | 2 +- ...llProductsHandlerUnitTests.cs => Tests.cs} | 6 +- ...roductByIdHandlerUnitTests.cs => Tests.cs} | 8 +- ...ctSortingsHandlerUnitTests.cs => Tests.cs} | 2 +- ...tCadIdByIdHandlerUnitTests.cs => Tests.cs} | 10 +- .../Tests.cs} | 12 +-- ...ExistsByIdHandlerUnitTests.cs => Tests.cs} | 4 +- ...{CreateTagHandlerUnitTests.cs => Tests.cs} | 6 +- ...{DeleteTagHandlerUnitTests.cs => Tests.cs} | 6 +- .../{EditTagHandlerUnitTests.cs => Tests.cs} | 6 +- ...{GetAllTagHandlerUnitTests.cs => Tests.cs} | 10 +- ...GetTagByIdHandlerUnitTests.cs => Tests.cs} | 6 +- .../Application/Tags/TagsBaseUnitTests.cs | 11 --- .../Catalog/Data/Categories/BaseUnitTests.cs | 14 +++ .../TestData.cs} | 6 +- .../Catalog/Data/Products/BaseUnitTests.cs | 35 +++++++ .../{ProductsData.cs => Products/TestData.cs} | 6 +- .../Catalog/Data/Tags/BaseUnitTests.cs | 14 +++ .../Data/{TagsData.cs => Tags/TestData.cs} | 6 +- .../Description/CategoryDescriptionData.cs | 3 - ...oryCreateInvalidData.cs => InvalidData.cs} | 8 +- ...tegoryDescriptionUnitTests.cs => Tests.cs} | 13 ++- ...ategoryCreateValidData.cs => ValidData.cs} | 8 +- .../Behaviors/Name/CategoryNameData.cs | 3 - ...gogryNameInvalidData.cs => InvalidData.cs} | 8 +- .../{CategoryNameUnitTests.cs => Tests.cs} | 18 ++-- .../CategoryNameValidData.cs => ValidData.cs} | 8 +- .../Categories/CategoriesBaseUnitTests.cs | 9 -- .../Categories/Create/CategoryCreateData.cs | 3 - .../CategoryCreateInvalidDescriptionData.cs | 13 --- .../Data/CategoryCreateInvalidNameData.cs | 13 --- .../Domain/Categories/Create/InvalidData.cs | 19 ++++ .../Domain/Categories/Create/Normal/Tests.cs | 34 +++++++ ...ategoryCreateValidData.cs => ValidData.cs} | 8 +- .../WithId/CategoryCreateWithIdUnitTests.cs | 36 ------- .../Tests.cs} | 14 ++- .../AddPurchase/AddProductPurchaseData.cs | 3 - .../Data/AddProductPurchaseValidData.cs | 12 --- ...ddProductPurchaseUnitTests.cs => Tests.cs} | 9 +- .../Counts/AddView/AddProductViewData.cs | 3 - .../AddView/Data/AddProductViewValidData.cs | 12 --- .../{AddProductViewUnitTests.cs => Tests.cs} | 9 +- ...ProductCategoryIdUnitTests.cs => Tests.cs} | 4 +- .../Data/SetProductDescriptionInvalidData.cs | 12 --- .../Data/SetProductDescriptionValidData.cs | 12 --- .../Behaviors/SetDescription/InvalidData.cs | 12 +++ .../SetProductDescriptionData.cs | 3 - ...roductDescriptionUnitTests.cs => Tests.cs} | 13 ++- .../Behaviors/SetDescription/ValidData.cs | 12 +++ .../SetName/Data/SetProductNameInvalidData.cs | 12 --- .../SetName/Data/SetProductNameValidData.cs | 12 --- .../Products/Behaviors/SetName/InvalidData.cs | 12 +++ .../Behaviors/SetName/SetProductNameData.cs | 3 - .../{SetProductNameUnitTests.cs => Tests.cs} | 13 ++- .../Products/Behaviors/SetName/ValidData.cs | 12 +++ .../Data/SetProductPriceInvalidData.cs | 12 --- .../SetPrice/Data/SetProductPriceValidData.cs | 12 --- .../Behaviors/SetPrice/InvalidData.cs | 12 +++ .../Behaviors/SetPrice/SetProductPriceData.cs | 3 - .../{SetProductPriceUnitTests.cs => Tests.cs} | 13 ++- .../Products/Behaviors/SetPrice/ValidData.cs | 12 +++ .../{ProductRemoveUnitTests.cs => Tests.cs} | 4 +- .../{ProductReportUnitTests.cs => Tests.cs} | 4 +- .../{ProductUncheckUnitTests.cs => Tests.cs} | 4 +- .../{ProductValidateUnitTests.cs => Tests.cs} | 4 +- .../Create/Data/CreateProductInvalidData.cs | 12 --- .../ProductCreateInvalidDescriptionData.cs | 12 --- .../Data/ProductCreateInvalidPriceData.cs | 12 --- .../Domain/Products/Create/InvalidData.cs | 21 ++++ .../Domain/Products/Create/Normal/Tests.cs | 63 ++++++++++++ .../Products/Create/ProductCreateData.cs | 3 - ...ProductCreateValidData.cs => ValidData.cs} | 8 +- .../WithId/ProductCreateWithIdUnitTests.cs | 57 ----------- .../Tests.cs} | 19 ++-- .../Domain/Products/ProductsBaseUnitTests.cs | 48 --------- ...etTagNameInvalidData.cs => InvalidData.cs} | 8 +- .../Tags/Behaviors/SetName/SetTagNameData.cs | 3 - .../{SetTagNameUnitTests.cs => Tests.cs} | 14 +-- .../SetTagNameValidData.cs => ValidData.cs} | 8 +- .../Create/Data/TagCreateInvalidNameData.cs | 12 --- .../Tags/Create/Data/TagCreateValidData.cs | 12 --- .../Catalog/Domain/Tags/Create/InvalidData.cs | 12 +++ .../{TagCreateUnitTests.cs => Tests.cs} | 20 ++-- .../Domain/Tags/Create/TagCreateData.cs | 3 - .../Catalog/Domain/Tags/Create/ValidData.cs | 12 +++ .../Create/WithId/TagCreateWithIdUnitTests.cs | 33 ------- .../Domain/Tags/Create/WithId/Tests.cs | 36 +++++++ .../Catalog/Domain/Tags/TagsBaseUnitTests.cs | 22 ----- ...moveCustomHandlerUnitTests.cs => Tests.cs} | 6 +- ...omCategoryHandlerUnitTests.cs => Tests.cs} | 6 +- ...eateCustomHandlerUnitTests.cs => Tests.cs} | 8 +- ...leteCustomHandlerUnitTests.cs => Tests.cs} | 8 +- ...EditCustomHandlerUnitTests.cs => Tests.cs} | 8 +- ...haseCustomHandlerUnitTests.cs => Tests.cs} | 6 +- ...yInvalidCityData.cs => InvalidCityData.cs} | 6 +- ...idCountryData.cs => InvalidCountryData.cs} | 6 +- ...nvalidEmailData.cs => InvalidEmailData.cs} | 6 +- ...nvalidPhoneData.cs => InvalidPhoneData.cs} | 6 +- ...eData.cs => InvalidShipmentServiceData.cs} | 6 +- .../PurchaseCustomWithDeliveryData.cs | 3 - ...thDeliveryHandlerUnitTests.cs => Tests.cs} | 12 +-- .../Customer/Purchase/WithDelivery/Theory.cs | 3 + ...mWithDeliveryValidData.cs => ValidData.cs} | 6 +- ...veryValidatorUnitTests.cs => Validator.cs} | 28 +++--- ...omDeliveryHandlerUnitTests.cs => Tests.cs} | 6 +- ...ceptCustomHandlerUnitTests.cs => Tests.cs} | 6 +- ...eginCustomHandlerUnitTests.cs => Tests.cs} | 6 +- ...ncelCustomHandlerUnitTests.cs => Tests.cs} | 6 +- ...nishCustomHandlerUnitTests.cs => Tests.cs} | 6 +- ...portCustomHandlerUnitTests.cs => Tests.cs} | 6 +- ...omCategoryHandlerUnitTests.cs => Tests.cs} | 6 +- .../Customs/CustomsBaseUnitTests.cs | 31 ------ ...ationEventHandlerUnitTests.cs => Tests.cs} | 8 +- ...ationEventHandlerUnitTests.cs => Tests.cs} | 8 +- ...omShipmentHandlerUnitTests.cs => Tests.cs} | 6 +- ...untCustomsHandlerUnitTests.cs => Tests.cs} | 6 +- ...CustomByIdHandlerUnitTests.cs => Tests.cs} | 8 +- ...CustomByIdHandlerUnitTests.cs => Tests.cs} | 8 +- ...AllPurchasedCartsUnitTests.cs => Tests.cs} | 10 +- ...ntStatusesHandlerUnitTests.cs => Tests.cs} | 2 +- ...omSortingsHandlerUnitTests.cs => Tests.cs} | 2 +- .../Customs/Application/GlobalUsings.cs | 1 - .../Customs/Data/Customs/BaseUnitTests.cs | 32 ++++++ .../{CustomsData.cs => Customs/TestData.cs} | 4 +- ...CustomSetCategoryUnitTests.cs => Tests.cs} | 50 +++++++++- .../SetDelivery/CustomSetNameData.cs | 3 - .../Data/CustomSetDeliveryValidData.cs | 10 -- ...CustomSetDeliveryUnitTests.cs => Tests.cs} | 13 ++- .../Behaviors/SetDelivery/ValidData.cs | 10 ++ .../CustomSetDescriptionData.cs | 3 - .../Data/CustomSetDescriptionInvalidData.cs | 12 --- .../Data/CustomSetDescriptionValidData.cs | 12 --- .../Behaviors/SetDescription/InvalidData.cs | 12 +++ ...tomSetDescriptionUnitTests.cs => Tests.cs} | 20 ++-- .../Behaviors/SetDescription/ValidData.cs | 12 +++ .../Behaviors/SetName/CustomSetNameData.cs | 3 - .../SetName/Data/CustomSetNameInvalidData.cs | 12 --- .../SetName/Data/CustomSetNameValidData.cs | 12 --- .../Customs/Behaviors/SetName/InvalidData.cs | 12 +++ .../{CustomSetNameUnitTests.cs => Tests.cs} | 14 +-- .../Customs/Behaviors/SetName/ValidData.cs | 12 +++ .../Tests.cs} | 6 +- .../Tests.cs} | 6 +- .../Tests.cs} | 6 +- .../Tests.cs} | 6 +- .../Tests.cs} | 6 +- .../Tests.cs} | 6 +- .../Tests.cs} | 6 +- .../Domain/Customs/Create/CustomCreateData.cs | 3 - .../CustomCreateInvalidDescriptionData.cs | 12 --- .../Data/CustomCreateInvalidNameData.cs | 12 --- .../Create/Data/CustomCreateValidData.cs | 12 --- .../Domain/Customs/Create/InvalidData.cs | 17 ++++ .../Domain/Customs/Create/Normal/Tests.cs | 42 ++++++++ .../Domain/Customs/Create/ValidData.cs | 12 +++ .../WithId/CustomCreateWitIdUnitTests.cs | 42 -------- .../Tests.cs} | 25 ++--- .../Domain/Customs/CustomsBaseUnitTests.cs | 73 -------------- .../UnitTests/Customs/Domain/GlobalUsings.cs | 2 - .../Delivery/Application/GlobalUsings.cs | 1 - ...elShipmentHandlerUnitTests.cs => Tests.cs} | 6 +- ...teShipmentHandlerUnitTests.cs => Tests.cs} | 8 +- ...lShipmentsHandlerUnitTests.cs => Tests.cs} | 4 +- ...ntSortingsHandlerUnitTests.cs => Tests.cs} | 2 +- ...pmentTrackHandlerUnitTests.cs => Tests.cs} | 16 ++- ...entWaybillHandlerUnitTests.cs => Tests.cs} | 6 +- .../InvalidData.cs} | 6 +- .../Tests.cs} | 6 +- .../Validator.cs} | 6 +- .../Shipments/ShipmentsBaseUnitTests.cs | 71 -------------- .../Delivery/Data/Shipments/BaseUnitTests.cs | 38 +++++++ .../TestData.cs} | 8 +- .../UnitTests/Delivery/Domain/GlobalUsings.cs | 1 - ...entCreateInvalidData.cs => InvalidData.cs} | 30 +++--- .../Tests.cs} | 43 ++++++-- .../Tests.cs} | 8 +- .../Shipments/ShipmentsBaseUnitTests.cs | 59 ----------- .../Application/Cads/CadsBaseUnitTests.cs | 16 --- ...{CreateCadHandlerUnitTests.cs => Tests.cs} | 8 +- .../{EditCadHandlerUnitTests.cs => Tests.cs} | 8 +- ...tCadCoordsHandlerUnitTests.cs => Tests.cs} | 8 +- ...ateCadByIdHandlerUnitTests.cs => Tests.cs} | 8 +- ...uctDeletedHandlerUnitTests.cs => Tests.cs} | 6 +- ...CadDownloadPolicyMock.cs => PolicyMock.cs} | 2 +- ...gnedUrlGetHandlerUnitTests.cs => Tests.cs} | 8 +- .../{CadUploadPolicyMock.cs => PolicyMock.cs} | 2 +- ...nedUrlPostHandlerUnitTests.cs => Tests.cs} | 8 +- ...{CadReplacePolicyMock.cs => PolicyMock.cs} | 2 +- ...gnedUrlPutHandlerUnitTests.cs => Tests.cs} | 8 +- ...ExistsByIdHandlerUnitTests.cs => Tests.cs} | 6 +- ...ExistsByIdHandlerUnitTests.cs => Tests.cs} | 6 +- .../Files/Application/GlobalUsings.cs | 1 - ...reateImageHandlerUnitTests.cs => Tests.cs} | 8 +- ...{EditImageHandlerUnitTests.cs => Tests.cs} | 8 +- ...uctDeletedHandlerUnitTests.cs => Tests.cs} | 6 +- .../Application/Images/ImagesBaseUnitTests.cs | 15 --- ...ageDownloadPolicyMock.cs => PolicyMock.cs} | 2 +- ...gnedUrlGetHandlerUnitTests.cs => Tests.cs} | 8 +- ...ImageUploadPolicyMock.cs => PolicyMock.cs} | 2 +- ...nedUrlPostHandlerUnitTests.cs => Tests.cs} | 8 +- ...mageReplacePolicyMock.cs => PolicyMock.cs} | 2 +- ...gnedUrlPutHandlerUnitTests.cs => Tests.cs} | 8 +- .../Files/Data/Cads/BaseUnitTests.cs | 32 ++++++ .../Data/{CadsData.cs => Cads/TestData.cs} | 4 +- .../Files/Data/Images/BaseUnitTests.cs | 25 +++++ .../{ImagesData.cs => Images/TestData.cs} | 4 +- ...CadCamCoordinatesUnitTests.cs => Tests.cs} | 4 +- .../{CadContentTypeUnitTests.cs => Tests.cs} | 4 +- ...CadPanCoordinatesUnitTests.cs => Tests.cs} | 4 +- .../{CadVolumeUnitTests.cs => Tests.cs} | 4 +- .../Files/Domain/Cads/CadsBaseUnitTests.cs | 46 --------- ...CadCreateInvalidData.cs => InvalidData.cs} | 8 +- .../Files/Domain/Cads/Create/Normal/Tests.cs | 38 +++++++ .../Create/WithId/CadCreateWithIdUnitTests.cs | 39 -------- .../CadCreateUnitTests.cs => WithId/Tests.cs} | 15 +-- tests/UnitTests/Files/Domain/GlobalUsings.cs | 1 - ...{ImageContentTypeUnitTests.cs => Tests.cs} | 4 +- .../Create/Data/ImageCreateInvalidData.cs | 15 --- .../Files/Domain/Images/Create/InvalidData.cs | 15 +++ .../{ImageCreateUnitTests.cs => Tests.cs} | 12 +-- .../WithId/ImageCreateWithIdUnitTests.cs | 34 ------- .../Domain/Images/Create/WithId/Tests.cs | 35 +++++++ .../Domain/Images/ImagesBaseUnitTests.cs | 15 --- .../Idempotency/Application/GlobalUsings.cs | 1 - .../BaseIdempotencyKeyUnitTests.cs | 24 ----- ...potencyKeyHandlerUnitTests.cs => Tests.cs} | 6 +- ...potencyKeyHandlerUnitTests.cs => Tests.cs} | 6 +- ...potencyKeyHandlerUnitTests.cs => Tests.cs} | 6 +- ...potencyKeyHandlerUnitTests.cs => Tests.cs} | 6 +- .../Data/IdempotencyKeys/BaseUnitTests.cs | 19 ++++ .../TestData.cs} | 4 +- .../Idempotency/Domain/GlobalUsings.cs | 1 - .../BaseIdempotencyKeyUnitTests.cs | 22 ----- ...eySetResponseBodyUnitTests.cs => Tests.cs} | 7 +- ...yKeySetStatusCodeUnitTests.cs => Tests.cs} | 7 +- ...KeyCreateInvalidData.cs => InvalidData.cs} | 8 +- ...mpotencyKeyCreateUnitTests.cs => Tests.cs} | 11 +-- .../Identity/Application/GlobalUsings.cs | 1 - ...geUsernameHandlerUnitTests.cs => Tests.cs} | 6 +- ...DeleteUserHandlerUnitTests.cs => Tests.cs} | 6 +- ...{LoginUserHandlerUnitTests.cs => Tests.cs} | 8 +- ...LogoutUserHandlerUnitTests.cs => Tests.cs} | 6 +- ...efreshUserHandlerUnitTests.cs => Tests.cs} | 6 +- ...gisterUserHandlerUnitTests.cs => Tests.cs} | 6 +- ...erPasswordHandlerUnitTests.cs => Tests.cs} | 6 +- ...swordEmailHandlerUnitTests.cs => Tests.cs} | 4 +- ...{SingleSignOnUserUnitTests.cs => Tests.cs} | 6 +- ...tsTrackingHandlerUnitTests.cs => Tests.cs} | 6 +- ...ationEmailHandlerUnitTests.cs => Tests.cs} | 4 +- ...yUserEmailHandlerUnitTests.cs => Tests.cs} | 10 +- .../Tests.cs} | 6 +- .../Tests.cs} | 6 +- .../Tests.cs} | 8 +- .../Tests.cs} | 8 +- .../Tests.cs} | 8 +- .../Tests.cs} | 8 +- ...ByUsernameHandlerUnitTests.cs => Tests.cs} | 8 +- ...ByUsernameHandlerUnitTests.cs => Tests.cs} | 4 +- .../Application/Users/UsersBaseUnitTests.cs | 40 -------- .../Identity/Data/Users/BaseUnitTests.cs | 30 ++++++ .../Data/{UsersData.cs => Users/TestData.cs} | 4 +- .../UnitTests/Identity/Domain/GlobalUsings.cs | 2 - ...erAddRefreshTokenUnitTests.cs => Tests.cs} | 2 +- ...emoveRefreshTokenUnitTests.cs => Tests.cs} | 4 +- .../Data/UserUsernameInvalidData.cs | 13 --- .../SetUsername/Data/UserUsernameValidData.cs | 12 --- .../Behaviors/SetUsername/InvalidData.cs | 13 +++ .../{UserUsernameUnitTests.cs => Tests.cs} | 14 +-- .../Behaviors/SetUsername/UserUsernameData.cs | 3 - .../Users/Behaviors/SetUsername/ValidData.cs | 12 +++ ...serCreateInvalidData.cs => InvalidData.cs} | 8 +- .../Domain/Users/Create/Normal/Tests.cs | 39 ++++++++ .../Tests.cs} | 14 +-- .../WithId/UserCreateWithIdUnitTests.cs | 36 ------- .../Domain/Users/UsersBaseUnitTests.cs | 37 ------- .../Notifications/Application/GlobalUsings.cs | 2 - .../Tests.cs} | 6 +- ...ificationsHandlerUnitTests.cs => Tests.cs} | 6 +- ...ificationsHandlerUnitTests.cs => Tests.cs} | 6 +- .../NotificationRequestedHandlerUnitTests.cs | 8 +- ...ificationsHandlerUnitTests.cs => Tests.cs} | 6 +- ...tificationHandlerUnitTests.cs => Tests.cs} | 10 +- ...onSortingsHandlerUnitTests.cs => Tests.cs} | 2 +- ...onStatusesHandlerUnitTests.cs => Tests.cs} | 2 +- .../Notifications/BaseUnitTests.cs} | 15 +-- .../TestData.cs} | 4 +- .../Notifications/Domain/GlobalUsings.cs | 1 - .../NotificationSetDescriptionInvalidData.cs | 12 --- .../NotificationSetDescriptionValidData.cs | 12 --- .../SetDescription/InvalidTestData.cs | 12 +++ .../NotificationSetDescriptionData.cs | 3 - ...ionSetDescriptionUnitTests.cs => Tests.cs} | 11 +-- .../Behaviors/SetDescription/ValidTestData.cs | 12 +++ .../Tests.cs} | 10 +- .../Tests.cs} | 22 ++--- .../Tests.cs} | 22 ++--- .../Tests.cs} | 22 ++--- ...otificationCreateInvalidDescriptionData.cs | 12 --- .../Data/NotificationCreateInvalidNameData.cs | 12 --- .../Data/NotificationCreateValidData.cs | 12 --- .../Notifications/Create/InvalidTestData.cs | 17 ++++ .../Notifications/Create/Normal/Tests.cs | 37 +++++++ .../Create/NotificationCreateData.cs | 3 - .../Notifications/Create/ValidTestData.cs | 12 +++ .../NotificationCreateWithIdUnitTests.cs | 39 -------- .../Tests.cs} | 20 ++-- .../NotificationsBaseUnitTests.cs | 37 ------- ...tomizationHandlerUnitTests.cs => Tests.cs} | 8 +- ...tomizationHandlerUnitTests.cs => Tests.cs} | 6 +- ...tomizationHandlerUnitTests.cs => Tests.cs} | 6 +- .../CustomizationsBaseUnitTests.cs | 54 ---------- ...zationByIdHandlerUnitTests.cs => Tests.cs} | 8 +- .../Tests.cs} | 8 +- .../Tests.cs} | 8 +- ...ExistsByIdHandlerUnitTests.cs => Tests.cs} | 6 +- .../Tests.cs} | 8 +- .../Tests.cs} | 8 +- .../Printing/Application/GlobalUsings.cs | 1 - ...teMaterialHandlerUnitTests.cs => Tests.cs} | 10 +- ...teMaterialHandlerUnitTests.cs => Tests.cs} | 6 +- ...itMaterialHandlerUnitTests.cs => Tests.cs} | 6 +- ...llMaterialHandlerUnitTests.cs => Tests.cs} | 4 +- ...terialByIdHandlerUnitTests.cs => Tests.cs} | 8 +- .../Data/Customizations/BaseUnitTests.cs | 37 +++++++ .../TestData.cs} | 4 +- .../Materials/BaseUnitTests.cs} | 27 ++--- .../TestData.cs} | 4 +- .../Data/CustomizationSetColorInvalidData.cs | 13 --- .../Behaviors/Color/TestData.cs | 13 +++ ...omizationSetColorUnitTests.cs => Tests.cs} | 6 +- .../Data/CustomizationSetInfillInvalidData.cs | 12 --- .../Behaviors/Infill/TestData.cs | 12 +++ ...mizationSetInfillUnitTests.cs => Tests.cs} | 6 +- ...tionSetMaterialIdUnitTests.cs => Tests.cs} | 4 +- .../Data/CustomizationSetScaleInvalidData.cs | 12 --- .../Behaviors/Scale/TestData.cs | 12 +++ ...omizationSetScaleUnitTests.cs => Tests.cs} | 6 +- .../CustomizationSetVolumeInvalidData.cs | 12 +++ .../Data/CustomizationSetVolumeInvalidData.cs | 12 --- ...mizationSetVolumeUnitTests.cs => Tests.cs} | 6 +- .../Customizations/Create/Normal/Tests.cs | 38 +++++++ ...zationCreateInvalidData.cs => TestData.cs} | 8 +- .../CustomizationCreateWithIdUnitTests.cs | 39 -------- .../Tests.cs} | 15 +-- .../CustomizationsBaseUnitTests.cs | 38 ------- .../UnitTests/Printing/Domain/GlobalUsings.cs | 1 - .../Cost/Data/MaterialSetCostInvalidData.cs | 12 --- .../Materials/Behaviors/Cost/TestData.cs | 12 +++ .../{MaterialSetCostUnitTests.cs => Tests.cs} | 6 +- .../Data/MaterialSetDensityInvalidData.cs | 12 --- .../Materials/Behaviors/Density/TestData.cs | 12 +++ ...aterialSetDensityUnitTests.cs => Tests.cs} | 6 +- ...erialSetNameInvalidData.cs => TestData.cs} | 8 +- .../{MaterialSetNameUnitTests.cs => Tests.cs} | 6 +- .../Domain/Materials/Create/Normal/Tests.cs | 37 +++++++ ...terialCreateInvalidData.cs => TestData.cs} | 8 +- .../Create/WithId/MaterialCreateUnitTests.cs | 39 -------- .../Tests.cs} | 15 +-- .../Materials/MaterialsBaseUnitTests.cs | 35 ------- .../Domain/Services/ServicesBaseUnitTests.cs | 3 + 543 files changed, 2858 insertions(+), 3527 deletions(-) create mode 100644 src/Modules/Accounts/Domain/Assembly.cs create mode 100644 src/Modules/Carts/Domain/Assembly.cs create mode 100644 src/Modules/Catalog/Domain/Assembly.cs create mode 100644 src/Modules/Customs/Domain/Assembly.cs create mode 100644 src/Modules/Delivery/Domain/Assembly.cs create mode 100644 src/Modules/Files/Domain/Assembly.cs create mode 100644 src/Modules/Idempotency/Domain/Assembly.cs create mode 100644 src/Modules/Identity/Domain/Assembly.cs create mode 100644 src/Modules/Notifications/Domain/Assembly.cs create mode 100644 src/Modules/Printing/Domain/Assembly.cs delete mode 100644 tests/UnitTests/Accounts/Application/Accounts/AccountsBaseUnitTests.cs rename tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/{CreateAccountHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/{DeleteAccountHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/{CreateAccountHandlerUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Accounts/Application/Accounts/Events/Application/{UserDeletedHandlerUnitTests.cs => Deleted/Tests.cs} (92%) rename tests/UnitTests/Accounts/Application/Accounts/Events/Application/{UserEditedHandlerUnitTests.cs => Edited/Tests.cs} (92%) rename tests/UnitTests/Accounts/Application/Accounts/Events/Application/{UserViewedProductHandlerUnitTests.cs => Viewed/Tests.cs} (89%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/{GetAllAccountsHandlerUnitTests.cs => Tests.cs} (81%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/{GetAccountByIdHandlerUnitTests.cs => Tests.cs} (87%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/{GetAccountSortingsHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/{GetUserEmailByIdHandler.cs => Tests.cs} (91%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/{GetAccountExistsByIdHandlerUnitTests.cs => ById/Tests.cs} (85%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/{GetAccountExistsByUsernameHandlerUnitTests.cs => ByUsername/Tests.cs} (85%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/{GetAccountInfoByUsernameHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/{GetUserRoleByIdHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/{GetUsernames/BatchGetUsernamesByIdHandlerUnitTests.cs => GetUsername/Batch/Tests.cs} (74%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/{GetUsernameByIdHandlerUnitTests.cs => Single/Tests.cs} (89%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/{GetAccountViewedProductHandlerUnitTests.cs => ById/Tests.cs} (87%) rename tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/{GetAccountViewedProductsByUsernameHandlerUnitTests.cs => ByName/Tests.cs} (86%) rename tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/{CreateRoleHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/{DeleteRoleHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/{GetAllRolesHandlerUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/{GetRoleByIdHandlerUnitTests.cs => Tests.cs} (86%) delete mode 100644 tests/UnitTests/Accounts/Application/Roles/RolesBaseUnitTests.cs create mode 100644 tests/UnitTests/Accounts/Data/Accounts/BaseUnitTests.cs rename tests/UnitTests/Accounts/Data/{AccountsData.cs => Accounts/TestData.cs} (92%) create mode 100644 tests/UnitTests/Accounts/Data/Roles/BaseUnitTests.cs rename tests/UnitTests/Accounts/Data/{RolesData.cs => Roles/TestData.cs} (89%) delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/AccountsBaseUnitTests.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/AccountEmailData.cs rename tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/{Data/AccountEmailInvalidData.cs => InvalidData.cs} (60%) rename tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/{AccountEmailUnitTests.cs => Tests.cs} (63%) rename tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/{Data/AccountEmailValidData.cs => ValidData.cs} (51%) delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/AccountFirstNameData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Data/AccountFirstNameInvalidData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Data/AccountFirstNameValidData.cs create mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/InvalidData.cs rename tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/{AccountFirstNameUnitTests.cs => Tests.cs} (64%) create mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/ValidData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/AccountLastNameData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/AccountLastNameUnitTests.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Data/AccountLastNameInvalidData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Data/AccountLastNameValidData.cs create mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/InvalidData.cs create mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Tests.cs create mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/ValidData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/Data/AccountTrackViewedProductsValidData.cs rename tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/{AccountTrackViewedProductsUnitTests.cs => Tests.cs} (70%) create mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/ValidData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/AccountUsernameData.cs rename tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/{Data/AccountUsernameInvalidData.cs => InvalidData.cs} (51%) rename tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/{AccountUsernameUnitTests.cs => Tests.cs} (64%) rename tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/{Data/AccountUsernameValidData.cs => ValidData.cs} (51%) delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Create/AccountCreateData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidEmailData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidFirstNameData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidLastNameData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidRoleData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidUsernameData.cs create mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Create/InvalidData.cs rename tests/UnitTests/Accounts/Domain/Accounts/Create/Normal/{AccountCreateUnitTests.cs => Tests.cs} (52%) rename tests/UnitTests/Accounts/Domain/Accounts/Create/{Data/AccountCreateValidData.cs => ValidData.cs} (66%) delete mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Create/WithId/AccountCreateWithIdUnitTests.cs create mode 100644 tests/UnitTests/Accounts/Domain/Accounts/Create/WithId/Tests.cs rename tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/{Data/RoleCreateInvalidData.cs => InvalidData.cs} (55%) delete mode 100644 tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/RoleDescriptionData.cs rename tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/{RoleDescriptionUnitTests.cs => Tests.cs} (70%) rename tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/{Data/RoleCreateValidData.cs => ValidData.cs} (54%) rename tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/{Data/RoleNameInvalidData.cs => InvalidData.cs} (55%) delete mode 100644 tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/RoleNameData.cs rename tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/{RoleNameUnitTests.cs => Tests.cs} (67%) rename tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/{Data/RoleNameValidData.cs => ValidData.cs} (55%) delete mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateInvalidDescriptionData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateInvalidNameData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateValidData.cs create mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/InvalidData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/Normal/RoleCreateUnitTests.cs create mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/Normal/Tests.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/RoleCreateData.cs create mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/ValidData.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/WithId/RoleCreateWithIdUnitTests.cs create mode 100644 tests/UnitTests/Accounts/Domain/Roles/Create/WithId/Tests.cs delete mode 100644 tests/UnitTests/Accounts/Domain/Roles/RolesBaseUnitTests.cs rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/{AddActiveCartItemHandlerUnitTests.cs => Tests.cs} (90%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/{Data/AddActiveCartValidData.cs => ValidData.cs} (52%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/{PurchaseActiveCartHandlerUnitTests.cs => Tests.cs} (97%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/{Data/PurchaseActiveCartWithDeliveryInvalidCityData.cs => InvalidCityData.cs} (60%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/{Data/PurchaseActiveCartWithDeliveryInvalidCountryData.cs => InvalidCountryData.cs} (59%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/{Data/PurchaseActiveCartWithDeliveryInvalidEmailData.cs => InvalidEmailData.cs} (72%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/{Data/PurchaseActiveCartWithDeliveryInvalidPhoneData.cs => InvalidPhoneData.cs} (61%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/{Data/PurchaseActiveCartWithDeliveryInvalidShipmentServiceData.cs => InvalidShipmentServiceData.cs} (55%) delete mode 100644 tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryData.cs rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/{PurchaseActiveCartWithDeliveryHandlerUnitTests.cs => Tests.cs} (97%) create mode 100644 tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Theory.cs rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/{Data/PurchaseActiveCartWithDeliveryValidData.cs => ValidData.cs} (61%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/{PurchaseActiveCartWithDeliveryValidatorUnitTests.cs => Validator.cs} (83%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/{DecreaseActiveCartItemQuantityHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/{IncreaseActiveCartItemQuantityHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/{RemoveActiveCartItemHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/{ToggleActiveCartItemForDeliveryHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/{ProductDeletedApplicationEventHandlerUnitTests.cs => Tests.cs} (81%) rename tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/{CalculateActiveCartShipmentHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/{CountActiveCartItemsHandlerUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/{GetActiveCartHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/{GetActiveCartItemHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/{CreatePurchasedCartHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/{ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests.cs => Tests.cs} (93%) delete mode 100644 tests/UnitTests/Carts/Application/PurchasedCarts/PurchasedCartsBaseUnitTests.cs rename tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/{CountPurchasedCartsHandlerUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/{CountPurchasedCartItemsHandlerUnitTests.cs => Tests.cs} (87%) rename tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/{GetAllPurchasedCartsUnitTests.cs => Tests.cs} (87%) rename tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/{GetPurchasedCartByIdUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/{GetPurchasedCartPaymentStatusesHandlerUnitTests.cs => Tests.cs} (87%) rename tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/{GetPurchasedCartSortingsHandlerUnitTests.cs => Tests.cs} (87%) rename tests/UnitTests/Carts/{Application/ActiveCarts/ActiveCartsBaseUnitTests.cs => Data/ActiveCarts/BaseUnitTests.cs} (77%) rename tests/UnitTests/Carts/Data/{ActiveCartsData.cs => ActiveCarts/TestData.cs} (82%) create mode 100644 tests/UnitTests/Carts/Data/PurchasedCarts/BaseUnitTests.cs rename tests/UnitTests/Carts/Data/{PurchasedCartsData.cs => PurchasedCarts/TestData.cs} (89%) delete mode 100644 tests/UnitTests/Carts/Domain/ActiveCarts/ActiveCartItemsBaseUnitTests.cs rename tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/DecreaseQuantity/{ActiveCartItemDecreaseQuantityUnitTests.cs => Tests.cs} (89%) rename tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/IncreaseQuantity/{ActiveCartItemIncreaseQuantityUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetForDelivery/{ActiveCartItemSetForDeliveryUnitTests.cs => Tests.cs} (81%) rename tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetNoDelivery/{ActiveCartItemSetNoDeliveryUnitTests.cs => Tests.cs} (80%) rename tests/UnitTests/Carts/Domain/ActiveCarts/Create/ForDelivery/{ActiveCartItemCreateUnitTests.cs => Tests.cs} (87%) rename tests/UnitTests/Carts/Domain/ActiveCarts/Create/NoDelivery/{ActiveCartItemCreateUnitTests.cs => Tests.cs} (84%) rename tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/AddItems/{PurchasedCartAddItemsUnitTests.cs => Tests.cs} (81%) rename tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/ShipmentId/{PurchasedCartSetShipmentIdUnitTests.cs => Tests.cs} (82%) rename tests/UnitTests/Carts/Domain/PurchasedCarts/Create/Normal/{PurchasedCartCreateUnitTests.cs => Tests.cs} (62%) rename tests/UnitTests/Carts/Domain/PurchasedCarts/Create/WithId/{PurchasedCartCreateWithIdUnitTests.cs => Tests.cs} (53%) delete mode 100644 tests/UnitTests/Carts/Domain/PurchasedCarts/PurchasedCartsBaseUnitTests.cs delete mode 100644 tests/UnitTests/Catalog/Application/Categories/CategoriesBaseUnitTests.cs rename tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/{CreateCategoryHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/{DeleteCategoryHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/{EditCategoryHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/{GetAllCategoriesHandlerUnitTests.cs => Tests.cs} (78%) rename tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/{GetCategoryByIdHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/{BatchGetCategoryByIdHandlerUnitTests.cs => Tests.cs} (87%) rename tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/{GetCategoryByIdHandlerUnitTests.cs => Tests.cs} (89%) rename tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/{GetCategoryExistsByIdHandlerUnitTests.cs => Tests.cs} (87%) rename tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/{RemoveProductHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/{CreateProductHandlerUnitTests.cs => Tests.cs} (97%) rename tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/{DeleteProductHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/{EditProductHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/{AddProductTagHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/{RemoveProductTagHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/{ReportProductHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/{ValidateProductHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Catalog/Application/Products/Events/Application/{ProductCreatedHandlerUnitTests.cs => Created/Tests.cs} (85%) rename tests/UnitTests/Catalog/Application/Products/Events/Application/{ProductsPurchasedHandlerUnitTests.cs => Purchased/Tests.cs} (84%) rename tests/UnitTests/Catalog/Application/Products/Events/Application/{ProductViewedHandlerUnitTests.cs => Viewed/Tests.cs} (97%) delete mode 100644 tests/UnitTests/Catalog/Application/Products/ProductsBaseUnitTests.cs rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/{ProductsCountHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/{CreatorGetAllProductsHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/{CreatorGetProductByIdHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/{GetProductCreatorSortingsHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/{DesignerGetAllProductsHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/{DesignerGetProductByIdHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/{GetProductDesignerSortingsHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/{GalleryGetAllProductsHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/{GalleryGetProductByIdHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/{GetProductSortingsHandlerUnitTests.cs => Tests.cs} (89%) rename tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/{BatchGetProductCadIdByIdHandlerUnitTests.cs => Tests.cs} (81%) rename tests/UnitTests/Catalog/Application/Products/Queries/Shared/{BatchPricesById/BatchGetProductPriceByIdHandlerUnitTests.cs => BatchPriceById/Tests.cs} (79%) rename tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/{GetProductExistsByIdHandlerUnitTests.cs => Tests.cs} (90%) rename tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/{CreateTagHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/{DeleteTagHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/{EditTagHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/{GetAllTagHandlerUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/{GetTagByIdHandlerUnitTests.cs => Tests.cs} (90%) delete mode 100644 tests/UnitTests/Catalog/Application/Tags/TagsBaseUnitTests.cs create mode 100644 tests/UnitTests/Catalog/Data/Categories/BaseUnitTests.cs rename tests/UnitTests/Catalog/Data/{CategoriesData.cs => Categories/TestData.cs} (88%) create mode 100644 tests/UnitTests/Catalog/Data/Products/BaseUnitTests.cs rename tests/UnitTests/Catalog/Data/{ProductsData.cs => Products/TestData.cs} (91%) create mode 100644 tests/UnitTests/Catalog/Data/Tags/BaseUnitTests.cs rename tests/UnitTests/Catalog/Data/{TagsData.cs => Tags/TestData.cs} (79%) delete mode 100644 tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/CategoryDescriptionData.cs rename tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/{Data/CategoryCreateInvalidData.cs => InvalidData.cs} (51%) rename tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/{CategoryDescriptionUnitTests.cs => Tests.cs} (66%) rename tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/{Data/CategoryCreateValidData.cs => ValidData.cs} (51%) delete mode 100644 tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/CategoryNameData.cs rename tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/{Data/CategogryNameInvalidData.cs => InvalidData.cs} (50%) rename tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/{CategoryNameUnitTests.cs => Tests.cs} (61%) rename tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/{Data/CategoryNameValidData.cs => ValidData.cs} (50%) delete mode 100644 tests/UnitTests/Catalog/Domain/Categories/CategoriesBaseUnitTests.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Categories/Create/CategoryCreateData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateInvalidDescriptionData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateInvalidNameData.cs create mode 100644 tests/UnitTests/Catalog/Domain/Categories/Create/InvalidData.cs create mode 100644 tests/UnitTests/Catalog/Domain/Categories/Create/Normal/Tests.cs rename tests/UnitTests/Catalog/Domain/Categories/Create/{Data/CategoryCreateValidData.cs => ValidData.cs} (60%) delete mode 100644 tests/UnitTests/Catalog/Domain/Categories/Create/WithId/CategoryCreateWithIdUnitTests.cs rename tests/UnitTests/Catalog/Domain/Categories/Create/{Normal/CategoryCreateUnitTests.cs => WithId/Tests.cs} (62%) delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/AddProductPurchaseData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/Data/AddProductPurchaseValidData.cs rename tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/{AddProductPurchaseUnitTests.cs => Tests.cs} (78%) delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/AddProductViewData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/Data/AddProductViewValidData.cs rename tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/{AddProductViewUnitTests.cs => Tests.cs} (78%) rename tests/UnitTests/Catalog/Domain/Products/Behaviors/SetCategoryId/{SetProductCategoryIdUnitTests.cs => Tests.cs} (81%) delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Data/SetProductDescriptionInvalidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Data/SetProductDescriptionValidData.cs create mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/InvalidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/SetProductDescriptionData.cs rename tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/{SetProductDescriptionUnitTests.cs => Tests.cs} (62%) create mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/ValidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Data/SetProductNameInvalidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Data/SetProductNameValidData.cs create mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/InvalidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/SetProductNameData.cs rename tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/{SetProductNameUnitTests.cs => Tests.cs} (59%) create mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/ValidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Data/SetProductPriceInvalidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Data/SetProductPriceValidData.cs create mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/InvalidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/SetProductPriceData.cs rename tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/{SetProductPriceUnitTests.cs => Tests.cs} (60%) create mode 100644 tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/ValidData.cs rename tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Removed/{ProductRemoveUnitTests.cs => Tests.cs} (89%) rename tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Reported/{ProductReportUnitTests.cs => Tests.cs} (89%) rename tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Unchecked/{ProductUncheckUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Validated/{ProductValidateUnitTests.cs => Tests.cs} (89%) delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Create/Data/CreateProductInvalidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateInvalidDescriptionData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateInvalidPriceData.cs create mode 100644 tests/UnitTests/Catalog/Domain/Products/Create/InvalidData.cs create mode 100644 tests/UnitTests/Catalog/Domain/Products/Create/Normal/Tests.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Create/ProductCreateData.cs rename tests/UnitTests/Catalog/Domain/Products/Create/{Data/ProductCreateValidData.cs => ValidData.cs} (60%) delete mode 100644 tests/UnitTests/Catalog/Domain/Products/Create/WithId/ProductCreateWithIdUnitTests.cs rename tests/UnitTests/Catalog/Domain/Products/Create/{Normal/ProductCreateUnitTests.cs => WithId/Tests.cs} (72%) delete mode 100644 tests/UnitTests/Catalog/Domain/Products/ProductsBaseUnitTests.cs rename tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/{Data/SetTagNameInvalidData.cs => InvalidData.cs} (50%) delete mode 100644 tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/SetTagNameData.cs rename tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/{SetTagNameUnitTests.cs => Tests.cs} (65%) rename tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/{Data/SetTagNameValidData.cs => ValidData.cs} (50%) delete mode 100644 tests/UnitTests/Catalog/Domain/Tags/Create/Data/TagCreateInvalidNameData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Tags/Create/Data/TagCreateValidData.cs create mode 100644 tests/UnitTests/Catalog/Domain/Tags/Create/InvalidData.cs rename tests/UnitTests/Catalog/Domain/Tags/Create/Normal/{TagCreateUnitTests.cs => Tests.cs} (55%) delete mode 100644 tests/UnitTests/Catalog/Domain/Tags/Create/TagCreateData.cs create mode 100644 tests/UnitTests/Catalog/Domain/Tags/Create/ValidData.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Tags/Create/WithId/TagCreateWithIdUnitTests.cs create mode 100644 tests/UnitTests/Catalog/Domain/Tags/Create/WithId/Tests.cs delete mode 100644 tests/UnitTests/Catalog/Domain/Tags/TagsBaseUnitTests.cs rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/{RemoveCustomHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/{AdminSetCustomCategoryHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/{CreateCustomHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/{DeleteCustomHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/{EditCustomHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/{PurchaseCustomHandlerUnitTests.cs => Tests.cs} (97%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/{Data/PurchaseCustomWithDeliveryInvalidCityData.cs => InvalidCityData.cs} (61%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/{Data/PurchaseCustomWithDeliveryInvalidCountryData.cs => InvalidCountryData.cs} (60%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/{Data/PurchaseCustomWithDeliveryInvalidEmailData.cs => InvalidEmailData.cs} (72%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/{Data/PurchaseCustomWithDeliveryInvalidPhoneData.cs => InvalidPhoneData.cs} (61%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/{Data/PurchaseCustomWithDeliveryInvalidShipmentServiceData.cs => InvalidShipmentServiceData.cs} (56%) delete mode 100644 tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryData.cs rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/{PurchaseCustomWithDeliveryHandlerUnitTests.cs => Tests.cs} (96%) create mode 100644 tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Theory.cs rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/{Data/PurchaseCustomWithDeliveryValidData.cs => ValidData.cs} (62%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/{PurchaseCustomWithDeliveryValidatorUnitTests.cs => Validator.cs} (86%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/{SetCustomDeliveryHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/{AcceptCustomHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/{BeginCustomHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/{CancelCustomHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/{FinishCustomHandlerUnitTests.cs => Tests.cs} (97%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/{ReportCustomHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/{DesignerSetCustomCategoryHandlerUnitTests.cs => Tests.cs} (95%) delete mode 100644 tests/UnitTests/Customs/Application/Customs/CustomsBaseUnitTests.cs rename tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/{CustomDeliveryRequestedApplicationEventHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/{CustomPaymentCompletedApplicationEventHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/{CalculateCustomShipmentHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/{CountCustomsHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/{CustomerGetCustomByIdHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/{DesignerGetCustomByIdHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/{GetAllPurchasedCartsUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/{GetCustomPaymentStatusesHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/{GetCustomSortingsHandlerUnitTests.cs => Tests.cs} (89%) create mode 100644 tests/UnitTests/Customs/Data/Customs/BaseUnitTests.cs rename tests/UnitTests/Customs/Data/{CustomsData.cs => Customs/TestData.cs} (95%) rename tests/UnitTests/Customs/Domain/Customs/Behaviors/SetCategory/{CustomSetCategoryUnitTests.cs => Tests.cs} (74%) delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/CustomSetNameData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/Data/CustomSetDeliveryValidData.cs rename tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/{CustomSetDeliveryUnitTests.cs => Tests.cs} (63%) create mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/ValidData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/CustomSetDescriptionData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Data/CustomSetDescriptionInvalidData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Data/CustomSetDescriptionValidData.cs create mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/InvalidData.cs rename tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/{CustomSetDescriptionUnitTests.cs => Tests.cs} (53%) create mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/ValidData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/CustomSetNameData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Data/CustomSetNameInvalidData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Data/CustomSetNameValidData.cs create mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/InvalidData.cs rename tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/{CustomSetNameUnitTests.cs => Tests.cs} (64%) create mode 100644 tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/ValidData.cs rename tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/{CustomAcceptUnitTests.cs => Accept/Tests.cs} (95%) rename tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/{CustomBeginUnitTests.cs => Begin/Tests.cs} (94%) rename tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/{CustomCancelUnitTests.cs => Cancel/Tests.cs} (95%) rename tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/{CustomCompleteUnitTests.cs => Complete/Tests.cs} (95%) rename tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/{CustomFinishUnitTests.cs => Finish/Tests.cs} (96%) rename tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/{CustomRemoveUnitTests.cs => Remove/Tests.cs} (93%) rename tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/{CustomReportUnitTests.cs => Report/Tests.cs} (95%) delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Create/CustomCreateData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateInvalidDescriptionData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateInvalidNameData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateValidData.cs create mode 100644 tests/UnitTests/Customs/Domain/Customs/Create/InvalidData.cs create mode 100644 tests/UnitTests/Customs/Domain/Customs/Create/Normal/Tests.cs create mode 100644 tests/UnitTests/Customs/Domain/Customs/Create/ValidData.cs delete mode 100644 tests/UnitTests/Customs/Domain/Customs/Create/WithId/CustomCreateWitIdUnitTests.cs rename tests/UnitTests/Customs/Domain/Customs/Create/{Normal/CustomCreateUnitTests.cs => WithId/Tests.cs} (58%) delete mode 100644 tests/UnitTests/Customs/Domain/Customs/CustomsBaseUnitTests.cs rename tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/{CancelShipmentHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/{CreateShipmentHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/{GetAllShipmentsHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/{GetShipmentSortingsHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/{GetShipmentTrackHandlerUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/{GetShipmentWaybillHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/{Data/CalculateShipmentInvalidData.cs => Calculate/InvalidData.cs} (72%) rename tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/{CalculateShipmentHandlerUnitTests.cs => Calculate/Tests.cs} (93%) rename tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/{CalculateShipmentValidatorUnitTests.cs => Calculate/Validator.cs} (88%) delete mode 100644 tests/UnitTests/Delivery/Application/Shipments/ShipmentsBaseUnitTests.cs create mode 100644 tests/UnitTests/Delivery/Data/Shipments/BaseUnitTests.cs rename tests/UnitTests/Delivery/Data/{ShipmentsData.cs => Shipments/TestData.cs} (87%) rename tests/UnitTests/Delivery/Domain/Shipments/Create/{Data/ShipmentCreateInvalidData.cs => InvalidData.cs} (89%) rename tests/UnitTests/Delivery/Domain/Shipments/Create/{WithId/ShipmentCreateWithIdUnitTestss.cs => Normal/Tests.cs} (52%) rename tests/UnitTests/Delivery/Domain/Shipments/Create/{Normal/ShipmentCreateUnitTests.cs => WithId/Tests.cs} (89%) delete mode 100644 tests/UnitTests/Delivery/Domain/Shipments/ShipmentsBaseUnitTests.cs delete mode 100644 tests/UnitTests/Files/Application/Cads/CadsBaseUnitTests.cs rename tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/{CreateCadHandlerUnitTests.cs => Tests.cs} (90%) rename tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/{EditCadHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/{SetCadCoordsHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/{BatchDuplicateCadByIdHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Files/Application/Cads/Events/Application/{ProductDeletedHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/{CadDownloadPolicyMock.cs => PolicyMock.cs} (82%) rename tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/{GetCadPresignedUrlGetHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/{CadUploadPolicyMock.cs => PolicyMock.cs} (83%) rename tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/{GetCadPresignedUrlPostHandlerUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/{CadReplacePolicyMock.cs => PolicyMock.cs} (83%) rename tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/{GetCadPresignedUrlPutHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/{GetCadExistsByIdHandlerUnitTests.cs => Tests.cs} (89%) rename tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/{GetCadExistsByIdHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Files/Application/Images/Commands/Internal/Create/{CreateImageHandlerUnitTests.cs => Tests.cs} (90%) rename tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/{EditImageHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Files/Application/Images/Events/Application/{ProductDeletedHandlerUnitTests.cs => Tests.cs} (95%) delete mode 100644 tests/UnitTests/Files/Application/Images/ImagesBaseUnitTests.cs rename tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/{ImageDownloadPolicyMock.cs => PolicyMock.cs} (82%) rename tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/{GetImagePresignedUrlGetHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/{ImageUploadPolicyMock.cs => PolicyMock.cs} (82%) rename tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/{GetImagePresignedUrlPostHandlerUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/{ImageReplacePolicyMock.cs => PolicyMock.cs} (82%) rename tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/{GetImagePresignedUrlPutHandlerUnitTests.cs => Tests.cs} (91%) create mode 100644 tests/UnitTests/Files/Data/Cads/BaseUnitTests.cs rename tests/UnitTests/Files/Data/{CadsData.cs => Cads/TestData.cs} (94%) create mode 100644 tests/UnitTests/Files/Data/Images/BaseUnitTests.cs rename tests/UnitTests/Files/Data/{ImagesData.cs => Images/TestData.cs} (85%) rename tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/{CadCamCoordinatesUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Files/Domain/Cads/Behaviors/ContentType/{CadContentTypeUnitTests.cs => Tests.cs} (89%) rename tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/{CadPanCoordinatesUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Files/Domain/Cads/Behaviors/Volume/{CadVolumeUnitTests.cs => Tests.cs} (88%) delete mode 100644 tests/UnitTests/Files/Domain/Cads/CadsBaseUnitTests.cs rename tests/UnitTests/Files/Domain/Cads/Create/{Data/CadCreateInvalidData.cs => InvalidData.cs} (76%) create mode 100644 tests/UnitTests/Files/Domain/Cads/Create/Normal/Tests.cs delete mode 100644 tests/UnitTests/Files/Domain/Cads/Create/WithId/CadCreateWithIdUnitTests.cs rename tests/UnitTests/Files/Domain/Cads/Create/{Normal/CadCreateUnitTests.cs => WithId/Tests.cs} (70%) rename tests/UnitTests/Files/Domain/Images/Behaviors/ContentType/{ImageContentTypeUnitTests.cs => Tests.cs} (89%) delete mode 100644 tests/UnitTests/Files/Domain/Images/Create/Data/ImageCreateInvalidData.cs create mode 100644 tests/UnitTests/Files/Domain/Images/Create/InvalidData.cs rename tests/UnitTests/Files/Domain/Images/Create/Normal/{ImageCreateUnitTests.cs => Tests.cs} (65%) delete mode 100644 tests/UnitTests/Files/Domain/Images/Create/WithId/ImageCreateWithIdUnitTests.cs create mode 100644 tests/UnitTests/Files/Domain/Images/Create/WithId/Tests.cs delete mode 100644 tests/UnitTests/Files/Domain/Images/ImagesBaseUnitTests.cs delete mode 100644 tests/UnitTests/Idempotency/Application/IdempotencyKeys/BaseIdempotencyKeyUnitTests.cs rename tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/{CompleteIdempotencyKeyHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/{CreateIdempotencyKeyHandlerUnitTests.cs => Tests.cs} (90%) rename tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/{DeleteIdempotencyKeyHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/{GetIdempotencyKeyHandlerUnitTests.cs => Tests.cs} (93%) create mode 100644 tests/UnitTests/Idempotency/Data/IdempotencyKeys/BaseUnitTests.cs rename tests/UnitTests/Idempotency/Data/{IdempotencyKeysData.cs => IdempotencyKeys/TestData.cs} (89%) delete mode 100644 tests/UnitTests/Idempotency/Domain/IdempotencyKeys/BaseIdempotencyKeyUnitTests.cs rename tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetResponseBody/{IdempotencyKeySetResponseBodyUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetStatusCode/{IdempotencyKeySetStatusCodeUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/{Data/IdempotencyKeyCreateInvalidData.cs => InvalidData.cs} (56%) rename tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/{IdempotencyKeyCreateUnitTests.cs => Tests.cs} (75%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/{ChangeUsernameHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/{DeleteUserHandlerUnitTests.cs => Tests.cs} (90%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/{LoginUserHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/{LogoutUserHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/{RefreshUserHandlerUnitTests.cs => Tests.cs} (96%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/{RegisterUserHandlerUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/{ResetUserPasswordHandlerUnitTests.cs => Tests.cs} (86%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/{ResetUserPasswordEmailHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/{SingleSignOnUserUnitTests.cs => Tests.cs} (97%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/{ToggleViewedProductsTrackingHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/{VerificationEmailHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/{VerifyUserEmailHandlerUnitTests.cs => Tests.cs} (90%) rename tests/UnitTests/Identity/Application/Users/Events/Application/Emails/{EmailVerificationRequestedHandlerUnitTests.cs => EmailVerification/Tests.cs} (83%) rename tests/UnitTests/Identity/Application/Users/Events/Application/Emails/{PasswordResetRequestedHandlerUnitTests.cs => PasswordReset/Tests.cs} (84%) rename tests/UnitTests/Identity/Application/Users/Events/Application/Roles/{RoleCreatedHandlerUnitTests.cs => Created/Tests.cs} (82%) rename tests/UnitTests/Identity/Application/Users/Events/Application/Roles/{RoleDeletedHandlerUnitTests.cs => Deleted/Tests.cs} (82%) rename tests/UnitTests/Identity/Application/Users/Events/Application/Users/{AccountCreatedHandlerUnitTests.cs => Created/Tests.cs} (87%) rename tests/UnitTests/Identity/Application/Users/Events/Application/Users/{AccountDeletedHandlerUnitTests.cs => Deleted/Tests.cs} (81%) rename tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/{GetUserByUsernameHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/{GetUserByUsernameHandlerUnitTests.cs => Tests.cs} (90%) delete mode 100644 tests/UnitTests/Identity/Application/Users/UsersBaseUnitTests.cs create mode 100644 tests/UnitTests/Identity/Data/Users/BaseUnitTests.cs rename tests/UnitTests/Identity/Data/{UsersData.cs => Users/TestData.cs} (94%) rename tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/{UserAddRefreshTokenUnitTests.cs => Tests.cs} (95%) rename tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/{UserRemoveRefreshTokenUnitTests.cs => Tests.cs} (88%) delete mode 100644 tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Data/UserUsernameInvalidData.cs delete mode 100644 tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Data/UserUsernameValidData.cs create mode 100644 tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/InvalidData.cs rename tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/{UserUsernameUnitTests.cs => Tests.cs} (67%) delete mode 100644 tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/UserUsernameData.cs create mode 100644 tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/ValidData.cs rename tests/UnitTests/Identity/Domain/Users/Create/{Data/UserCreateInvalidData.cs => InvalidData.cs} (60%) create mode 100644 tests/UnitTests/Identity/Domain/Users/Create/Normal/Tests.cs rename tests/UnitTests/Identity/Domain/Users/Create/{Normal/UserCreateUnitTests.cs => WithId/Tests.cs} (65%) delete mode 100644 tests/UnitTests/Identity/Domain/Users/Create/WithId/UserCreateWithIdUnitTests.cs delete mode 100644 tests/UnitTests/Identity/Domain/Users/UsersBaseUnitTests.cs rename tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/{Open copy/HideNotificationsHandlerUnitTests.cs => Hide/Tests.cs} (93%) rename tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/{OpenNotificationsHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/{ReadNotificationsHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Notifications/Application/Notifications/Events/{ => NotificationRequested}/NotificationRequestedHandlerUnitTests.cs (95%) rename tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/{CountNotificationsHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/{GetAllNotificationHandlerUnitTests.cs => Tests.cs} (90%) rename tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/{GetNotificationSortingsHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/{GetNotificationStatusesHandlerUnitTests.cs => Tests.cs} (88%) rename tests/UnitTests/Notifications/{Application/Notifications/NotificationsBaseUnitTests.cs => Data/Notifications/BaseUnitTests.cs} (63%) rename tests/UnitTests/Notifications/Data/{NotificationsData.cs => Notifications/TestData.cs} (93%) delete mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Data/NotificationSetDescriptionInvalidData.cs delete mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Data/NotificationSetDescriptionValidData.cs create mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/InvalidTestData.cs delete mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/NotificationSetDescriptionData.cs rename tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/{NotificationSetDescriptionUnitTests.cs => Tests.cs} (74%) create mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/ValidTestData.cs rename tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/{NotificationHideUnitTests.cs => Hide/Tests.cs} (83%) rename tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/{NotificationOpenUnitTests.cs => Open/Tests.cs} (64%) rename tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/{NotificationReadUnitTests.cs => Read/Tests.cs} (64%) rename tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/{NotificationUnhideUnitTests.cs => Unhide/Tests.cs} (64%) delete mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateInvalidDescriptionData.cs delete mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateInvalidNameData.cs delete mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateValidData.cs create mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Create/InvalidTestData.cs create mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Create/Normal/Tests.cs delete mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Create/NotificationCreateData.cs create mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Create/ValidTestData.cs delete mode 100644 tests/UnitTests/Notifications/Domain/Notifications/Create/WithId/NotificationCreateWithIdUnitTests.cs rename tests/UnitTests/Notifications/Domain/Notifications/Create/{Normal/NotificationCreateUnitTests.cs => WithId/Tests.cs} (60%) delete mode 100644 tests/UnitTests/Notifications/Domain/Notifications/NotificationsBaseUnitTests.cs rename tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/{CreateCustomizationHandlerUnitTests.cs => Tests.cs} (89%) rename tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/{DeleteCustomizationHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/{EditCustomizationHandlerUnitTests.cs => Tests.cs} (93%) delete mode 100644 tests/UnitTests/Printing/Application/Customizations/CustomizationsBaseUnitTests.cs rename tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/{GetCustomizationByIdHandlerUnitTests.cs => Tests.cs} (94%) rename tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/{BatchGetCustomizationCostByIdHandlerUnitTests.cs => Batch/Tests.cs} (92%) rename tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/{GetCustomizationCostByIdHandlerUnitTests.cs => Single/Tests.cs} (93%) rename tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/{GetCustomizationExistsByIdHandlerUnitTests.cs => Tests.cs} (87%) rename tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/{BatchGetCustomizationWeightByIdHandlerUnitTests.cs => Batch/Tests.cs} (92%) rename tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/{GetCustomizationWeightByIdHandlerUnitTests.cs => Single/Tests.cs} (93%) rename tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/{CreateMaterialHandlerUnitTests.cs => Tests.cs} (91%) rename tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/{DeleteMaterialHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/{EditMaterialHandlerUnitTests.cs => Tests.cs} (93%) rename tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/{GetAllMaterialHandlerUnitTests.cs => Tests.cs} (92%) rename tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/{GetMaterialByIdHandlerUnitTests.cs => Tests.cs} (85%) create mode 100644 tests/UnitTests/Printing/Data/Customizations/BaseUnitTests.cs rename tests/UnitTests/Printing/Data/{CustomizationsData.cs => Customizations/TestData.cs} (92%) rename tests/UnitTests/Printing/{Application/Materials/MaterialsBaseUnitTests.cs => Data/Materials/BaseUnitTests.cs} (56%) rename tests/UnitTests/Printing/Data/{MaterialsData.cs => Materials/TestData.cs} (92%) delete mode 100644 tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/Data/CustomizationSetColorInvalidData.cs create mode 100644 tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/TestData.cs rename tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/{CustomizationSetColorUnitTests.cs => Tests.cs} (81%) delete mode 100644 tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/Data/CustomizationSetInfillInvalidData.cs create mode 100644 tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/TestData.cs rename tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/{CustomizationSetInfillUnitTests.cs => Tests.cs} (81%) rename tests/UnitTests/Printing/Domain/Customizations/Behaviors/MaterialId/{CustomizationSetMaterialIdUnitTests.cs => Tests.cs} (81%) delete mode 100644 tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/Data/CustomizationSetScaleInvalidData.cs create mode 100644 tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/TestData.cs rename tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/{CustomizationSetScaleUnitTests.cs => Tests.cs} (81%) create mode 100644 tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/CustomizationSetVolumeInvalidData.cs delete mode 100644 tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/Data/CustomizationSetVolumeInvalidData.cs rename tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/{CustomizationSetVolumeUnitTests.cs => Tests.cs} (81%) create mode 100644 tests/UnitTests/Printing/Domain/Customizations/Create/Normal/Tests.cs rename tests/UnitTests/Printing/Domain/Customizations/Create/{Data/CustomizationCreateInvalidData.cs => TestData.cs} (80%) delete mode 100644 tests/UnitTests/Printing/Domain/Customizations/Create/WithId/CustomizationCreateWithIdUnitTests.cs rename tests/UnitTests/Printing/Domain/Customizations/Create/{Normal/CustomizationCreateUnitTests.cs => WithId/Tests.cs} (67%) delete mode 100644 tests/UnitTests/Printing/Domain/Customizations/CustomizationsBaseUnitTests.cs delete mode 100644 tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/Data/MaterialSetCostInvalidData.cs create mode 100644 tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/TestData.cs rename tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/{MaterialSetCostUnitTests.cs => Tests.cs} (82%) delete mode 100644 tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/Data/MaterialSetDensityInvalidData.cs create mode 100644 tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/TestData.cs rename tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/{MaterialSetDensityUnitTests.cs => Tests.cs} (82%) rename tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/{Data/MaterialSetNameInvalidData.cs => TestData.cs} (50%) rename tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/{MaterialSetNameUnitTests.cs => Tests.cs} (82%) create mode 100644 tests/UnitTests/Printing/Domain/Materials/Create/Normal/Tests.cs rename tests/UnitTests/Printing/Domain/Materials/Create/{Data/MaterialCreateInvalidData.cs => TestData.cs} (66%) delete mode 100644 tests/UnitTests/Printing/Domain/Materials/Create/WithId/MaterialCreateUnitTests.cs rename tests/UnitTests/Printing/Domain/Materials/Create/{Normal/MaterialCreateUnitTests.cs => WithId/Tests.cs} (70%) delete mode 100644 tests/UnitTests/Printing/Domain/Materials/MaterialsBaseUnitTests.cs diff --git a/src/Modules/Accounts/Domain/Accounts/Account.cs b/src/Modules/Accounts/Domain/Accounts/Account.cs index 55793c84d..8eb3b758a 100644 --- a/src/Modules/Accounts/Domain/Accounts/Account.cs +++ b/src/Modules/Accounts/Domain/Accounts/Account.cs @@ -51,7 +51,7 @@ public static Account Create( .ValidateFirstName() .ValidateLastName(); - public static Account CreateWithId( + internal static Account CreateWithId( AccountId id, string role, string username, diff --git a/src/Modules/Accounts/Domain/Assembly.cs b/src/Modules/Accounts/Domain/Assembly.cs new file mode 100644 index 000000000..7b47aecaa --- /dev/null +++ b/src/Modules/Accounts/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Accounts.Persistence"), + InternalsVisibleTo("UnitTests.Accounts.Data"), +] diff --git a/src/Modules/Accounts/Domain/Roles/Role.cs b/src/Modules/Accounts/Domain/Roles/Role.cs index 9c05653f2..62d1c6645 100644 --- a/src/Modules/Accounts/Domain/Roles/Role.cs +++ b/src/Modules/Accounts/Domain/Roles/Role.cs @@ -20,7 +20,7 @@ public static Role Create(string name, string description) .ValidateName() .ValidateDescription(); - public static Role CreateWithId(RoleId id, string name, string description) + internal static Role CreateWithId(RoleId id, string name, string description) => new Role(name, description) { Id = id diff --git a/src/Modules/Carts/Domain/Assembly.cs b/src/Modules/Carts/Domain/Assembly.cs new file mode 100644 index 000000000..c80491032 --- /dev/null +++ b/src/Modules/Carts/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Carts.Persistence"), + InternalsVisibleTo("UnitTests.Carts.Data"), +] diff --git a/src/Modules/Carts/Domain/PurchasedCarts/PurchasedCart.cs b/src/Modules/Carts/Domain/PurchasedCarts/PurchasedCart.cs index c6aeb1ccc..f9b7d6c28 100644 --- a/src/Modules/Carts/Domain/PurchasedCarts/PurchasedCart.cs +++ b/src/Modules/Carts/Domain/PurchasedCarts/PurchasedCart.cs @@ -31,7 +31,7 @@ private PurchasedCart(AccountId buyerId) : this() public static PurchasedCart Create(AccountId buyerId) => new(buyerId); - public static PurchasedCart CreateWithId(PurchasedCartId id, AccountId buyerId) + internal static PurchasedCart CreateWithId(PurchasedCartId id, AccountId buyerId) => new PurchasedCart(buyerId) { Id = id diff --git a/src/Modules/Catalog/Domain/Assembly.cs b/src/Modules/Catalog/Domain/Assembly.cs new file mode 100644 index 000000000..3614f2e1c --- /dev/null +++ b/src/Modules/Catalog/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Catalog.Persistence"), + InternalsVisibleTo("UnitTests.Catalog.Data"), +] diff --git a/src/Modules/Catalog/Domain/Categories/Category.cs b/src/Modules/Catalog/Domain/Categories/Category.cs index 44b93a6d4..056ec7eaf 100644 --- a/src/Modules/Catalog/Domain/Categories/Category.cs +++ b/src/Modules/Catalog/Domain/Categories/Category.cs @@ -20,7 +20,7 @@ public static Category Create(string name, string description) .ValidateName() .ValidateDescription(); - public static Category CreateWithId(CategoryId id, string name, string description) + internal static Category CreateWithId(CategoryId id, string name, string description) => new Category(name, description) { Id = id diff --git a/src/Modules/Catalog/Domain/Products/Product.cs b/src/Modules/Catalog/Domain/Products/Product.cs index afedb2dd9..276138e97 100644 --- a/src/Modules/Catalog/Domain/Products/Product.cs +++ b/src/Modules/Catalog/Domain/Products/Product.cs @@ -56,7 +56,7 @@ CadId cadId .ValidateDescription() .ValidatePrice(); - public static Product CreateWithId( + internal static Product CreateWithId( string name, string description, decimal price, diff --git a/src/Modules/Catalog/Domain/Tags/Tag.cs b/src/Modules/Catalog/Domain/Tags/Tag.cs index 2e370a3f0..c2587ffd8 100644 --- a/src/Modules/Catalog/Domain/Tags/Tag.cs +++ b/src/Modules/Catalog/Domain/Tags/Tag.cs @@ -17,7 +17,7 @@ public static Tag Create(string name) => new Tag(name) .ValidateName(); - public static Tag CreateWithId(TagId? id, string name) + internal static Tag CreateWithId(TagId? id, string name) => new Tag(name) { Id = id ?? TagId.New() diff --git a/src/Modules/Customs/Domain/Assembly.cs b/src/Modules/Customs/Domain/Assembly.cs new file mode 100644 index 000000000..c3b37a383 --- /dev/null +++ b/src/Modules/Customs/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Customs.Persistence"), + InternalsVisibleTo("UnitTests.Customs.Data"), +] diff --git a/src/Modules/Customs/Domain/Customs/Custom.cs b/src/Modules/Customs/Domain/Customs/Custom.cs index d47465757..3adcb2e27 100644 --- a/src/Modules/Customs/Domain/Customs/Custom.cs +++ b/src/Modules/Customs/Domain/Customs/Custom.cs @@ -56,7 +56,7 @@ public static Custom Create( .ValidateName() .ValidateDescription(); - public static Custom CreateWithId( + internal static Custom CreateWithId( CustomId id, string name, string description, diff --git a/src/Modules/Delivery/Domain/Assembly.cs b/src/Modules/Delivery/Domain/Assembly.cs new file mode 100644 index 000000000..e4afe4018 --- /dev/null +++ b/src/Modules/Delivery/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Delivery.Persistence"), + InternalsVisibleTo("UnitTests.Delivery.Data"), +] diff --git a/src/Modules/Delivery/Domain/Shipments/Shipment.cs b/src/Modules/Delivery/Domain/Shipments/Shipment.cs index 5e5398201..38cae0cda 100644 --- a/src/Modules/Delivery/Domain/Shipments/Shipment.cs +++ b/src/Modules/Delivery/Domain/Shipments/Shipment.cs @@ -62,7 +62,7 @@ string street .ValidateCity() .ValidateStreet(); - public static Shipment CreateWithId( + internal static Shipment CreateWithId( ShipmentId id, AccountId buyerId, string service, diff --git a/src/Modules/Files/Domain/Assembly.cs b/src/Modules/Files/Domain/Assembly.cs new file mode 100644 index 000000000..8232d40de --- /dev/null +++ b/src/Modules/Files/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Files.Persistence"), + InternalsVisibleTo("UnitTests.Files.Data"), +] diff --git a/src/Modules/Files/Domain/Cads/Cad.cs b/src/Modules/Files/Domain/Cads/Cad.cs index 3554b476b..ef2f924ce 100644 --- a/src/Modules/Files/Domain/Cads/Cad.cs +++ b/src/Modules/Files/Domain/Cads/Cad.cs @@ -46,7 +46,7 @@ AccountId ownerId .ValidateCamCoordinates() .ValidatePanCoordinates(); - public static Cad CreateWithId( + internal static Cad CreateWithId( CadId id, string key, string contentType, diff --git a/src/Modules/Files/Domain/Images/Image.cs b/src/Modules/Files/Domain/Images/Image.cs index 96b41f6a4..d101c0ede 100644 --- a/src/Modules/Files/Domain/Images/Image.cs +++ b/src/Modules/Files/Domain/Images/Image.cs @@ -27,7 +27,7 @@ public static Image Create(string key, string contentType, AccountId ownerId) .ValidateKey() .ValidateContentType(); - public static Image CreateWithId(ImageId id, string key, string contentType, AccountId ownerId) + internal static Image CreateWithId(ImageId id, string key, string contentType, AccountId ownerId) => new Image(key, contentType, ownerId) { Id = id } .ValidateKey() .ValidateContentType(); diff --git a/src/Modules/Idempotency/Domain/Assembly.cs b/src/Modules/Idempotency/Domain/Assembly.cs new file mode 100644 index 000000000..80a1d9b96 --- /dev/null +++ b/src/Modules/Idempotency/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Idempotency.Persistence"), + InternalsVisibleTo("UnitTests.Idempotency.Data"), +] diff --git a/src/Modules/Identity/Domain/Assembly.cs b/src/Modules/Identity/Domain/Assembly.cs new file mode 100644 index 000000000..a016dff80 --- /dev/null +++ b/src/Modules/Identity/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Identity.Infrastructure"), + InternalsVisibleTo("UnitTests.Identity.Data"), +] diff --git a/src/Modules/Identity/Domain/Users/User.cs b/src/Modules/Identity/Domain/Users/User.cs index 0782242fd..26b8af69e 100644 --- a/src/Modules/Identity/Domain/Users/User.cs +++ b/src/Modules/Identity/Domain/Users/User.cs @@ -37,7 +37,7 @@ public static User Create(string role, string username, Email email, AccountId a .ValidateUsername() .ValidateEmail(); - public static User Create(UserId id, string role, string username, Email email, AccountId accountId, ICollection refreshTokens) + internal static User Create(UserId id, string role, string username, Email email, AccountId accountId, ICollection refreshTokens) => new User(role, username, email, accountId) { Id = id, diff --git a/src/Modules/Notifications/Domain/Assembly.cs b/src/Modules/Notifications/Domain/Assembly.cs new file mode 100644 index 000000000..e910cc7dd --- /dev/null +++ b/src/Modules/Notifications/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Notifications.Persistence"), + InternalsVisibleTo("UnitTests.Notifications.Data"), +] diff --git a/src/Modules/Notifications/Domain/Notifications/Notification.cs b/src/Modules/Notifications/Domain/Notifications/Notification.cs index 18607862c..9d402c9a9 100644 --- a/src/Modules/Notifications/Domain/Notifications/Notification.cs +++ b/src/Modules/Notifications/Domain/Notifications/Notification.cs @@ -58,7 +58,7 @@ AccountId[] receiverIds return notifications; } - public static Notification Create( + internal static Notification Create( NotificationId id, string type, NotificationContent content, diff --git a/src/Modules/Printing/Domain/Assembly.cs b/src/Modules/Printing/Domain/Assembly.cs new file mode 100644 index 000000000..e235b0ae3 --- /dev/null +++ b/src/Modules/Printing/Domain/Assembly.cs @@ -0,0 +1,6 @@ +using System.Runtime.CompilerServices; + +[assembly: + InternalsVisibleTo("Modules.Printing.Persistence"), + InternalsVisibleTo("UnitTests.Printing.Data"), +] diff --git a/src/Modules/Printing/Domain/Customizations/Customization.cs b/src/Modules/Printing/Domain/Customizations/Customization.cs index 982b48b55..493f35185 100644 --- a/src/Modules/Printing/Domain/Customizations/Customization.cs +++ b/src/Modules/Printing/Domain/Customizations/Customization.cs @@ -45,7 +45,7 @@ MaterialId materialId .ValidateVolume() .ValidateColor(); - public static Customization CreateWithId( + internal static Customization Create( CustomizationId id, decimal scale, decimal infill, diff --git a/src/Modules/Printing/Domain/Materials/Material.cs b/src/Modules/Printing/Domain/Materials/Material.cs index 6d614ec1d..6d3bfefbb 100644 --- a/src/Modules/Printing/Domain/Materials/Material.cs +++ b/src/Modules/Printing/Domain/Materials/Material.cs @@ -40,7 +40,7 @@ ImageId textureId .ValidateDensity() .ValidateCost(); - public static Material CreateWithId( + internal static Material Create( MaterialId id, string name, decimal density, diff --git a/src/Modules/Printing/Persistence/Configurations/Materials/Utilities.cs b/src/Modules/Printing/Persistence/Configurations/Materials/Utilities.cs index fae9bbc19..717781133 100644 --- a/src/Modules/Printing/Persistence/Configurations/Materials/Utilities.cs +++ b/src/Modules/Printing/Persistence/Configurations/Materials/Utilities.cs @@ -67,11 +67,11 @@ internal EntityTypeBuilder SetValidations() internal EntityTypeBuilder SetSeeding() { builder.HasData([ - Material.CreateWithId(MaterialId.New(1), "PLA", 1.24m, 30m, PLA), - Material.CreateWithId(MaterialId.New(2), "ABS", 1.04m, 30m, ABS), - Material.CreateWithId(MaterialId.New(3), "Glow in dark", 1.25m, 30m, GlowInDark), - Material.CreateWithId(MaterialId.New(4), "TUF", 1.27m, 30m, TUF), - Material.CreateWithId(MaterialId.New(5), "Wood", 1.23m, 30m, Wood), + Material.Create(MaterialId.New(1), "PLA", 1.24m, 30m, PLA), + Material.Create(MaterialId.New(2), "ABS", 1.04m, 30m, ABS), + Material.Create(MaterialId.New(3), "Glow in dark", 1.25m, 30m, GlowInDark), + Material.Create(MaterialId.New(4), "TUF", 1.27m, 30m, TUF), + Material.Create(MaterialId.New(5), "Wood", 1.23m, 30m, Wood), ]); return builder; diff --git a/tests/UnitTests/Accounts/Application/Accounts/AccountsBaseUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/AccountsBaseUnitTests.cs deleted file mode 100644 index f497bdcf6..000000000 --- a/tests/UnitTests/Accounts/Application/Accounts/AccountsBaseUnitTests.cs +++ /dev/null @@ -1,16 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Accounts; - -namespace CustomCADs.UnitTests.Accounts.Application.Accounts; - -using static AccountsData; - -public class AccountsBaseUnitTests -{ - public static readonly CancellationToken ct = CancellationToken.None; - - protected static Account CreateAccount(string? role = null, string username = ValidUsername, string email = ValidEmail1, string? firstName = ValidFirstName, string? lastName = ValidLastName) - => Account.Create(role ?? RolesData.ValidName, username, email, firstName, lastName); - - protected static Account CreateAccountWithId(AccountId? id = null, string? role = null, string username = ValidUsername, string email = ValidEmail1, DateTimeOffset? createdAt = null, string? firstName = ValidFirstName, string? lastName = ValidLastName) - => Account.CreateWithId(id ?? ValidId, role ?? RolesData.ValidName, username, email, createdAt ?? DateTimeOffset.UtcNow, firstName, lastName); -} diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/CreateAccountHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs similarity index 93% rename from tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/CreateAccountHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs index 29a13a445..c52ef98de 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/CreateAccountHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs @@ -7,16 +7,16 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Commands.Internal.Create; -using static AccountsData; +using static Data.Accounts.TestData; -public class CreateAccountHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly CreateAccountHandler handler; private readonly Mock writes = new(); private readonly Mock uow = new(); private readonly Mock raiser = new(); - public CreateAccountHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, raiser.Object); @@ -29,7 +29,7 @@ public CreateAccountHandlerUnitTests() && x.LastName == ValidLastName ), ct - )).ReturnsAsync(CreateAccountWithId(id: ValidId)); + )).ReturnsAsync(CreateAccount(id: ValidId)); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/DeleteAccountHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs similarity index 92% rename from tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/DeleteAccountHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs index 3d902cb21..f644da8d5 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/DeleteAccountHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs @@ -1,16 +1,16 @@ using CustomCADs.Modules.Accounts.Application.Accounts.Commands.Internal.Delete; using CustomCADs.Modules.Accounts.Domain.Repositories; using CustomCADs.Modules.Accounts.Domain.Repositories.Reads; - -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Commands.Internal.Delete; - using CustomCADs.Modules.Accounts.Domain.Repositories.Writes; using CustomCADs.Shared.Application.Abstractions.Events; using CustomCADs.Shared.Application.Events.Account.Accounts; using CustomCADs.Shared.Application.Exceptions; -using static AccountsData; -public class DeleteAccountHandlerUnitTests : AccountsBaseUnitTests +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Commands.Internal.Delete; + +using static Data.Accounts.TestData; + +public class Tests : Data.Accounts.BaseUnitTests { private readonly DeleteAccountHandler handler; private readonly Mock raiser = new(); @@ -18,12 +18,12 @@ public class DeleteAccountHandlerUnitTests : AccountsBaseUnitTests private readonly Mock writes = new(); private readonly Mock reads = new(); - public DeleteAccountHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, raiser.Object); reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) - .ReturnsAsync(CreateAccountWithId()); + .ReturnsAsync(CreateAccount()); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/CreateAccountHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs similarity index 86% rename from tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/CreateAccountHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs index b10fd1526..dc65323a3 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/CreateAccountHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs @@ -4,18 +4,17 @@ using CustomCADs.Shared.Application.UseCases.Accounts.Commands; using CustomCADs.Shared.Domain.TypedIds.Accounts; -using static CustomCADs.UnitTests.Accounts.Data.AccountsData; -using static CustomCADs.Shared.Domain.DomainConstants; - namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Commands.Shared.Create; -public class CreateAccountHandlerUnitTests : AccountsBaseUnitTests +using static Data.Accounts.TestData; + +public class Tests : Data.Accounts.BaseUnitTests { private readonly CreateAccountHandler handler; private readonly Mock writes = new(); private readonly Mock uow = new(); - public CreateAccountHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object); @@ -28,7 +27,7 @@ public CreateAccountHandlerUnitTests() && x.LastName == ValidLastName ), ct - )).ReturnsAsync(CreateAccountWithId(id: ValidId)); + )).ReturnsAsync(CreateAccount(id: ValidId)); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserDeletedHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs similarity index 92% rename from tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserDeletedHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs index 95e88027c..c92002ff6 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs @@ -5,11 +5,11 @@ using CustomCADs.Shared.Application.Events.Identity; using CustomCADs.Shared.Application.Exceptions; -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application; +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application.Deleted; -using static AccountsData; +using static Data.Accounts.TestData; -public class UserDeletedHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly UserDeletedHandler handler; private readonly Mock reads = new(); @@ -18,7 +18,7 @@ public class UserDeletedHandlerUnitTests : AccountsBaseUnitTests private readonly Account account = CreateAccount(); - public UserDeletedHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserEditedHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs similarity index 92% rename from tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserEditedHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs index c13bc385d..8a24f021e 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserEditedHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs @@ -4,17 +4,17 @@ using CustomCADs.Shared.Application.Events.Identity; using CustomCADs.Shared.Application.Exceptions; -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application; +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application.Edited; -using static AccountsData; +using static Data.Accounts.TestData; -public class UserEditedHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly UserEditedHandler handler; private readonly Mock reads = new(); private readonly Mock uow = new(); - public UserEditedHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserViewedProductHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs similarity index 89% rename from tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserViewedProductHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs index 0e4677ebf..8da640e37 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/UserViewedProductHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs @@ -5,9 +5,9 @@ using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application; +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application.Viewed; -public class UserViewedProductHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly UserViewedProductHandler handler; private readonly Mock writes = new(); @@ -17,7 +17,7 @@ public class UserViewedProductHandlerUnitTests : AccountsBaseUnitTests private static readonly ProductId productId = ProductId.New(); private static readonly DateTimeOffset viewedAt = DateTimeOffset.UtcNow; - public UserViewedProductHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object); } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/GetAllAccountsHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs similarity index 81% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/GetAllAccountsHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs index 6eb9987f7..6841449b2 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/GetAllAccountsHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs @@ -5,20 +5,20 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Internal.GetAll; -public class GetAllAccountsHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAllAccountsHandler handler; private readonly Mock reads = new(); private readonly Account[] accounts = [ - CreateAccountWithId(id: AccountId.New()), - CreateAccountWithId(id: AccountId.New()), - CreateAccountWithId(id: AccountId.New()), - CreateAccountWithId(id: AccountId.New()), + CreateAccount(id: AccountId.New()), + CreateAccount(id: AccountId.New()), + CreateAccount(id: AccountId.New()), + CreateAccount(id: AccountId.New()), ]; private readonly AccountQuery query = new(Pagination: new(1, 1)); - public GetAllAccountsHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/GetAccountByIdHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs similarity index 87% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/GetAccountByIdHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs index 1e23e55db..a3215b1a5 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/GetAccountByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs @@ -4,19 +4,19 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Internal.GetById; -using static AccountsData; +using static Data.Accounts.TestData; -public class GetAccountByIdHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountByIdHandler handler; private readonly Mock reads = new(); - public GetAccountByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) - .ReturnsAsync(CreateAccountWithId(id: ValidId)); + .ReturnsAsync(CreateAccount(id: ValidId)); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/GetAccountSortingsHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/Tests.cs similarity index 88% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/GetAccountSortingsHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/Tests.cs index 30a633d4e..9f7114086 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/GetAccountSortingsHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Internal.GetSortings; -public class GetAccountSortingsHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountSortingsHandler handler = new(); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/GetUserEmailByIdHandler.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs similarity index 91% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/GetUserEmailByIdHandler.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs index 2e47cce98..404e6e1f5 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/GetUserEmailByIdHandler.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs @@ -5,16 +5,16 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetEmail; -using static AccountsData; +using static Data.Accounts.TestData; -public class GetUserEmailByIdHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetUserEmailByIdHandler handler; private readonly Mock reads = new(); private static readonly Account account = CreateAccount(); - public GetUserEmailByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/GetAccountExistsByIdHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs similarity index 85% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/GetAccountExistsByIdHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs index 94ba64ebd..ad1bd5e96 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/GetAccountExistsByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs @@ -2,16 +2,16 @@ using CustomCADs.Modules.Accounts.Domain.Repositories.Reads; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetExists; +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetExists.ById; -using static AccountsData; +using static Data.Accounts.TestData; -public class GetAccountExistsByIdHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountExistsByIdHandler handler; private readonly Mock reads = new(); - public GetAccountExistsByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/GetAccountExistsByUsernameHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs similarity index 85% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/GetAccountExistsByUsernameHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs index a9f3a32f0..0596baf34 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/GetAccountExistsByUsernameHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs @@ -2,16 +2,16 @@ using CustomCADs.Modules.Accounts.Domain.Repositories.Reads; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetExists; +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetExists.ByUsername; -using static AccountsData; +using static Data.Accounts.TestData; -public class GetAccountExistsByUsernameHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountExistsByUsernameHandler handler; private readonly Mock reads = new(); - public GetAccountExistsByUsernameHandlerUnitTests() + public Tests() { handler = new(reads.Object); } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/GetAccountInfoByUsernameHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs similarity index 92% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/GetAccountInfoByUsernameHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs index 8bf252c0f..b6a31bac5 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/GetAccountInfoByUsernameHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs @@ -5,16 +5,16 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetInfo; -using static AccountsData; +using static Data.Accounts.TestData; -public class GetAccountInfoByUsernameHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountInfoByUsernameHandler handler; private readonly Mock reads = new(); private static readonly Account account = CreateAccount(); - public GetAccountInfoByUsernameHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/GetUserRoleByIdHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs similarity index 88% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/GetUserRoleByIdHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs index 8c26975f2..bf5f59b46 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/GetUserRoleByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs @@ -5,14 +5,14 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetUserRole; -using static AccountsData; +using static Data.Accounts.TestData; -public class GetUserRoleByIdHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetUserRoleByIdHandler handler; private readonly Mock reads = new(); - public GetUserRoleByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); @@ -42,7 +42,7 @@ public async Task Handle_ShouldReturnResult() string actualRole = await handler.Handle(query, ct); // Assert - Assert.Equal(RolesData.ValidName, actualRole); + Assert.Equal(Data.Roles.TestData.ValidName, actualRole); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/BatchGetUsernamesByIdHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs similarity index 74% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/BatchGetUsernamesByIdHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs index 4c33ea6c5..dd6e8c2b9 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsernames/BatchGetUsernamesByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs @@ -4,12 +4,12 @@ using CustomCADs.Shared.Domain.Querying; using CustomCADs.Shared.Domain.TypedIds.Accounts; -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetUsernames; +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetUsername.Batch; -using static AccountsData; +using static Data.Accounts.TestData; using static DomainConstants.Users; -public class BatchGetUsernamesByIdHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly BatchGetUsernamesByIdHandler handler; private readonly Mock reads = new(); @@ -18,18 +18,18 @@ public class BatchGetUsernamesByIdHandlerUnitTests : AccountsBaseUnitTests private static readonly string[] usernames = [CustomerUsername, ContributorUsername, DesignerUsername, HeadDesignerUsername, AdminUsername]; private static readonly AccountQuery accountQuery = new(Pagination: new(1, ids.Length), Ids: ids); - public BatchGetUsernamesByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); reads.Setup(x => x.AllAsync(accountQuery, false, ct)).ReturnsAsync(new Result( Count: ids.Length, Items: [ - CreateAccountWithId(id: AccountId.New(), username: CustomerUsername), - CreateAccountWithId(id: AccountId.New(), username: ContributorUsername), - CreateAccountWithId(id: AccountId.New(), username: DesignerUsername), - CreateAccountWithId(id: AccountId.New(), username: HeadDesignerUsername), - CreateAccountWithId(id: AccountId.New(), username: AdminUsername), + CreateAccount(id: AccountId.New(), username: CustomerUsername), + CreateAccount(id: AccountId.New(), username: ContributorUsername), + CreateAccount(id: AccountId.New(), username: DesignerUsername), + CreateAccount(id: AccountId.New(), username: HeadDesignerUsername), + CreateAccount(id: AccountId.New(), username: AdminUsername), ] )); } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/GetUsernameByIdHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs similarity index 89% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/GetUsernameByIdHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs index fd393c2c4..c4e6a78e5 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/GetUsernameByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs @@ -3,16 +3,16 @@ using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetUsername; +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetUsername.Single; -using static AccountsData; +using static Data.Accounts.TestData; -public class GetUsernameByIdHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetUsernameByIdHandler handler; private readonly Mock reads = new(); - public GetUsernameByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/GetAccountViewedProductHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs similarity index 87% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/GetAccountViewedProductHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs index 762d49449..2a6ad1c43 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/GetAccountViewedProductHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs @@ -3,18 +3,18 @@ using CustomCADs.Shared.Application.UseCases.Accounts.Queries; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.ViewedProducts; +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.ViewedProducts.ById; -using static AccountsData; +using static Data.Accounts.TestData; -public class GetAccountViewedProductHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountViewedProductHandler handler; private readonly Mock reads = new(); private static readonly ProductId productId = ProductId.New(); - public GetAccountViewedProductHandlerUnitTests() + public Tests() { handler = new(reads.Object); reads.Setup(x => x.ViewedProductsByIdAsync(ValidId, ct)) diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/GetAccountViewedProductsByUsernameHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs similarity index 86% rename from tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/GetAccountViewedProductsByUsernameHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs index e1d97783a..a509d1560 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/GetAccountViewedProductsByUsernameHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs @@ -3,18 +3,18 @@ using CustomCADs.Modules.Accounts.Domain.Repositories.Reads; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.ViewedProducts; +namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.ViewedProducts.ByName; -using static AccountsData; +using static Data.Accounts.TestData; -public class GetAccountViewedProductsByUsernameHandlerUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountViewedProductsByUsernameHandler handler; private readonly Mock reads = new(); private static readonly ViewedProduct[] expected = []; - public GetAccountViewedProductsByUsernameHandlerUnitTests() + public Tests() { handler = new(reads.Object); reads.Setup(x => x.ViewedProductsByUsernameAsync(ValidUsername, ct)) diff --git a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/CreateRoleHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs similarity index 92% rename from tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/CreateRoleHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs index b6f3fb868..fe45abd6e 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/CreateRoleHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs @@ -8,9 +8,9 @@ namespace CustomCADs.UnitTests.Accounts.Application.Roles.Commands.Internal.Create; -using static RolesData; +using static Data.Roles.TestData; -public class CreateRoleHandlerUnitTests : RolesBaseUnitTests +public class Tests : Data.Roles.BaseUnitTests { private readonly CreateRoleHandler handler; private readonly Mock raiser = new(); @@ -18,9 +18,9 @@ public class CreateRoleHandlerUnitTests : RolesBaseUnitTests private readonly Mock uow = new(); private readonly Mock writes = new(); - private static readonly Role role = CreateRoleWithId(id: ValidId); + private static readonly Role role = CreateRole(id: ValidId); - public CreateRoleHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, cache.Object, raiser.Object); diff --git a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/DeleteRoleHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs similarity index 94% rename from tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/DeleteRoleHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs index f40d0ce86..3e6bf47ca 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/DeleteRoleHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs @@ -9,9 +9,9 @@ namespace CustomCADs.UnitTests.Accounts.Application.Roles.Commands.Internal.Delete; -using static RolesData; +using static Data.Roles.TestData; -public class DeleteRoleHandlerUnitTests : RolesBaseUnitTests +public class Tests : Data.Roles.BaseUnitTests { private readonly DeleteRoleHandler handler; private readonly Mock raiser = new(); @@ -20,7 +20,7 @@ public class DeleteRoleHandlerUnitTests : RolesBaseUnitTests private readonly Mock writes = new(); private readonly Mock reads = new(); - public DeleteRoleHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, cache.Object, raiser.Object); diff --git a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/GetAllRolesHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs similarity index 86% rename from tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/GetAllRolesHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs index 081c1afe9..556536819 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/GetAllRolesHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs @@ -5,20 +5,20 @@ namespace CustomCADs.UnitTests.Accounts.Application.Roles.Queries.Internal.GetAll; -public class GetAllRolesHandlerUnitTests : RolesBaseUnitTests +public class Tests : Data.Roles.BaseUnitTests { private readonly GetAllRolesHandler handler; private readonly Mock reads = new(); private readonly Mock> cache = new(); private readonly Role[] roles = [ - CreateRoleWithId(), - CreateRoleWithId(), - CreateRoleWithId(), - CreateRoleWithId(), + CreateRole(), + CreateRole(), + CreateRole(), + CreateRole(), ]; - public GetAllRolesHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); diff --git a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/GetRoleByIdHandlerUnitTests.cs b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs similarity index 86% rename from tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/GetRoleByIdHandlerUnitTests.cs rename to tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs index 6d80348c4..e145e318e 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/GetRoleByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs @@ -5,22 +5,22 @@ namespace CustomCADs.UnitTests.Accounts.Application.Roles.Queries.Internal.GetById; -using static RolesData; +using static Data.Roles.TestData; -public class GetRoleByIdHandlerUnitTests : RolesBaseUnitTests +public class Tests : Data.Roles.BaseUnitTests { private readonly GetRoleByIdHandler handler; private readonly Mock reads = new(); private readonly Mock> cache = new(); - public GetRoleByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); cache.Setup(x => x.GetOrCreateAsync( ValidId, It.IsAny>>() - )).ReturnsAsync(CreateRoleWithId(id: ValidId)); + )).ReturnsAsync(CreateRole(id: ValidId)); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Roles/RolesBaseUnitTests.cs b/tests/UnitTests/Accounts/Application/Roles/RolesBaseUnitTests.cs deleted file mode 100644 index 3c43c5b22..000000000 --- a/tests/UnitTests/Accounts/Application/Roles/RolesBaseUnitTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Application.Roles; - -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using static RolesData; - -public class RolesBaseUnitTests -{ - public static readonly CancellationToken ct = CancellationToken.None; - - protected static Role CreateRole(string? name = null, string? description = null) - => Role.Create(name ?? ValidName, description ?? MinValidDescription); - - protected static Role CreateRoleWithId(RoleId? id = null, string? name = null, string? description = null) - => Role.CreateWithId(id ?? ValidId, name ?? ValidName, description ?? MinValidDescription); -} diff --git a/tests/UnitTests/Accounts/Data/Accounts/BaseUnitTests.cs b/tests/UnitTests/Accounts/Data/Accounts/BaseUnitTests.cs new file mode 100644 index 000000000..004112d58 --- /dev/null +++ b/tests/UnitTests/Accounts/Data/Accounts/BaseUnitTests.cs @@ -0,0 +1,14 @@ +using CustomCADs.Modules.Accounts.Domain.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Accounts; + +namespace CustomCADs.UnitTests.Accounts.Data.Accounts; + +using static Data.Accounts.TestData; + +public class BaseUnitTests +{ + public static readonly CancellationToken ct = CancellationToken.None; + + protected static Account CreateAccount(string? role = null, string username = ValidUsername, string email = ValidEmail1, DateTimeOffset? createdAt = null, string? firstName = ValidFirstName, string? lastName = ValidLastName, AccountId? id = null) + => Account.CreateWithId(id ?? ValidId, role ?? Roles.TestData.ValidName, username, email, createdAt ?? DateTimeOffset.UtcNow, firstName, lastName); +} diff --git a/tests/UnitTests/Accounts/Data/AccountsData.cs b/tests/UnitTests/Accounts/Data/Accounts/TestData.cs similarity index 92% rename from tests/UnitTests/Accounts/Data/AccountsData.cs rename to tests/UnitTests/Accounts/Data/Accounts/TestData.cs index 19ae29520..bc231f3c6 100644 --- a/tests/UnitTests/Accounts/Data/AccountsData.cs +++ b/tests/UnitTests/Accounts/Data/Accounts/TestData.cs @@ -1,13 +1,13 @@ -using CustomCADs.Modules.Accounts.Domain.Accounts; +using CustomCADs.Modules.Accounts.Domain.Accounts; using CustomCADs.Shared.Domain; using CustomCADs.Shared.Domain.TypedIds.Accounts; -namespace CustomCADs.UnitTests.Accounts.Data; +namespace CustomCADs.UnitTests.Accounts.Data.Accounts; using static AccountConstants; using static DomainConstants.Users; -public static class AccountsData +public static class TestData { public const string ValidUsername = CustomerUsername; public static readonly string MinValidUsername = new('a', NameMinLength + 1); diff --git a/tests/UnitTests/Accounts/Data/Roles/BaseUnitTests.cs b/tests/UnitTests/Accounts/Data/Roles/BaseUnitTests.cs new file mode 100644 index 000000000..181328378 --- /dev/null +++ b/tests/UnitTests/Accounts/Data/Roles/BaseUnitTests.cs @@ -0,0 +1,21 @@ +using CustomCADs.Modules.Accounts.Domain.Roles; +using CustomCADs.Shared.Domain.TypedIds.Accounts; + +namespace CustomCADs.UnitTests.Accounts.Data.Roles; + +using static Data.Roles.TestData; + +public class BaseUnitTests +{ + public static readonly CancellationToken ct = CancellationToken.None; + + protected static Role CreateRole( + string? name = null, + string? description = null, + RoleId? id = null + ) => Role.CreateWithId( + id: id ?? ValidId, + name: name ?? ValidName, + description: description ?? ValidDescription + ); +} diff --git a/tests/UnitTests/Accounts/Data/RolesData.cs b/tests/UnitTests/Accounts/Data/Roles/TestData.cs similarity index 89% rename from tests/UnitTests/Accounts/Data/RolesData.cs rename to tests/UnitTests/Accounts/Data/Roles/TestData.cs index 70df47815..f24182f11 100644 --- a/tests/UnitTests/Accounts/Data/RolesData.cs +++ b/tests/UnitTests/Accounts/Data/Roles/TestData.cs @@ -1,13 +1,13 @@ -using CustomCADs.Modules.Accounts.Domain.Roles; +using CustomCADs.Modules.Accounts.Domain.Roles; using CustomCADs.Modules.Accounts.Domain; using CustomCADs.Shared.Domain.TypedIds.Accounts; -namespace CustomCADs.UnitTests.Accounts.Data; +namespace CustomCADs.UnitTests.Accounts.Data.Roles; using static Constants.Roles; using static RoleConstants; -public static class RolesData +public static class TestData { public static readonly string ValidName = Shared.Domain.DomainConstants.Users.CustomerRole; public static readonly string MinValidName = new('a', NameMinLength + 1); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/AccountsBaseUnitTests.cs b/tests/UnitTests/Accounts/Domain/Accounts/AccountsBaseUnitTests.cs deleted file mode 100644 index 9533f9cc5..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/AccountsBaseUnitTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Accounts; - -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts; - -using static AccountsData; - -public class AccountsBaseUnitTests -{ - protected static Account CreateAccount( - string? role = null, - string username = ValidUsername, - string email = ValidEmail1, - string? firstName = ValidFirstName, - string? lastName = ValidLastName - ) => Account.Create( - role: role ?? RolesData.ValidName, - username: username, - email: email, - firstName: firstName, - lastName: lastName - ); - - protected static Account CreateAccountWithId( - AccountId? id = null, - string? role = null, - string username = ValidUsername, - string email = ValidEmail1, - DateTimeOffset? createdAt = null, - string? firstName = ValidFirstName, - string? lastName = ValidLastName - ) => Account.CreateWithId( - id: id ?? ValidId, - role: role ?? RolesData.ValidName, - username: username, - email: email, - createdAt: createdAt ?? DateTimeOffset.UtcNow, - firstName: firstName, - lastName: lastName - ); -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/AccountEmailData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/AccountEmailData.cs deleted file mode 100644 index 87f2d6038..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/AccountEmailData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Email; - -public class AccountEmailData : TheoryData; diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/Data/AccountEmailInvalidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/InvalidData.cs similarity index 60% rename from tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/Data/AccountEmailInvalidData.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/InvalidData.cs index 320ec9d36..e4fb2f15d 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/Data/AccountEmailInvalidData.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/InvalidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Email.Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Email; -using static AccountsData; +using static Data.Accounts.TestData; -public class AccountEmailInvalidData : AccountEmailData +public class InvalidData : TheoryData { - public AccountEmailInvalidData() + public InvalidData() { Add(InvalidEmail); Add(InvalidEmailLocal); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/AccountEmailUnitTests.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/Tests.cs similarity index 63% rename from tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/AccountEmailUnitTests.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/Tests.cs index aae1887ae..080cf02c1 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/AccountEmailUnitTests.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/Tests.cs @@ -1,12 +1,11 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Email; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Email; -public class AccountEmailUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { [Theory] - [ClassData(typeof(AccountEmailValidData))] + [ClassData(typeof(ValidData))] public void SetEmail_ShouldNotThrowException_WhenEmailIsValid(string email) { var account = CreateAccount(); @@ -15,7 +14,7 @@ public void SetEmail_ShouldNotThrowException_WhenEmailIsValid(string email) } [Theory] - [ClassData(typeof(AccountEmailValidData))] + [ClassData(typeof(ValidData))] public void SetEmail_Setsemail_WhenUserameIsValid(string email) { var account = CreateAccount(); @@ -26,7 +25,7 @@ public void SetEmail_Setsemail_WhenUserameIsValid(string email) } [Theory] - [ClassData(typeof(AccountEmailInvalidData))] + [ClassData(typeof(InvalidData))] public void SetEmail_ThrowsException_WhenUserameIsInvalid(string email) { var account = CreateAccount(); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/Data/AccountEmailValidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/ValidData.cs similarity index 51% rename from tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/Data/AccountEmailValidData.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/ValidData.cs index 833ee48a3..d425e114e 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/Data/AccountEmailValidData.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Email/ValidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Email.Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Email; -using static AccountsData; +using static Data.Accounts.TestData; -public class AccountEmailValidData : AccountEmailData +public class ValidData : TheoryData { - public AccountEmailValidData() + public ValidData() { Add(ValidEmail1); Add(ValidEmail2); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/AccountFirstNameData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/AccountFirstNameData.cs deleted file mode 100644 index f1b92a0f7..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/AccountFirstNameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.FirstName; - -public class AccountFirstNameData : TheoryData; diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Data/AccountFirstNameInvalidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Data/AccountFirstNameInvalidData.cs deleted file mode 100644 index d5ad98d34..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Data/AccountFirstNameInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.FirstName.Data; - -using static AccountsData; - -public class AccountFirstNameInvalidData : AccountFirstNameData -{ - public AccountFirstNameInvalidData() - { - Add(MinInvalidFirstName); - Add(MaxInvalidFirstName); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Data/AccountFirstNameValidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Data/AccountFirstNameValidData.cs deleted file mode 100644 index 91a9d1408..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Data/AccountFirstNameValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.FirstName.Data; - -using static AccountsData; - -public class AccountFirstNameValidData : AccountFirstNameData -{ - public AccountFirstNameValidData() - { - Add(ValidFirstName); - Add(ValidFirstNameNull); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/InvalidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/InvalidData.cs new file mode 100644 index 000000000..ae4202949 --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/InvalidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.FirstName; + +using static Data.Accounts.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(MinInvalidFirstName); + Add(MaxInvalidFirstName); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/AccountFirstNameUnitTests.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Tests.cs similarity index 64% rename from tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/AccountFirstNameUnitTests.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Tests.cs index 10909d3bd..605783a5c 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/AccountFirstNameUnitTests.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/Tests.cs @@ -1,12 +1,11 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.FirstName; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.FirstName; -public class AccountFirstNameUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { [Theory] - [ClassData(typeof(AccountFirstNameValidData))] + [ClassData(typeof(ValidData))] public void SetFirstName_ShouldNotThrowException_WhenFirstNameIsValid(string firstName) { var account = CreateAccount(); @@ -15,7 +14,7 @@ public void SetFirstName_ShouldNotThrowException_WhenFirstNameIsValid(string fir } [Theory] - [ClassData(typeof(AccountFirstNameValidData))] + [ClassData(typeof(ValidData))] public void SetFirstName_SetsfirstName_WhenUsernameIsValid(string firstName) { var account = CreateAccount(); @@ -26,7 +25,7 @@ public void SetFirstName_SetsfirstName_WhenUsernameIsValid(string firstName) } [Theory] - [ClassData(typeof(AccountFirstNameInvalidData))] + [ClassData(typeof(InvalidData))] public void SetFirstName_ThrowsException_WhenUsernameIsInvalid(string firstName) { var account = CreateAccount(); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/ValidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/ValidData.cs new file mode 100644 index 000000000..0bd1f9c93 --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/FirstName/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.FirstName; + +using static Data.Accounts.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(ValidFirstName); + Add(ValidFirstNameNull); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/AccountLastNameData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/AccountLastNameData.cs deleted file mode 100644 index a4b102bd8..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/AccountLastNameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.LastName; - -public class AccountLastNameData : TheoryData; diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/AccountLastNameUnitTests.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/AccountLastNameUnitTests.cs deleted file mode 100644 index 622a24ebd..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/AccountLastNameUnitTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.LastName; - -using CustomCADs.Shared.Domain.Exceptions; -using Data; - -public class AccountLastNameUnitTests : AccountsBaseUnitTests -{ - [Theory] - [ClassData(typeof(AccountLastNameValidData))] - public void SetLastName_ShouldNotThrowException_WhenLastNameIsValid(string? lastName) - { - var account = CreateAccount(); - - account.SetLastName(lastName); - } - - [Theory] - [ClassData(typeof(AccountLastNameValidData))] - public void SetLastName_SetsLastName_WhenLastNameIsValid(string? lastName) - { - var account = CreateAccount(); - - account.SetLastName(lastName); - - Assert.Equal(account.LastName, lastName); - } - - [Theory] - [ClassData(typeof(AccountLastNameInvalidData))] - public void SetLastName_ThrowsException_WhenLastNameIsInvalid(string? lastName) - { - var account = CreateAccount(); - - Assert.Throws>( - () => account.SetLastName(lastName) - ); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Data/AccountLastNameInvalidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Data/AccountLastNameInvalidData.cs deleted file mode 100644 index 25cfe3949..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Data/AccountLastNameInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.LastName.Data; - -using static AccountsData; - -public class AccountLastNameInvalidData : AccountLastNameData -{ - public AccountLastNameInvalidData() - { - Add(MinInvalidLastName); - Add(MaxInvalidLastName); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Data/AccountLastNameValidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Data/AccountLastNameValidData.cs deleted file mode 100644 index e801f5e8e..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Data/AccountLastNameValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.LastName.Data; - -using static AccountsData; - -public class AccountLastNameValidData : AccountLastNameData -{ - public AccountLastNameValidData() - { - Add(ValidLastName); - Add(ValidLastNameNull); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/InvalidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/InvalidData.cs new file mode 100644 index 000000000..9a7454065 --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/InvalidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.LastName; + +using static Data.Accounts.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(MinInvalidLastName); + Add(MaxInvalidLastName); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Tests.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Tests.cs new file mode 100644 index 000000000..d4f6acb97 --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/Tests.cs @@ -0,0 +1,37 @@ +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.LastName; + +public class Tests : Data.Accounts.BaseUnitTests +{ + [Theory] + [ClassData(typeof(ValidData))] + public void SetLastName_ShouldNotThrowException_WhenLastNameIsValid(string lastName) + { + var account = CreateAccount(); + + account.SetLastName(lastName); + } + + [Theory] + [ClassData(typeof(ValidData))] + public void SetLastName_SetslastName_WhenUsernameIsValid(string lastName) + { + var account = CreateAccount(); + + account.SetLastName(lastName); + + Assert.Equal(account.LastName, lastName); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void SetLastName_ThrowsException_WhenUsernameIsInvalid(string lastName) + { + var account = CreateAccount(); + + Assert.Throws>( + () => account.SetLastName(lastName) + ); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/ValidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/ValidData.cs new file mode 100644 index 000000000..fd0fcd26d --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/LastName/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.LastName; + +using static Data.Accounts.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(ValidLastName); + Add(ValidLastNameNull); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/Data/AccountTrackViewedProductsValidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/Data/AccountTrackViewedProductsValidData.cs deleted file mode 100644 index 2c261e59c..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/Data/AccountTrackViewedProductsValidData.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.TrackViewedProducts.Data; - -public class AccountTrackViewedProductsValidData : TheoryData -{ - public AccountTrackViewedProductsValidData() - { - Add(true); - Add(false); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/AccountTrackViewedProductsUnitTests.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/Tests.cs similarity index 70% rename from tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/AccountTrackViewedProductsUnitTests.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/Tests.cs index 538e0638c..60dc806a4 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/AccountTrackViewedProductsUnitTests.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/Tests.cs @@ -1,9 +1,9 @@ namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.TrackViewedProducts; -public class AccountTrackViewedProductsUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { [Theory] - [ClassData(typeof(Data.AccountTrackViewedProductsValidData))] + [ClassData(typeof(ValidData))] public void SetTrackViewedProducts_ShouldNotThrowException(bool value) { var account = CreateAccount(); @@ -12,7 +12,7 @@ public void SetTrackViewedProducts_ShouldNotThrowException(bool value) } [Theory] - [ClassData(typeof(Data.AccountTrackViewedProductsValidData))] + [ClassData(typeof(ValidData))] public void SetTrackViewedProducts_SetsTrackViewedProducts(bool value) { var account = CreateAccount(); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/ValidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/ValidData.cs new file mode 100644 index 000000000..53fc8264d --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/TrackViewedProducts/ValidData.cs @@ -0,0 +1,10 @@ +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.TrackViewedProducts; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(true); + Add(false); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/AccountUsernameData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/AccountUsernameData.cs deleted file mode 100644 index b10adcd82..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/AccountUsernameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Username; - -public class AccountUsernameData : TheoryData; diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/Data/AccountUsernameInvalidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/InvalidData.cs similarity index 51% rename from tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/Data/AccountUsernameInvalidData.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/InvalidData.cs index 2d2cf7fe0..f52ec0553 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/Data/AccountUsernameInvalidData.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/InvalidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Username.Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Username; -using static AccountsData; +using static Data.Accounts.TestData; -public class AccountUsernameInvalidData : AccountUsernameData +public class InvalidData : TheoryData { - public AccountUsernameInvalidData() + public InvalidData() { Add(InvalidUsername); Add(MinInvalidUsername); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/AccountUsernameUnitTests.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/Tests.cs similarity index 64% rename from tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/AccountUsernameUnitTests.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/Tests.cs index 1ebf5bed5..4bd379af4 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/AccountUsernameUnitTests.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/Tests.cs @@ -1,12 +1,11 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Username; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Username; -public class AccountUsernameUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { [Theory] - [ClassData(typeof(AccountUsernameValidData))] + [ClassData(typeof(ValidData))] public void SetUsername_ShouldNotThrowException_WhenUsernameIsValid(string username) { var account = CreateAccount(); @@ -15,7 +14,7 @@ public void SetUsername_ShouldNotThrowException_WhenUsernameIsValid(string usern } [Theory] - [ClassData(typeof(AccountUsernameValidData))] + [ClassData(typeof(ValidData))] public void SetUsername_SetsUsername_WhenUserameIsValid(string username) { var account = CreateAccount(); @@ -26,7 +25,7 @@ public void SetUsername_SetsUsername_WhenUserameIsValid(string username) } [Theory] - [ClassData(typeof(AccountUsernameInvalidData))] + [ClassData(typeof(InvalidData))] public void SetUsername_ThrowsException_WhenUserameIsInvalid(string username) { var account = CreateAccount(); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/Data/AccountUsernameValidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/ValidData.cs similarity index 51% rename from tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/Data/AccountUsernameValidData.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/ValidData.cs index d2d602cea..15318338d 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/Data/AccountUsernameValidData.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Behaviors/Username/ValidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Username.Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Behaviors.Username; -using static AccountsData; +using static Data.Accounts.TestData; -public class AccountUsernameValidData : AccountUsernameData +public class ValidData : TheoryData { - public AccountUsernameValidData() + public ValidData() { Add(ValidUsername); Add(MinValidUsername); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/AccountCreateData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/AccountCreateData.cs deleted file mode 100644 index e99636fe7..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Create/AccountCreateData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create; - -public class AccountCreateData : TheoryData; diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidEmailData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidEmailData.cs deleted file mode 100644 index 44b2f877c..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidEmailData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.Data; - -using static AccountsData; - -public class AccountCreateInvalidEmailData : AccountCreateData -{ - public AccountCreateInvalidEmailData() - { - Add(RolesData.ValidName, ValidUsername, InvalidEmail, ValidFirstName, ValidLastName); - Add(RolesData.MinValidName, MinValidUsername, InvalidEmailLocal, ValidFirstNameNull, ValidLastNameNull); - Add(RolesData.MaxValidName, MaxValidUsername, InvalidEmailDomain, ValidFirstName, ValidLastName); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidFirstNameData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidFirstNameData.cs deleted file mode 100644 index 1f4529785..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidFirstNameData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.Data; - -using static AccountsData; - -public class AccountCreateInvalidFirstNameData : AccountCreateData -{ - public AccountCreateInvalidFirstNameData() - { - Add(RolesData.ValidName, ValidUsername, ValidEmail1, MinInvalidFirstName, ValidLastName); - Add(RolesData.MinValidName, MinValidUsername, ValidEmail2, MaxInvalidFirstName, ValidLastNameNull); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidLastNameData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidLastNameData.cs deleted file mode 100644 index 4f90c7843..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidLastNameData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.Data; - -using static AccountsData; - -public class AccountCreateInvalidLastNameData : AccountCreateData -{ - public AccountCreateInvalidLastNameData() - { - Add(RolesData.ValidName, ValidUsername, ValidEmail1, ValidFirstName, MinInvalidLastName); - Add(RolesData.MinValidName, MinValidUsername, ValidEmail2, ValidFirstNameNull, MaxInvalidLastName); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidRoleData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidRoleData.cs deleted file mode 100644 index 949d3a8a9..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidRoleData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.Data; - -using static AccountsData; - -public class AccountCreateInvalidRoleData : AccountCreateData -{ - public AccountCreateInvalidRoleData() - { - Add(RolesData.InvalidName, ValidUsername, ValidEmail1, ValidFirstName, ValidLastName); - Add(RolesData.MinInvalidName, MinValidUsername, ValidEmail2, ValidFirstNameNull, ValidLastNameNull); - Add(RolesData.MaxInvalidName, MaxValidUsername, ValidEmail3, ValidFirstName, ValidLastName); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidUsernameData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidUsernameData.cs deleted file mode 100644 index 117f5ead0..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateInvalidUsernameData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.Data; - -using static AccountsData; - -public class AccountCreateInvalidUsernameData : AccountCreateData -{ - public AccountCreateInvalidUsernameData() - { - Add(RolesData.ValidName, InvalidUsername, ValidEmail1, ValidFirstName, ValidLastName); - Add(RolesData.MinValidName, MinInvalidUsername, ValidEmail2, ValidFirstNameNull, ValidLastNameNull); - Add(RolesData.MaxValidName, MaxInvalidUsername, ValidEmail3, ValidFirstName, ValidLastName); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/InvalidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/InvalidData.cs new file mode 100644 index 000000000..820c4a067 --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Accounts/Create/InvalidData.cs @@ -0,0 +1,33 @@ +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create; + +using static Data.Accounts.TestData; +using RolesData = Data.Roles.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + // Role + Add(RolesData.InvalidName, ValidUsername, ValidEmail1, ValidFirstName, ValidLastName); + Add(RolesData.MinInvalidName, MinValidUsername, ValidEmail2, ValidFirstNameNull, ValidLastNameNull); + Add(RolesData.MaxInvalidName, MaxValidUsername, ValidEmail3, ValidFirstName, ValidLastName); + + // Username + Add(RolesData.ValidName, InvalidUsername, ValidEmail1, ValidFirstName, ValidLastName); + Add(RolesData.MinValidName, MinInvalidUsername, ValidEmail2, ValidFirstNameNull, ValidLastNameNull); + Add(RolesData.MaxValidName, MaxInvalidUsername, ValidEmail3, ValidFirstName, ValidLastName); + + // First Name + Add(RolesData.ValidName, ValidUsername, ValidEmail1, MinInvalidFirstName, ValidLastName); + Add(RolesData.MinValidName, MinValidUsername, ValidEmail2, MaxInvalidFirstName, ValidLastNameNull); + + // Last Name + Add(RolesData.ValidName, ValidUsername, ValidEmail1, ValidFirstName, MinInvalidLastName); + Add(RolesData.MinValidName, MinValidUsername, ValidEmail2, ValidFirstNameNull, MaxInvalidLastName); + + // Email + Add(RolesData.ValidName, ValidUsername, InvalidEmail, ValidFirstName, ValidLastName); + Add(RolesData.MinValidName, MinValidUsername, InvalidEmailLocal, ValidFirstNameNull, ValidLastNameNull); + Add(RolesData.MaxValidName, MaxValidUsername, InvalidEmailDomain, ValidFirstName, ValidLastName); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/Normal/AccountCreateUnitTests.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/Normal/Tests.cs similarity index 52% rename from tests/UnitTests/Accounts/Domain/Accounts/Create/Normal/AccountCreateUnitTests.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Create/Normal/Tests.cs index e3a733629..b6e3494d9 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Create/Normal/AccountCreateUnitTests.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Create/Normal/Tests.cs @@ -1,22 +1,21 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.Normal; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.Normal; -public class AccountCreateUnitTests : AccountsBaseUnitTests +public class Tests : Data.Accounts.BaseUnitTests { [Theory] - [ClassData(typeof(AccountCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldNotThrowException_WhenAccountIsValid(string role, string username, string email, string? firstName, string? lastName) { - CreateAccount(role, username, email, firstName, lastName); + Account.Create(role, username, email, firstName, lastName); } [Theory] - [ClassData(typeof(AccountCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldPopulateCorrectly_WhenAccountIsValid(string role, string username, string email, string? firstName, string? lastName) { - var account = CreateAccount(role, username, email, firstName, lastName); + var account = Account.Create(role, username, email, firstName, lastName); Assert.Multiple( () => Assert.Equal(role, account.RoleName), @@ -28,15 +27,11 @@ public void Create_ShouldPopulateCorrectly_WhenAccountIsValid(string role, strin } [Theory] - [ClassData(typeof(AccountCreateInvalidRoleData))] - [ClassData(typeof(AccountCreateInvalidUsernameData))] - [ClassData(typeof(AccountCreateInvalidEmailData))] - [ClassData(typeof(AccountCreateInvalidFirstNameData))] - [ClassData(typeof(AccountCreateInvalidLastNameData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenAccountIsInvalid(string role, string username, string email, string? firstName, string? lastName) { Assert.Throws>( - () => CreateAccount(role, username, email, firstName, lastName) + () => Account.Create(role, username, email, firstName, lastName) ); } } diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateValidData.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/ValidData.cs similarity index 66% rename from tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateValidData.cs rename to tests/UnitTests/Accounts/Domain/Accounts/Create/ValidData.cs index 84c091476..756df2456 100644 --- a/tests/UnitTests/Accounts/Domain/Accounts/Create/Data/AccountCreateValidData.cs +++ b/tests/UnitTests/Accounts/Domain/Accounts/Create/ValidData.cs @@ -1,10 +1,11 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create; -using static AccountsData; +using static Data.Accounts.TestData; +using RolesData = Data.Roles.TestData; -public class AccountCreateValidData : AccountCreateData +public class ValidData : TheoryData { - public AccountCreateValidData() + public ValidData() { Add(RolesData.ValidName, ValidUsername, ValidEmail1, ValidFirstName, ValidLastName); Add(RolesData.MinValidName, MinValidUsername, ValidEmail2, ValidFirstNameNull, ValidLastNameNull); diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/WithId/AccountCreateWithIdUnitTests.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/WithId/AccountCreateWithIdUnitTests.cs deleted file mode 100644 index dc3ff869e..000000000 --- a/tests/UnitTests/Accounts/Domain/Accounts/Create/WithId/AccountCreateWithIdUnitTests.cs +++ /dev/null @@ -1,43 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.WithId; - -using CustomCADs.Shared.Domain.Exceptions; -using Data; -using static AccountsData; - -public class AccountCreateWithIdUnitTests : AccountsBaseUnitTests -{ - [Theory] - [ClassData(typeof(AccountCreateValidData))] - public void CreateWithId_ShouldNotThrowException_WhenAccountIsValid(string role, string username, string email, string? firstName, string? lastName) - { - CreateAccountWithId(ValidId, role, username, email, createdAt: null, firstName, lastName); - } - - [Theory] - [ClassData(typeof(AccountCreateValidData))] - public void CreateWithId_ShouldPopulateCorrectly_WhenAccountIsValid(string role, string username, string email, string? firstName, string? lastName) - { - var account = CreateAccountWithId(ValidId, role, username, email, createdAt: null, firstName, lastName); - - Assert.Multiple( - () => Assert.Equal(role, account.RoleName), - () => Assert.Equal(username, account.Username), - () => Assert.Equal(email, account.Email), - () => Assert.Equal(firstName, account.FirstName), - () => Assert.Equal(lastName, account.LastName) - ); - } - - [Theory] - [ClassData(typeof(AccountCreateInvalidRoleData))] - [ClassData(typeof(AccountCreateInvalidUsernameData))] - [ClassData(typeof(AccountCreateInvalidEmailData))] - [ClassData(typeof(AccountCreateInvalidFirstNameData))] - [ClassData(typeof(AccountCreateInvalidLastNameData))] - public void CreateWithId_ShouldThrowException_WhenAccountIsInvalid(string role, string username, string email, string? firstName, string? lastName) - { - Assert.Throws>( - () => CreateAccountWithId(ValidId, role, username, email, createdAt: null, firstName, lastName) - ); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Accounts/Create/WithId/Tests.cs b/tests/UnitTests/Accounts/Domain/Accounts/Create/WithId/Tests.cs new file mode 100644 index 000000000..cc7f02fb6 --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Accounts/Create/WithId/Tests.cs @@ -0,0 +1,40 @@ +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Accounts.Domain.Accounts.Create.WithId; + +using static Data.Accounts.TestData; + +public class Tests : Data.Accounts.BaseUnitTests +{ + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldNotThrowException_WhenAccountIsValid(string role, string username, string email, string? firstName, string? lastName) + { + CreateAccount(role, username, email, createdAt: null, firstName, lastName); + } + + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldPopulateCorrectly_WhenAccountIsValid(string role, string username, string email, string? firstName, string? lastName) + { + var account = CreateAccount(role, username, email, createdAt: null, firstName, lastName, ValidId); + + Assert.Multiple( + () => Assert.Equal(ValidId, account.Id), + () => Assert.Equal(role, account.RoleName), + () => Assert.Equal(username, account.Username), + () => Assert.Equal(email, account.Email), + () => Assert.Equal(firstName, account.FirstName), + () => Assert.Equal(lastName, account.LastName) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenAccountIsInvalid(string role, string username, string email, string? firstName, string? lastName) + { + Assert.Throws>( + () => CreateAccount(role, username, email, createdAt: null, firstName, lastName) + ); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/Data/RoleCreateInvalidData.cs b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/InvalidData.cs similarity index 55% rename from tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/Data/RoleCreateInvalidData.cs rename to tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/InvalidData.cs index d370e0b55..c5e7a5566 100644 --- a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/Data/RoleCreateInvalidData.cs +++ b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/InvalidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Description.Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Description; -using static RolesData; +using static Data.Roles.TestData; -public class RoleCreateInvalidData : RoleDescriptionData +public class InvalidData : TheoryData { - public RoleCreateInvalidData() + public InvalidData() { Add(InvalidDescription); Add(MinInvalidDescription); diff --git a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/RoleDescriptionData.cs b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/RoleDescriptionData.cs deleted file mode 100644 index a93d4b64b..000000000 --- a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/RoleDescriptionData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Description; - -public class RoleDescriptionData : TheoryData; diff --git a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/RoleDescriptionUnitTests.cs b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/Tests.cs similarity index 70% rename from tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/RoleDescriptionUnitTests.cs rename to tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/Tests.cs index bbfc15ff1..d4da01af2 100644 --- a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/RoleDescriptionUnitTests.cs +++ b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/Tests.cs @@ -1,12 +1,12 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Description; - + using CustomCADs.Shared.Domain.Exceptions; -using Data; -public class RoleDescriptionUnitTests : RolesBaseUnitTests +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Description; + +public class Tests : Data.Roles.BaseUnitTests { [Theory] - [ClassData(typeof(RoleCreateValidData))] + [ClassData(typeof(ValidData))] public void SetDescription_ShouldNotThrowException_WhenDescriptionIsValid(string description) { var role = CreateRole(); @@ -15,7 +15,7 @@ public void SetDescription_ShouldNotThrowException_WhenDescriptionIsValid(string } [Theory] - [ClassData(typeof(RoleCreateValidData))] + [ClassData(typeof(ValidData))] public void SetDescription_SetsDescription_WhenDescriptionIsValid(string description) { var role = CreateRole(); @@ -26,7 +26,7 @@ public void SetDescription_SetsDescription_WhenDescriptionIsValid(string descrip } [Theory] - [ClassData(typeof(RoleCreateInvalidData))] + [ClassData(typeof(InvalidData))] public void SetDescription_ThrowsException_WhenDescriptionIsInvalid(string description) { var role = CreateRole(); diff --git a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/Data/RoleCreateValidData.cs b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/ValidData.cs similarity index 54% rename from tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/Data/RoleCreateValidData.cs rename to tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/ValidData.cs index 161796d5d..a415eeb40 100644 --- a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/Data/RoleCreateValidData.cs +++ b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Description/ValidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Description.Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Description; -using static RolesData; +using static Data.Roles.TestData; -public class RoleCreateValidData : RoleDescriptionData +public class ValidData : TheoryData { - public RoleCreateValidData() + public ValidData() { Add(ValidDescription); Add(MinValidDescription); diff --git a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/Data/RoleNameInvalidData.cs b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/InvalidData.cs similarity index 55% rename from tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/Data/RoleNameInvalidData.cs rename to tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/InvalidData.cs index 8d6bfba6e..8888f1349 100644 --- a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/Data/RoleNameInvalidData.cs +++ b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/InvalidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Name.Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Name; -using static RolesData; +using static Data.Roles.TestData; -public class RoleNameInvalidData : RoleNameData +public class InvalidData : TheoryData { - public RoleNameInvalidData() + public InvalidData() { Add(InvalidName); Add(MinInvalidName); diff --git a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/RoleNameData.cs b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/RoleNameData.cs deleted file mode 100644 index e9cca3c26..000000000 --- a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/RoleNameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Name; - -public class RoleNameData : TheoryData; diff --git a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/RoleNameUnitTests.cs b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/Tests.cs similarity index 67% rename from tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/RoleNameUnitTests.cs rename to tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/Tests.cs index 9e5b06fec..cfc5a8132 100644 --- a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/RoleNameUnitTests.cs +++ b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/Tests.cs @@ -1,12 +1,12 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Name; - + using CustomCADs.Shared.Domain.Exceptions; -using Data; -public class RoleNameUnitTests : RolesBaseUnitTests +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Name; + +public class Tests : Data.Roles.BaseUnitTests { [Theory] - [ClassData(typeof(RoleNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_ShouldNotThrowException_WhenNameIsValid(string name) { var role = CreateRole(); @@ -15,7 +15,7 @@ public void SetName_ShouldNotThrowException_WhenNameIsValid(string name) } [Theory] - [ClassData(typeof(RoleNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_SetsName_WhenNameIsValid(string name) { var role = CreateRole(); @@ -26,7 +26,7 @@ public void SetName_SetsName_WhenNameIsValid(string name) } [Theory] - [ClassData(typeof(RoleNameInvalidData))] + [ClassData(typeof(InvalidData))] public void SetName_ThrowsException_WhenNameIsInvalid(string name) { var role = CreateRole(); diff --git a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/Data/RoleNameValidData.cs b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/ValidData.cs similarity index 55% rename from tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/Data/RoleNameValidData.cs rename to tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/ValidData.cs index 0887e429f..429bdaa5b 100644 --- a/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/Data/RoleNameValidData.cs +++ b/tests/UnitTests/Accounts/Domain/Roles/Behaviors/Name/ValidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Name.Data; +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Behaviors.Name; -using static RolesData; +using static Data.Roles.TestData; -public class RoleNameValidData : RoleNameData +public class ValidData : TheoryData { - public RoleNameValidData() + public ValidData() { Add(ValidName); Add(MinValidName); diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateInvalidDescriptionData.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateInvalidDescriptionData.cs deleted file mode 100644 index 7d12a3c67..000000000 --- a/tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateInvalidDescriptionData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create.Data; - -using static RolesData; - -public class RoleCreateInvalidDescriptionData : RoleCreateData -{ - public RoleCreateInvalidDescriptionData() - { - Add(ValidName, InvalidDescription); - Add(MinValidName, MinInvalidDescription); - Add(MaxValidName, MaxInvalidDescription); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateInvalidNameData.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateInvalidNameData.cs deleted file mode 100644 index 9a6a98386..000000000 --- a/tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateInvalidNameData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create.Data; - -using static RolesData; - -public class RoleCreateInvalidNameData : RoleCreateData -{ - public RoleCreateInvalidNameData() - { - Add(InvalidName, ValidDescription); - Add(MinInvalidName, MinValidDescription); - Add(MaxInvalidName, MaxValidDescription); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateValidData.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateValidData.cs deleted file mode 100644 index c361382e5..000000000 --- a/tests/UnitTests/Accounts/Domain/Roles/Create/Data/RoleCreateValidData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create.Data; - -using static RolesData; - -public class RoleCreateValidData : RoleCreateData -{ - public RoleCreateValidData() - { - Add(ValidName, ValidDescription); - Add(MinValidName, MinValidDescription); - Add(MaxValidName, MaxValidDescription); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/InvalidData.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/InvalidData.cs new file mode 100644 index 000000000..7c5903c62 --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Roles/Create/InvalidData.cs @@ -0,0 +1,19 @@ +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create; + +using static Data.Roles.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + // Name + Add(InvalidName, ValidDescription); + Add(MinInvalidName, MinValidDescription); + Add(MaxInvalidName, MaxValidDescription); + + // Description + Add(ValidName, InvalidDescription); + Add(MinValidName, MinInvalidDescription); + Add(MaxValidName, MaxInvalidDescription); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/Normal/RoleCreateUnitTests.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/Normal/RoleCreateUnitTests.cs deleted file mode 100644 index 68554194f..000000000 --- a/tests/UnitTests/Accounts/Domain/Roles/Create/Normal/RoleCreateUnitTests.cs +++ /dev/null @@ -1,44 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create.Normal; - -using CustomCADs.Shared.Domain.Exceptions; -using Data; - -public class RoleCreateUnitTests : RolesBaseUnitTests -{ - [Theory] - [ClassData(typeof(RoleCreateValidData))] - public void Create_ShouldNotThrowException_WhenRoleIsValid(string name, string description) - { - CreateRole(name, description); - } - - [Theory] - [ClassData(typeof(RoleCreateValidData))] - public void Create_ShouldPopulateProperties_WhenRoleIsValid(string name, string description) - { - var role = CreateRole(name, description); - - Assert.Multiple( - () => Assert.Equal(role.Name, name), - () => Assert.Equal(role.Description, description) - ); - } - - [Theory] - [ClassData(typeof(RoleCreateInvalidNameData))] - public void Create_ShouldThrowException_WhenNameIsInvalid(string name, string description) - { - Assert.Throws>( - () => CreateRole(name, description) - ); - } - - [Theory] - [ClassData(typeof(RoleCreateInvalidDescriptionData))] - public void Create_ShouldThrowException_WhenDescriptionIsInvalid(string name, string description) - { - Assert.Throws>( - () => CreateRole(name, description) - ); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/Normal/Tests.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/Normal/Tests.cs new file mode 100644 index 000000000..7f5c8c5cb --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Roles/Create/Normal/Tests.cs @@ -0,0 +1,35 @@ + +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create.Normal; + +public class Tests : Data.Roles.BaseUnitTests +{ + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldNotThrowException_WhenRoleIsValid(string name, string description) + { + Role.Create(name, description); + } + + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldPopulateProperties_WhenRoleIsValid(string name, string description) + { + var role = Role.Create(name, description); + + Assert.Multiple( + () => Assert.Equal(role.Name, name), + () => Assert.Equal(role.Description, description) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenRoleIsInvalid(string name, string description) + { + Assert.Throws>( + () => Role.Create(name, description) + ); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/RoleCreateData.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/RoleCreateData.cs deleted file mode 100644 index 31645f655..000000000 --- a/tests/UnitTests/Accounts/Domain/Roles/Create/RoleCreateData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create; - -public class RoleCreateData : TheoryData; diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/ValidData.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/ValidData.cs new file mode 100644 index 000000000..c652c1b60 --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Roles/Create/ValidData.cs @@ -0,0 +1,13 @@ +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create; + +using static Data.Roles.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(ValidName, ValidDescription); + Add(MinValidName, MinValidDescription); + Add(MaxValidName, MaxValidDescription); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/WithId/RoleCreateWithIdUnitTests.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/WithId/RoleCreateWithIdUnitTests.cs deleted file mode 100644 index 6ccf1c5d4..000000000 --- a/tests/UnitTests/Accounts/Domain/Roles/Create/WithId/RoleCreateWithIdUnitTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create.WithId; - -using CustomCADs.Shared.Domain.Exceptions; -using Data; -using static RolesData; - -public class RoleCreateWithIdUnitTests : RolesBaseUnitTests -{ - [Theory] - [ClassData(typeof(RoleCreateValidData))] - public void CreateWithId_ShouldNotThrowException_WhenRoleIsValid(string name, string description) - { - CreateRoleWithId(ValidId, name, description); - } - - [Theory] - [ClassData(typeof(RoleCreateValidData))] - public void CreateWithId_ShouldPopulateProperties_WhenRoleIsValid(string name, string description) - { - var role = CreateRoleWithId(ValidId, name, description); - - Assert.Multiple( - () => Assert.Equal(role.Name, name), - () => Assert.Equal(role.Description, description) - ); - } - - [Theory] - [ClassData(typeof(RoleCreateInvalidNameData))] - [ClassData(typeof(RoleCreateInvalidDescriptionData))] - public void CreateWithId_ShouldThrowException_WhenRoleIsInvalid(string name, string description) - { - Assert.Throws>( - () => CreateRoleWithId(ValidId, name, description) - ); - } -} diff --git a/tests/UnitTests/Accounts/Domain/Roles/Create/WithId/Tests.cs b/tests/UnitTests/Accounts/Domain/Roles/Create/WithId/Tests.cs new file mode 100644 index 000000000..aa43d3ffe --- /dev/null +++ b/tests/UnitTests/Accounts/Domain/Roles/Create/WithId/Tests.cs @@ -0,0 +1,37 @@ +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Accounts.Domain.Roles.Create.WithId; + +using static Data.Roles.TestData; + +public class Tests : Data.Roles.BaseUnitTests +{ + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldNotThrowException_WhenRoleIsValid(string name, string description) + { + CreateRole(name, description); + } + + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldPopulateProperties_WhenRoleIsValid(string name, string description) + { + var role = CreateRole(name, description, id: ValidId); + + Assert.Multiple( + () => Assert.Equal(role.Id, ValidId), + () => Assert.Equal(role.Name, name), + () => Assert.Equal(role.Description, description) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenRoleIsInvalid(string name, string description) + { + Assert.Throws>( + () => CreateRole(name, description) + ); + } +} diff --git a/tests/UnitTests/Accounts/Domain/Roles/RolesBaseUnitTests.cs b/tests/UnitTests/Accounts/Domain/Roles/RolesBaseUnitTests.cs deleted file mode 100644 index 1697428e0..000000000 --- a/tests/UnitTests/Accounts/Domain/Roles/RolesBaseUnitTests.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace CustomCADs.UnitTests.Accounts.Domain.Roles; - -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using static RolesData; - -public class RolesBaseUnitTests -{ - protected static Role CreateRole( - string? name = null, - string description = ValidDescription - ) => Role.Create( - name: name ?? ValidName, - description: description - ); - - protected static Role CreateRoleWithId( - RoleId? id = null, - string? name = null, - string description = ValidDescription - ) => Role.CreateWithId( - id: id ?? ValidId, - name: name ?? ValidName, - description: description - ); -} diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/AddActiveCartItemHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs similarity index 90% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/AddActiveCartItemHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs index ca424cb7a..aeafe0825 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/AddActiveCartItemHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs @@ -1,24 +1,23 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Commands.Internal.Add; using CustomCADs.Modules.Carts.Domain.Repositories; using CustomCADs.Shared.Application.UseCases.Products.Queries; - -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Add; - using CustomCADs.Shared.Application.Abstractions.Requests.Sender; using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.Customizations.Queries; using CustomCADs.Shared.Domain.TypedIds.Printing; -using Data; -using static ActiveCartsData; -public class AddActiveCartItemHandlerUnitTests : ActiveCartsBaseUnitTests +namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Add; + +using static Data.ActiveCarts.TestData; + +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly AddActiveCartItemHandler handler; private readonly Mock uow = new(); private readonly Mock> writes = new(); private readonly Mock sender = new(); - public AddActiveCartItemHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, sender.Object); @@ -34,7 +33,7 @@ public AddActiveCartItemHandlerUnitTests() } [Theory] - [ClassData(typeof(AddActiveCartValidData))] + [ClassData(typeof(ValidData))] public async Task Handle_ShouldPersistToDatabase(CustomizationId? customizationId) { // Arrange @@ -53,7 +52,7 @@ public async Task Handle_ShouldPersistToDatabase(CustomizationId? customizationI } [Theory] - [ClassData(typeof(AddActiveCartValidData))] + [ClassData(typeof(ValidData))] public async Task Handle_ShouldSendRequests(CustomizationId? customizationId) { // Arrange @@ -83,7 +82,7 @@ public async Task Handle_ShouldSendRequests(CustomizationId? customizationId) } [Theory] - [ClassData(typeof(AddActiveCartValidData))] + [ClassData(typeof(ValidData))] public async Task Handle_ShouldThrowException_WhenProductNotFound(CustomizationId? customizationId) { // Arrange diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Data/AddActiveCartValidData.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/ValidData.cs similarity index 52% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Data/AddActiveCartValidData.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/ValidData.cs index 793e0f98c..2ae55bb7b 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Data/AddActiveCartValidData.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/ValidData.cs @@ -1,12 +1,12 @@ using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Add.Data; +namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Add; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class AddActiveCartValidData : TheoryData +public class ValidData : TheoryData { - public AddActiveCartValidData() + public ValidData() { Add(ValidCustomizationId); Add(null); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs similarity index 97% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs index d0dbfa1e6..6d200e892 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/PurchaseActiveCartHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs @@ -16,9 +16,9 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.Normal; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class PurchaseActiveCartHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly PurchaseActiveCartHandler handler; private readonly Mock reads = new(); @@ -28,7 +28,7 @@ public class PurchaseActiveCartHandlerUnitTests : ActiveCartsBaseUnitTests private static readonly string paymentMethodId = string.Empty; - public PurchaseActiveCartHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object, payment.Object, raiser.Object); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidCityData.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidCityData.cs similarity index 60% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidCityData.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidCityData.cs index 02f539add..bda1e7055 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidCityData.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidCityData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; -public class PurchaseActiveCartWithDeliveryInvalidCityData : PurchaseActiveCartWithDeliveryData +public class InvalidCityData : Theory { - public PurchaseActiveCartWithDeliveryInvalidCityData() + public InvalidCityData() { Add("payment-method-id-1", "shipment-service-1", "Bulgaria", string.Empty, "Slivnitsa", null, "customcads@gmail.com"); Add("payment-method-id-2", "shipment-service-2", "Romania", null!, "Brailles", "+359359359359", null); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidCountryData.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidCountryData.cs similarity index 59% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidCountryData.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidCountryData.cs index eafe11de4..8c8893629 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidCountryData.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidCountryData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; -public class PurchaseActiveCartWithDeliveryInvalidCountryData : PurchaseActiveCartWithDeliveryData +public class InvalidCountryData : Theory { - public PurchaseActiveCartWithDeliveryInvalidCountryData() + public InvalidCountryData() { Add("payment-method-id-1", "shipment-service-1", string.Empty, "Sofia", "Slivnitsa", null, "customcads@gmail.com"); Add("payment-method-id-2", "shipment-service-2", null!, "Bucharest", "Brailles", "+359359359359", null); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidEmailData.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidEmailData.cs similarity index 72% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidEmailData.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidEmailData.cs index b9f1cda21..b0004fbbc 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidEmailData.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidEmailData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; -public class PurchaseActiveCartWithDeliveryInvalidEmailData : PurchaseActiveCartWithDeliveryData +public class InvalidEmailData : Theory { - public PurchaseActiveCartWithDeliveryInvalidEmailData() + public InvalidEmailData() { Add("payment-method-id-1", "shipment-service-1", "Bulgaria", "Sofia", "Slivnitsa", null, "@gmail.com"); Add("payment-method-id-1", "shipment-service-1", "Bulgaria", "Sofia", "Slivnitsa", null, "customcads_gmail.com"); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidPhoneData.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidPhoneData.cs similarity index 61% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidPhoneData.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidPhoneData.cs index 60d904746..5745bcd54 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidPhoneData.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidPhoneData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; -public class PurchaseActiveCartWithDeliveryInvalidPhoneData : PurchaseActiveCartWithDeliveryData +public class InvalidPhoneData : Theory { - public PurchaseActiveCartWithDeliveryInvalidPhoneData() + public InvalidPhoneData() { Add("payment-method-id-1", "shipment-service-1", "Bulgaria", "Slivnitsa", "Sofia", "0359359359", "customcads@gmail.com"); Add("payment-method-id-2", "shipment-service-2", "Romania", "Brailles", "Bucharest", "+359 359 359 359", null); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidShipmentServiceData.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidShipmentServiceData.cs similarity index 55% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidShipmentServiceData.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidShipmentServiceData.cs index 10e23ee89..0bc2f273f 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryInvalidShipmentServiceData.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/InvalidShipmentServiceData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; -public class PurchaseActiveCartWithDeliveryInvalidShipmentServiceData : PurchaseActiveCartWithDeliveryData +public class InvalidShipmentServiceData : Theory { - public PurchaseActiveCartWithDeliveryInvalidShipmentServiceData() + public InvalidShipmentServiceData() { Add("payment-method-id-1", string.Empty, "Bulgaria", "Sofia", "Slivnitsa", null, "customcads@gmail.com"); Add("payment-method-id-2", null!, "Romania", "Bucharest", "Brailles", "+359359359359", null); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryData.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryData.cs deleted file mode 100644 index ba9864c67..000000000 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; - -public class PurchaseActiveCartWithDeliveryData : TheoryData; diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs similarity index 97% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs index 37ffc702e..59a83df80 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs @@ -20,9 +20,9 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class PurchaseActiveCartWithDeliveryWithDeliveryHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly PurchaseActiveCartWithDeliveryHandler handler; private readonly Mock reads = new(); @@ -35,7 +35,7 @@ public class PurchaseActiveCartWithDeliveryWithDeliveryHandlerUnitTests : Active private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); private static readonly ContactDto contact = new(null, null); - public PurchaseActiveCartWithDeliveryWithDeliveryHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object, payment.Object, raiser.Object); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Theory.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Theory.cs new file mode 100644 index 000000000..f12e4b4ef --- /dev/null +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Theory.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; + +public class Theory : TheoryData; diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryValidData.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/ValidData.cs similarity index 61% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryValidData.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/ValidData.cs index 5117c7bdb..2f63c8628 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Data/PurchaseActiveCartWithDeliveryValidData.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/ValidData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; -public class PurchaseActiveCartWithDeliveryValidData : PurchaseActiveCartWithDeliveryData +public class ValidData : Theory { - public PurchaseActiveCartWithDeliveryValidData() + public ValidData() { Add("payment-method-id-1", "shipment-service-1", "Bulgaria", "Sofia", "Slivnitsa", null, "customcads@gmail.com"); Add("payment-method-id-2", "shipment-service-2", "Romania", "Bucharest", "Brailles", "+359359359359", null); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryValidatorUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Validator.cs similarity index 83% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryValidatorUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Validator.cs index 1a68aa7b1..73b39a2df 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/PurchaseActiveCartWithDeliveryValidatorUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Validator.cs @@ -3,15 +3,14 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; -using Data; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class PurchaseActiveCartWithDeliveryValidatorUnitTests : ActiveCartsBaseUnitTests +public class Validator : Data.ActiveCarts.BaseUnitTests { private readonly PurchaseActiveCartWithDeliveryValidator validator = new(); [Theory] - [ClassData(typeof(PurchaseActiveCartWithDeliveryValidData))] + [ClassData(typeof(ValidData))] public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -31,11 +30,11 @@ public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, } [Theory] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidShipmentServiceData))] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidCountryData))] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidCityData))] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidPhoneData))] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidEmailData))] + [ClassData(typeof(InvalidShipmentServiceData))] + [ClassData(typeof(InvalidCountryData))] + [ClassData(typeof(InvalidCityData))] + [ClassData(typeof(InvalidPhoneData))] + [ClassData(typeof(InvalidEmailData))] public async Task Validate_ShouldBeInvalid_WhenCartIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -55,7 +54,7 @@ public async Task Validate_ShouldBeInvalid_WhenCartIsNotValid(string paymentMeth } [Theory] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidShipmentServiceData))] + [ClassData(typeof(InvalidShipmentServiceData))] public async Task Validate_ShouldReturnProperErrors_WhenShipmentServiceIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -75,7 +74,7 @@ public async Task Validate_ShouldReturnProperErrors_WhenShipmentServiceIsNotVali } [Theory] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidCountryData))] + [ClassData(typeof(InvalidCountryData))] public async Task Validate_ShouldReturnProperErrors_WhenCountryIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -95,7 +94,7 @@ public async Task Validate_ShouldReturnProperErrors_WhenCountryIsNotValid(string } [Theory] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidCityData))] + [ClassData(typeof(InvalidCityData))] public async Task Validate_ShouldReturnProperErrors_WhenCityIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -115,7 +114,7 @@ public async Task Validate_ShouldReturnProperErrors_WhenCityIsNotValid(string pa } [Theory] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidPhoneData))] + [ClassData(typeof(InvalidPhoneData))] public async Task Validate_ShouldReturnProperErrors_WhenPhoneIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -135,7 +134,7 @@ public async Task Validate_ShouldReturnProperErrors_WhenPhoneIsNotValid(string p } [Theory] - [ClassData(typeof(PurchaseActiveCartWithDeliveryInvalidEmailData))] + [ClassData(typeof(InvalidEmailData))] public async Task Validate_ShouldReturnProperErrors_WhenEmailIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/DecreaseActiveCartItemQuantityHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs similarity index 94% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/DecreaseActiveCartItemQuantityHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs index 7de894e47..4c3356b47 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/DecreaseActiveCartItemQuantityHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Quantity.Decrease; using static ActiveCartItemConstants; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class DecreaseActiveCartItemQuantityHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly DecreaseActiveCartItemQuantityHandler handler; private readonly Mock reads = new(); @@ -17,7 +17,7 @@ public class DecreaseActiveCartItemQuantityHandlerUnitTests : ActiveCartsBaseUni private int oldQuantity; - public DecreaseActiveCartItemQuantityHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/IncreaseActiveCartItemQuantityHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs similarity index 94% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/IncreaseActiveCartItemQuantityHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs index c395587eb..2996f06c6 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/IncreaseActiveCartItemQuantityHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Quantity.Increase; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class IncreaseActiveCartItemQuantityHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly IncreaseActiveCartItemQuantityHandler handler; private readonly Mock reads = new(); @@ -16,7 +16,7 @@ public class IncreaseActiveCartItemQuantityHandlerUnitTests : ActiveCartsBaseUni private int oldQuantity; - public IncreaseActiveCartItemQuantityHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/RemoveActiveCartItemHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs similarity index 92% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/RemoveActiveCartItemHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs index a1fba0056..cafd7f435 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/RemoveActiveCartItemHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Remove; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class RemoveActiveCartItemHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly RemoveActiveCartItemHandler handler; private readonly Mock reads = new(); @@ -16,7 +16,7 @@ public class RemoveActiveCartItemHandlerUnitTests : ActiveCartsBaseUnitTests private readonly ActiveCartItem item = CreateItem(productId: ValidProductId); - public RemoveActiveCartItemHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/ToggleActiveCartItemForDeliveryHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs similarity index 96% rename from tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/ToggleActiveCartItemForDeliveryHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs index f739ef6ec..5af8e37d5 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/ToggleActiveCartItemForDeliveryHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs @@ -9,9 +9,9 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.ToggleForDelivery; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class ToggleActiveCartItemForDeliveryHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly ToggleActiveCartItemForDeliveryHandler handler; private readonly Mock reads = new(); @@ -22,7 +22,7 @@ public class ToggleActiveCartItemForDeliveryHandlerUnitTests : ActiveCartsBaseUn private static readonly ProductId productId1 = ProductId.New(); private static readonly ProductId productId2 = ProductId.New(); - public ToggleActiveCartItemForDeliveryHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs similarity index 81% rename from tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedApplicationEventHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs index c6eef2c24..9df5bf630 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/ProductDeletedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs @@ -4,14 +4,14 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Events.Application.ProductDeleted; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class ProductDeletedApplicationEventHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly ProductDeletedHandler handler; private readonly Mock uow = new(); - public ProductDeletedApplicationEventHandlerUnitTests() + public Tests() { handler = new(uow.Object); } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs similarity index 93% rename from tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs index c48db7978..aa0ae4d2e 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/CalculateActiveCartShipmentHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.CalculateShipment; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class CalculateActiveCartShipmentHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly CalculateActiveCartShipmentHandler handler; private readonly Mock reads = new(); @@ -20,7 +20,7 @@ public class CalculateActiveCartShipmentHandlerUnitTests : ActiveCartsBaseUnitTe new(default, string.Empty, string.Empty, default, default) ]; - public CalculateActiveCartShipmentHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/CountActiveCartItemsHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs similarity index 86% rename from tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/CountActiveCartItemsHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs index 1a6c2b543..6fa82760b 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/CountActiveCartItemsHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs @@ -3,16 +3,16 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.Count; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class CountActiveCartItemsHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly CountActiveCartItemsHandler handler; private readonly Mock reads = new(); private const int Count = 5; - public CountActiveCartItemsHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/GetActiveCartHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs similarity index 92% rename from tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/GetActiveCartHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs index 0b4b7f0a2..77344b0c7 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/GetActiveCartHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.GetAll; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class GetActiveCartHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly GetActiveCartItemsHandler handler; private readonly Mock reads = new(); @@ -19,7 +19,7 @@ public class GetActiveCartHandlerUnitTests : ActiveCartsBaseUnitTests CreateItemWithDelivery(), ]; - public GetActiveCartHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/GetActiveCartItemHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs similarity index 93% rename from tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/GetActiveCartItemHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs index 0504d4c38..b498e45df 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/GetActiveCartItemHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.GetSingle; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class GetActiveCartItemHandlerUnitTests : ActiveCartsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly GetActiveCartItemHandler handler; private readonly Mock reads = new(); @@ -17,7 +17,7 @@ public class GetActiveCartItemHandlerUnitTests : ActiveCartsBaseUnitTests private static readonly AccountId newBuyerId = AccountId.New(); - public GetActiveCartItemHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs similarity index 95% rename from tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs index fe485f410..a13200193 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/CreatePurchasedCartHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs @@ -15,9 +15,9 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Commands.Internal.Create; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class CreatePurchasedCartHandlerUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly CreatePurchasedCartHandler handler; private readonly Mock> writes = new(); @@ -31,14 +31,14 @@ public class CreatePurchasedCartHandlerUnitTests : PurchasedCartsBaseUnitTests private static readonly Dictionary cads = []; private static readonly CadId[] cadIds = [.. cads.Select(x => x.Value)]; - public CreatePurchasedCartHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, sender.Object, raiser.Object); writes.Setup(x => x.AddAsync( It.Is(x => x.BuyerId == buyerId), ct - )).ReturnsAsync(CreateCartWithId(id: ValidId)); + )).ReturnsAsync(CreateCart(id: ValidId)); sender.Setup(x => x.SendQueryAsync( It.Is(x => x.Id == buyerId), diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs similarity index 93% rename from tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs index 222b52d65..df8131df7 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs @@ -9,9 +9,9 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Events.Application.DeliveryRequested; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly ActiveCartDeliveryRequestedApplicationEventHandler handler; private readonly Mock reads = new(); @@ -22,7 +22,7 @@ public class ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests : Purch items: [CreateItem(forDelivery: true)] ); - public ActiveCartDeliveryRequestedApplicationEventHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object); diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs index f45bb89b3..6a61f4ffa 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs @@ -10,9 +10,9 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Events.Application.PaymentCompleted; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class CartPaymentCompletedApplicationEventHandlerUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly CartPaymentCompletedApplicationEventHandler handler; private readonly Mock reads = new(); @@ -23,12 +23,12 @@ public class CartPaymentCompletedApplicationEventHandlerUnitTests : PurchasedCar private const string To = "someone@gmail.com"; private const string Url = "www.somewhere.com"; - public CartPaymentCompletedApplicationEventHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, email.Object); reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) - .ReturnsAsync(CreateCartWithId()); + .ReturnsAsync(CreateCart()); sender.Setup(x => x.SendQueryAsync( It.Is(x => x.Id == ValidBuyerId), diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/PurchasedCartsBaseUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/PurchasedCartsBaseUnitTests.cs deleted file mode 100644 index a1a4aaff6..000000000 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/PurchasedCartsBaseUnitTests.cs +++ /dev/null @@ -1,60 +0,0 @@ -using CustomCADs.Modules.Carts.Domain.PurchasedCarts.Entities; -using CustomCADs.Modules.Carts.Domain.PurchasedCarts.ValueObjects; -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Carts; -using CustomCADs.Shared.Domain.TypedIds.Catalog; -using CustomCADs.Shared.Domain.TypedIds.Files; -using CustomCADs.Shared.Domain.TypedIds.Printing; - -namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts; - -using static PurchasedCartsData; -using static PurchasedCartsData.CartItemsData; - -public class PurchasedCartsBaseUnitTests -{ - protected static readonly CancellationToken ct = CancellationToken.None; - - protected static PurchasedCart CreateCartWithId(PurchasedCartId? id = null, AccountId? buyerId = null) - => PurchasedCart.CreateWithId( - id: id ?? ValidId, - buyerId: buyerId ?? ValidBuyerId - ); - - protected static PurchasedCart CreateCartWithItems(PurchasedCartId? id = null, AccountId? buyerId = null, params PurchasedCartItem[] items) - { - var purchasedCart = CreateCartWithId(id, buyerId); - purchasedCart.AddItems([.. items.Select(i => - new CartItemDto( - Price: i.Price, - CadId: i.CadId, - ProductId: i.ProductId, - ForDelivery: i.ForDelivery, - CustomizationId: i.CustomizationId, - Quantity: i.Quantity, - AddedAt: i.AddedAt - ) - )]); - - return purchasedCart; - } - - protected static PurchasedCartItem CreateItem( - PurchasedCartId? cartId = null, - ProductId? productId = null, - CadId? cadId = null, - CustomizationId? customizationId = null, - decimal? price = null, - int? quantity = null, - bool? forDelivery = null - ) => PurchasedCartItem.Create( - cartId: cartId ?? ValidId, - productId: productId ?? ValidProductId, - cadId: cadId ?? ValidCadId, - customizationId: customizationId ?? ValidCustomizationId, - price: price ?? MinValidPrice, - quantity: quantity ?? MinValidQuantity, - forDelivery: forDelivery ?? false, - addedAt: DateTimeOffset.UtcNow - ); -} diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/CountPurchasedCartsHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs similarity index 86% rename from tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/CountPurchasedCartsHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs index 520f5d565..c0a177652 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/CountPurchasedCartsHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs @@ -3,16 +3,16 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal.Count.Carts; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class CountPurchasedCartsHandlerUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly CountPurchasedCartsHandler handler; private readonly Mock reads = new(); private const int Count = 4; - public CountPurchasedCartsHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/CountPurchasedCartItemsHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs similarity index 87% rename from tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/CountPurchasedCartItemsHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs index 9c102edaa..5858754fb 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/CountPurchasedCartItemsHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs @@ -4,16 +4,16 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal.Count.Items; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class CountPurchasedCartItemsHandlerUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly CountPurchasedCartItemsHandler handler; private readonly Mock reads = new(); private static readonly Dictionary count = new() { [ValidId] = 4 }; - public CountPurchasedCartItemsHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/GetAllPurchasedCartsUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs similarity index 87% rename from tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/GetAllPurchasedCartsUnitTests.cs rename to tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs index 326bc8619..2bad97691 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/GetAllPurchasedCartsUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs @@ -5,20 +5,20 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal.GetAll; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class GetAllPurchasedCartsUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly GetAllPurchasedCartsHandler handler; private readonly Mock reads = new(); private readonly PurchasedCart[] carts = [ - CreateCartWithId(id: ValidId), - CreateCartWithId(id: ValidId), + CreateCart(id: ValidId), + CreateCart(id: ValidId), ]; private readonly PurchasedCartQuery query; - public GetAllPurchasedCartsUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/GetPurchasedCartByIdUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs similarity index 91% rename from tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/GetPurchasedCartByIdUnitTests.cs rename to tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs index 9f17fa9e4..e21b361bf 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/GetPurchasedCartByIdUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs @@ -6,18 +6,18 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal.GetById; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class GetPurchasedCartByIdUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly GetPurchasedCartByIdHandler handler; private readonly Mock reads = new(); private readonly Mock sender = new(); private const string Buyer = "PDMatsaliev20"; - private readonly PurchasedCart cart = CreateCartWithId(); + private readonly PurchasedCart cart = CreateCart(); - public GetPurchasedCartByIdUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/GetPurchasedCartPaymentStatusesHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/Tests.cs similarity index 87% rename from tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/GetPurchasedCartPaymentStatusesHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/Tests.cs index 1b3c60c04..5a990d061 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/GetPurchasedCartPaymentStatusesHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal.GetPaymentStatuses; -public class GetPurchasedCartPaymentStatusesHandlerUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly GetPurchasedCartPaymentStatusesHandler handler = new(); diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/GetPurchasedCartSortingsHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/Tests.cs similarity index 87% rename from tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/GetPurchasedCartSortingsHandlerUnitTests.cs rename to tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/Tests.cs index 1e6acaebe..66038e6ca 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/GetPurchasedCartSortingsHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal.GetSortings; -public class GetPurchasedCartSortingsHandlerUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly GetPurchasedCartSortingsHandler handler = new(); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/ActiveCartsBaseUnitTests.cs b/tests/UnitTests/Carts/Data/ActiveCarts/BaseUnitTests.cs similarity index 77% rename from tests/UnitTests/Carts/Application/ActiveCarts/ActiveCartsBaseUnitTests.cs rename to tests/UnitTests/Carts/Data/ActiveCarts/BaseUnitTests.cs index 51e0b60c5..56528ba66 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/ActiveCartsBaseUnitTests.cs +++ b/tests/UnitTests/Carts/Data/ActiveCarts/BaseUnitTests.cs @@ -1,12 +1,13 @@ -using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Modules.Carts.Domain.ActiveCarts; +using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Catalog; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts; +namespace CustomCADs.UnitTests.Carts.Data.ActiveCarts; -using static ActiveCartsData; +using static TestData; -public class ActiveCartsBaseUnitTests +public class BaseUnitTests { protected static readonly CancellationToken ct = CancellationToken.None; diff --git a/tests/UnitTests/Carts/Data/ActiveCartsData.cs b/tests/UnitTests/Carts/Data/ActiveCarts/TestData.cs similarity index 82% rename from tests/UnitTests/Carts/Data/ActiveCartsData.cs rename to tests/UnitTests/Carts/Data/ActiveCarts/TestData.cs index c9e1f195b..6459acdf8 100644 --- a/tests/UnitTests/Carts/Data/ActiveCartsData.cs +++ b/tests/UnitTests/Carts/Data/ActiveCarts/TestData.cs @@ -1,13 +1,13 @@ -using CustomCADs.Modules.Carts.Domain.ActiveCarts; +using CustomCADs.Modules.Carts.Domain.ActiveCarts; using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Catalog; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.UnitTests.Carts.Data; +namespace CustomCADs.UnitTests.Carts.Data.ActiveCarts; using static ActiveCartItemConstants; -public static class ActiveCartsData +public static class TestData { public const int MinValidQuantity = QuantityMin + 1; public const int MaxValidQuantity = QuantityMax - 1; diff --git a/tests/UnitTests/Carts/Data/PurchasedCarts/BaseUnitTests.cs b/tests/UnitTests/Carts/Data/PurchasedCarts/BaseUnitTests.cs new file mode 100644 index 000000000..1385d6b8a --- /dev/null +++ b/tests/UnitTests/Carts/Data/PurchasedCarts/BaseUnitTests.cs @@ -0,0 +1,98 @@ +using CustomCADs.Modules.Carts.Domain.ActiveCarts; +using CustomCADs.Modules.Carts.Domain.PurchasedCarts; +using CustomCADs.Modules.Carts.Domain.PurchasedCarts.Entities; +using CustomCADs.Modules.Carts.Domain.PurchasedCarts.ValueObjects; +using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Carts; +using CustomCADs.Shared.Domain.TypedIds.Catalog; +using CustomCADs.Shared.Domain.TypedIds.Files; +using CustomCADs.Shared.Domain.TypedIds.Printing; + +namespace CustomCADs.UnitTests.Carts.Data.PurchasedCarts; + +using static TestData; +using static TestData.CartItemsData; + +public class BaseUnitTests +{ + protected static readonly CancellationToken ct = CancellationToken.None; + + protected static PurchasedCart CreateCart(AccountId? buyerId = null, PurchasedCartId? id = null) + => PurchasedCart.CreateWithId(id ?? ValidId, buyerId ?? ValidBuyerId); + + protected static PurchasedCart CreateCartWithItems( + AccountId buyerId, + ActiveCartItem[] items, + Dictionary prices, + Dictionary productCads, + Dictionary itemCads + ) + { + var purchasedCart = CreateCart(buyerId); + + purchasedCart.AddItems([.. items.Select(item => { + decimal price = prices[item.ProductId]; + CadId productCadId = productCads[item.ProductId]; + CadId itemCadId = itemCads[productCadId]; + + return new CartItemDto(price, itemCadId, item.ProductId, item.ForDelivery, item.CustomizationId, item.Quantity, item.AddedAt); + })]); + + return purchasedCart; + } + + protected static PurchasedCart CreateCartWithItems(PurchasedCartId? id = null, AccountId? buyerId = null, params PurchasedCartItem[] items) + { + var purchasedCart = CreateCart(buyerId, id); + purchasedCart.AddItems([.. items.Select(i => + new CartItemDto( + Price: i.Price, + CadId: i.CadId, + ProductId: i.ProductId, + ForDelivery: i.ForDelivery, + CustomizationId: i.CustomizationId, + Quantity: i.Quantity, + AddedAt: i.AddedAt + ) + )]); + + return purchasedCart; + } + + protected static ActiveCartItem[] CreateItems(int noDeliveryCount, int forDeliveryCount) + { + List items = []; + + for (int i = 0; i < noDeliveryCount; i++) + { + items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId)); + items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId)); + } + for (int i = 0; i < forDeliveryCount; i++) + { + items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId, CartItemsData.ValidCustomizationId)); + items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId, CartItemsData.ValidCustomizationId)); + } + + return [.. items]; + } + + protected static PurchasedCartItem CreateItem( + PurchasedCartId? cartId = null, + ProductId? productId = null, + CadId? cadId = null, + CustomizationId? customizationId = null, + decimal? price = null, + int? quantity = null, + bool? forDelivery = null + ) => PurchasedCartItem.Create( + cartId: cartId ?? ValidId, + productId: productId ?? ValidProductId, + cadId: cadId ?? ValidCadId, + customizationId: customizationId ?? ValidCustomizationId, + price: price ?? MinValidPrice, + quantity: quantity ?? MinValidQuantity, + forDelivery: forDelivery ?? false, + addedAt: DateTimeOffset.UtcNow + ); +} diff --git a/tests/UnitTests/Carts/Data/PurchasedCartsData.cs b/tests/UnitTests/Carts/Data/PurchasedCarts/TestData.cs similarity index 89% rename from tests/UnitTests/Carts/Data/PurchasedCartsData.cs rename to tests/UnitTests/Carts/Data/PurchasedCarts/TestData.cs index da837e63c..334e9cef0 100644 --- a/tests/UnitTests/Carts/Data/PurchasedCartsData.cs +++ b/tests/UnitTests/Carts/Data/PurchasedCarts/TestData.cs @@ -1,4 +1,4 @@ -using CustomCADs.Modules.Carts.Domain.PurchasedCarts; +using CustomCADs.Modules.Carts.Domain.PurchasedCarts; using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Carts; using CustomCADs.Shared.Domain.TypedIds.Catalog; @@ -6,11 +6,11 @@ using CustomCADs.Shared.Domain.TypedIds.Files; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.UnitTests.Carts.Data; +namespace CustomCADs.UnitTests.Carts.Data.PurchasedCarts; using static PurchasedCartConstants.PurchasedCartItems; -public static class PurchasedCartsData +public static class TestData { public static class CartItemsData { diff --git a/tests/UnitTests/Carts/Domain/ActiveCarts/ActiveCartItemsBaseUnitTests.cs b/tests/UnitTests/Carts/Domain/ActiveCarts/ActiveCartItemsBaseUnitTests.cs deleted file mode 100644 index b9f0532f8..000000000 --- a/tests/UnitTests/Carts/Domain/ActiveCarts/ActiveCartItemsBaseUnitTests.cs +++ /dev/null @@ -1,28 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Catalog; -using CustomCADs.Shared.Domain.TypedIds.Printing; - -namespace CustomCADs.UnitTests.Carts.Domain.ActiveCarts; - -using static ActiveCartsData; - -public class ActiveCartItemsBaseUnitTests -{ - protected static ActiveCartItem CreateItem( - AccountId? buyerId = null, - ProductId? productId = null - ) => ActiveCartItem.Create( - buyerId: buyerId ?? ValidBuyerId, - productId: productId ?? ValidProductId - ); - - protected static ActiveCartItem CreateItemWithDelivery( - AccountId? buyerId = null, - ProductId? productId = null, - CustomizationId? customizationId = null - ) => ActiveCartItem.Create( - buyerId: buyerId ?? ValidBuyerId, - productId: productId ?? ValidProductId, - customizationId: customizationId ?? ValidCustomizationId - ); -} diff --git a/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/DecreaseQuantity/ActiveCartItemDecreaseQuantityUnitTests.cs b/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/DecreaseQuantity/Tests.cs similarity index 89% rename from tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/DecreaseQuantity/ActiveCartItemDecreaseQuantityUnitTests.cs rename to tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/DecreaseQuantity/Tests.cs index 1ce7fedd4..23484c0b0 100644 --- a/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/DecreaseQuantity/ActiveCartItemDecreaseQuantityUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/DecreaseQuantity/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Carts.Domain.ActiveCarts.Behaviors.DecreaseQuantity; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class ActiveCartItemDecreaseQuantityUnitTests : ActiveCartItemsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { [Theory] [InlineData(MaxValidQuantity)] diff --git a/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/IncreaseQuantity/ActiveCartItemIncreaseQuantityUnitTests.cs b/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/IncreaseQuantity/Tests.cs similarity index 88% rename from tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/IncreaseQuantity/ActiveCartItemIncreaseQuantityUnitTests.cs rename to tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/IncreaseQuantity/Tests.cs index f4da539a5..c09236796 100644 --- a/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/IncreaseQuantity/ActiveCartItemIncreaseQuantityUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/IncreaseQuantity/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Carts.Domain.ActiveCarts.Behaviors.IncreaseQuantity; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class ActiveCartItemIncreaseQuantityUnitTests : ActiveCartItemsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { [Theory] [InlineData(MaxValidQuantity)] diff --git a/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetForDelivery/ActiveCartItemSetForDeliveryUnitTests.cs b/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetForDelivery/Tests.cs similarity index 81% rename from tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetForDelivery/ActiveCartItemSetForDeliveryUnitTests.cs rename to tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetForDelivery/Tests.cs index cfdaadd50..a018676dc 100644 --- a/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetForDelivery/ActiveCartItemSetForDeliveryUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetForDelivery/Tests.cs @@ -1,8 +1,8 @@ namespace CustomCADs.UnitTests.Carts.Domain.ActiveCarts.Behaviors.SetForDelivery; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class ActiveCartItemSetForDeliveryUnitTests : ActiveCartItemsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { [Fact] public void SetForDelivery_ShouldNotThrowException() diff --git a/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetNoDelivery/ActiveCartItemSetNoDeliveryUnitTests.cs b/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetNoDelivery/Tests.cs similarity index 80% rename from tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetNoDelivery/ActiveCartItemSetNoDeliveryUnitTests.cs rename to tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetNoDelivery/Tests.cs index cd5b6ac99..ebc4b9320 100644 --- a/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetNoDelivery/ActiveCartItemSetNoDeliveryUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/ActiveCarts/Behaviors/SetNoDelivery/Tests.cs @@ -1,6 +1,6 @@ namespace CustomCADs.UnitTests.Carts.Domain.ActiveCarts.Behaviors.SetNoDelivery; -public class ActiveCartItemSetNoDeliveryUnitTests : ActiveCartItemsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { [Fact] public void SetForDelivery_ShouldNotThrowException() diff --git a/tests/UnitTests/Carts/Domain/ActiveCarts/Create/ForDelivery/ActiveCartItemCreateUnitTests.cs b/tests/UnitTests/Carts/Domain/ActiveCarts/Create/ForDelivery/Tests.cs similarity index 87% rename from tests/UnitTests/Carts/Domain/ActiveCarts/Create/ForDelivery/ActiveCartItemCreateUnitTests.cs rename to tests/UnitTests/Carts/Domain/ActiveCarts/Create/ForDelivery/Tests.cs index 1108bac00..cdb324a2e 100644 --- a/tests/UnitTests/Carts/Domain/ActiveCarts/Create/ForDelivery/ActiveCartItemCreateUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/ActiveCarts/Create/ForDelivery/Tests.cs @@ -1,8 +1,8 @@ namespace CustomCADs.UnitTests.Carts.Domain.ActiveCarts.Create.ForDelivery; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class ActiveCartItemCreateUnitTests : ActiveCartItemsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { [Fact] public void Create_ShouldNotThrowException_WhenCartIsValid() diff --git a/tests/UnitTests/Carts/Domain/ActiveCarts/Create/NoDelivery/ActiveCartItemCreateUnitTests.cs b/tests/UnitTests/Carts/Domain/ActiveCarts/Create/NoDelivery/Tests.cs similarity index 84% rename from tests/UnitTests/Carts/Domain/ActiveCarts/Create/NoDelivery/ActiveCartItemCreateUnitTests.cs rename to tests/UnitTests/Carts/Domain/ActiveCarts/Create/NoDelivery/Tests.cs index 68d7406fe..a5a6b3701 100644 --- a/tests/UnitTests/Carts/Domain/ActiveCarts/Create/NoDelivery/ActiveCartItemCreateUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/ActiveCarts/Create/NoDelivery/Tests.cs @@ -1,8 +1,8 @@ namespace CustomCADs.UnitTests.Carts.Domain.ActiveCarts.Create.NoDelivery; -using static ActiveCartsData; +using static Data.ActiveCarts.TestData; -public class ActiveCartItemCreateUnitTests : ActiveCartItemsBaseUnitTests +public class Tests : Data.ActiveCarts.BaseUnitTests { [Fact] public void Create_ShouldNotThrowException_WhenCartIsValid() diff --git a/tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/AddItems/PurchasedCartAddItemsUnitTests.cs b/tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/AddItems/Tests.cs similarity index 81% rename from tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/AddItems/PurchasedCartAddItemsUnitTests.cs rename to tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/AddItems/Tests.cs index 6cfd1bf18..f51662d56 100644 --- a/tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/AddItems/PurchasedCartAddItemsUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/AddItems/Tests.cs @@ -4,14 +4,14 @@ namespace CustomCADs.UnitTests.Carts.Domain.PurchasedCarts.Behaviors.AddItems; using static PurchasedCartConstants; -using static PurchasedCartsData.CartItemsData; +using static Data.PurchasedCarts.TestData.CartItemsData; -public class PurchasedCartAddItemsUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { [Fact] public void AddItems_ShouldNotThrowException_WhenItemsCountIsValid() { - CreateCartWithId().AddItems([ + CreateCart().AddItems([ new(MaxValidPrice, ValidCadId, ValidProductId, false, null, 1, DateTimeOffset.UtcNow) ]); } @@ -19,7 +19,7 @@ public void AddItems_ShouldNotThrowException_WhenItemsCountIsValid() [Fact] public void AddItems_ShouldThrowException_WhenItemsCountIsNotValid() { - var purchasedCart = CreateCartWithId(); + var purchasedCart = CreateCart(); for (int i = 0; i < ItemsCountMax; i++) { purchasedCart.AddItems([ diff --git a/tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/ShipmentId/PurchasedCartSetShipmentIdUnitTests.cs b/tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/ShipmentId/Tests.cs similarity index 82% rename from tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/ShipmentId/PurchasedCartSetShipmentIdUnitTests.cs rename to tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/ShipmentId/Tests.cs index fe050391c..5a1bf1e63 100644 --- a/tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/ShipmentId/PurchasedCartSetShipmentIdUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/PurchasedCarts/Behaviors/ShipmentId/Tests.cs @@ -3,14 +3,14 @@ namespace CustomCADs.UnitTests.Carts.Domain.PurchasedCarts.Behaviors.ShipmentId; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class PurchasedCartSetShipmentIdUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { [Fact] public void SetShipmentId_ShouldNotThrowException_WhenIsDelivery() { - var items = CreateItems(1, 1); + var items = CreateItems(noDeliveryCount: 1, forDeliveryCount: 1); var cads = items.ToDictionary(x => x.ProductId, x => CadId.New()); CreateCartWithItems( @@ -25,7 +25,7 @@ public void SetShipmentId_ShouldNotThrowException_WhenIsDelivery() [Fact] public void SetShipmentId_ShouldThrowException_WhenNotDelivery() { - var items = CreateItems(2, 0); + var items = CreateItems(noDeliveryCount: 2, forDeliveryCount: 0); var cads = items.ToDictionary(x => x.ProductId, x => CadId.New()); Assert.Throws>( diff --git a/tests/UnitTests/Carts/Domain/PurchasedCarts/Create/Normal/PurchasedCartCreateUnitTests.cs b/tests/UnitTests/Carts/Domain/PurchasedCarts/Create/Normal/Tests.cs similarity index 62% rename from tests/UnitTests/Carts/Domain/PurchasedCarts/Create/Normal/PurchasedCartCreateUnitTests.cs rename to tests/UnitTests/Carts/Domain/PurchasedCarts/Create/Normal/Tests.cs index 29c88b08b..c73af8363 100644 --- a/tests/UnitTests/Carts/Domain/PurchasedCarts/Create/Normal/PurchasedCartCreateUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/PurchasedCarts/Create/Normal/Tests.cs @@ -1,20 +1,19 @@ namespace CustomCADs.UnitTests.Carts.Domain.PurchasedCarts.Create.Normal; -using CustomCADs.UnitTests.Carts.Domain.PurchasedCarts; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class PurchasedCartCreateUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { [Fact] public void Create_ShouldNotThrowException() { - CreateCart(buyerId: ValidBuyerId); + PurchasedCart.Create(ValidBuyerId); } [Fact] public void Create_ShouldPopulateProperties() { - var cart = CreateCart(buyerId: ValidBuyerId); + var cart = PurchasedCart.Create(ValidBuyerId); Assert.Multiple( () => Assert.Equal(ValidBuyerId, cart.BuyerId), diff --git a/tests/UnitTests/Carts/Domain/PurchasedCarts/Create/WithId/PurchasedCartCreateWithIdUnitTests.cs b/tests/UnitTests/Carts/Domain/PurchasedCarts/Create/WithId/Tests.cs similarity index 53% rename from tests/UnitTests/Carts/Domain/PurchasedCarts/Create/WithId/PurchasedCartCreateWithIdUnitTests.cs rename to tests/UnitTests/Carts/Domain/PurchasedCarts/Create/WithId/Tests.cs index b0cbed958..7b4924dec 100644 --- a/tests/UnitTests/Carts/Domain/PurchasedCarts/Create/WithId/PurchasedCartCreateWithIdUnitTests.cs +++ b/tests/UnitTests/Carts/Domain/PurchasedCarts/Create/WithId/Tests.cs @@ -1,19 +1,19 @@ namespace CustomCADs.UnitTests.Carts.Domain.PurchasedCarts.Create.WithId; -using static PurchasedCartsData; +using static Data.PurchasedCarts.TestData; -public class PurchasedCartCreateWithIdUnitTests : PurchasedCartsBaseUnitTests +public class Tests : Data.PurchasedCarts.BaseUnitTests { [Fact] - public void CreateWithId_ShouldNotThrowException() + public void Create_ShouldNotThrowException() { - CreateCartWithId(ValidId, ValidBuyerId); + CreateCart(ValidBuyerId, ValidId); } [Fact] - public void CreateWithId_ShouldPopulateProperties() + public void Create_ShouldPopulateProperties() { - var cart = CreateCartWithId(ValidId, ValidBuyerId); + var cart = CreateCart(ValidBuyerId, ValidId); Assert.Multiple( () => Assert.Equal(ValidId, cart.Id), diff --git a/tests/UnitTests/Carts/Domain/PurchasedCarts/PurchasedCartsBaseUnitTests.cs b/tests/UnitTests/Carts/Domain/PurchasedCarts/PurchasedCartsBaseUnitTests.cs deleted file mode 100644 index dc6dab232..000000000 --- a/tests/UnitTests/Carts/Domain/PurchasedCarts/PurchasedCartsBaseUnitTests.cs +++ /dev/null @@ -1,57 +0,0 @@ -using CustomCADs.Modules.Carts.Domain.PurchasedCarts.ValueObjects; -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Carts; -using CustomCADs.Shared.Domain.TypedIds.Catalog; -using CustomCADs.Shared.Domain.TypedIds.Files; - -namespace CustomCADs.UnitTests.Carts.Domain.PurchasedCarts; - -using static PurchasedCartsData; - -public class PurchasedCartsBaseUnitTests -{ - protected static PurchasedCart CreateCart(AccountId? buyerId = null) - => PurchasedCart.Create(buyerId ?? ValidBuyerId); - - protected static PurchasedCart CreateCartWithId(PurchasedCartId? id = null, AccountId? buyerId = null) - => PurchasedCart.CreateWithId(id ?? ValidId, buyerId ?? ValidBuyerId); - - protected static PurchasedCart CreateCartWithItems( - AccountId buyerId, - ActiveCartItem[] items, - Dictionary prices, - Dictionary productCads, - Dictionary itemCads - ) - { - var purchasedCart = CreateCart(buyerId); - - purchasedCart.AddItems([.. items.Select(item => { - decimal price = prices[item.ProductId]; - CadId productCadId = productCads[item.ProductId]; - CadId itemCadId = itemCads[productCadId]; - - return new CartItemDto(price, itemCadId, item.ProductId, item.ForDelivery, item.CustomizationId, item.Quantity, item.AddedAt); - })]); - - return purchasedCart; - } - - protected static ActiveCartItem[] CreateItems(int noDeliveryCount, int forDeliveryCount) - { - List items = []; - - for (int i = 0; i < noDeliveryCount; i++) - { - items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId)); - items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId)); - } - for (int i = 0; i < forDeliveryCount; i++) - { - items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId, CartItemsData.ValidCustomizationId)); - items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId, CartItemsData.ValidCustomizationId)); - } - - return [.. items]; - } -} diff --git a/tests/UnitTests/Catalog/Application/Categories/CategoriesBaseUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/CategoriesBaseUnitTests.cs deleted file mode 100644 index f2915000b..000000000 --- a/tests/UnitTests/Catalog/Application/Categories/CategoriesBaseUnitTests.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Application.Categories; - -using static CategoriesData; - -public class CategoriesBaseUnitTests -{ - public static readonly CancellationToken ct = CancellationToken.None; - - protected static Category CreateCategory(CategoryId? id = null, string name = ValidName, string description = ValidDescription) - => Category.CreateWithId(id ?? ValidId, name, description); -} diff --git a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/CreateCategoryHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs similarity index 92% rename from tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/CreateCategoryHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs index 658d77843..b0e14e52c 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/CreateCategoryHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs @@ -4,16 +4,16 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Commands.Internal.Create; -using static CategoriesData; +using static Data.Categories.TestData; -public class CreateCategoryHandlerUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { private readonly CreateCategoryHandler handler; private readonly Mock writes = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); - public CreateCategoryHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, cache.Object); diff --git a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/DeleteCategoryHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs similarity index 88% rename from tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/DeleteCategoryHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs index c4cf97c5e..9d8d6d320 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/DeleteCategoryHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Commands.Internal.Delete; -using static CategoriesData; +using static Data.Categories.TestData; -public class DeleteCategoryHandlerUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { private readonly DeleteCategoryHandler handler; private readonly Mock> cache = new(); @@ -15,12 +15,12 @@ public class DeleteCategoryHandlerUnitTests : CategoriesBaseUnitTests private readonly Mock writes = new(); private readonly Mock reads = new(); - public DeleteCategoryHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, cache.Object); reads.Setup(v => v.SingleByIdAsync(ValidId, true, ct)) - .ReturnsAsync(CreateCategory(ValidId, ValidName, ValidDescription)); + .ReturnsAsync(CreateCategory(ValidName, ValidDescription)); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/EditCategoryHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs similarity index 93% rename from tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/EditCategoryHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs index 0e9fe5891..34fbf97d4 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/EditCategoryHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs @@ -4,9 +4,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Commands.Internal.Edit; -using static CategoriesData; +using static Data.Categories.TestData; -public class EditCategoryHandlerUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { private readonly EditCategoryHandler handler; private readonly Mock reads = new(); @@ -15,7 +15,7 @@ public class EditCategoryHandlerUnitTests : CategoriesBaseUnitTests private readonly Category category = CreateCategory(); - public EditCategoryHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, cache.Object); reads.Setup(v => v.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(category); diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/GetAllCategoriesHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs similarity index 78% rename from tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/GetAllCategoriesHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs index 6844d5240..226bc691a 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/GetAllCategoriesHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs @@ -4,21 +4,21 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Internal.GetAll; -using static CategoriesData; +using static Data.Categories.TestData; -public class GetAllCategoriesHandlerUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { private readonly GetAllCategoriesHandler handler; private readonly Mock reads = new(); private readonly Mock> cache = new(); private readonly Category[] categories = [ - Category.CreateWithId(CategoryId.New(1), ValidName, ValidDescription), - Category.CreateWithId(CategoryId.New(2), MinValidName, MinValidDescription), - Category.CreateWithId(CategoryId.New(3), MaxValidName, MaxValidDescription) + CreateCategory(ValidName, ValidDescription, CategoryId.New(1)), + CreateCategory(MinValidName, MinValidDescription, CategoryId.New(2)), + CreateCategory(MaxValidName, MaxValidDescription, CategoryId.New(3)) ]; - public GetAllCategoriesHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/GetCategoryByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs similarity index 88% rename from tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/GetCategoryByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs index 9e51f6886..244c0f242 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/GetCategoryByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs @@ -3,15 +3,15 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Internal.GetById; -using static CategoriesData; +using static Data.Categories.TestData; -public class GetCategoryByIdHandlerUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { private readonly GetCategoryByIdHandler handler; private readonly Mock reads = new(); private readonly Mock> cache = new(); - public GetCategoryByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/BatchGetCategoryByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs similarity index 87% rename from tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/BatchGetCategoryByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs index cd5fc110d..8d3bd0e6e 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/BatchGetCategoryByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs @@ -4,9 +4,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Shared.BatchGetById; -using static CategoriesData; +using static Data.Categories.TestData; -public class BatchGetCategoryByIdHandlerUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { private readonly BatchGetCategoryByIdHandler handler; private readonly Mock reads = new(); @@ -17,9 +17,9 @@ public class BatchGetCategoryByIdHandlerUnitTests : CategoriesBaseUnitTests CategoryId.New(2), CategoryId.New(3) ]; - private static readonly Category[] categories = [.. ids.Select(id => CreateCategory(id, ValidName, ValidDescription))]; + private static readonly Category[] categories = [.. ids.Select(id => CreateCategory(id: id))]; - public BatchGetCategoryByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); cache.Setup(x => x.GetOrCreateAsync(It.IsAny>>>())).ReturnsAsync(categories); diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/GetCategoryByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs similarity index 89% rename from tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/GetCategoryByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs index 026113bed..11142ec2d 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/GetCategoryByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs @@ -4,15 +4,15 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Shared.GetById; -using static CategoriesData; +using static Data.Categories.TestData; -public class GetCategoryByIdHandlerUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { private readonly GetCategoryNameByIdHandler handler; private readonly Mock reads = new(); private readonly Mock> cache = new(); - public GetCategoryByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/GetCategoryExistsByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs similarity index 87% rename from tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/GetCategoryExistsByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs index c9ebf9087..b104b89e0 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/GetCategoryExistsByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs @@ -4,14 +4,14 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Shared.GetExists; -using static CategoriesData; +using static Data.Categories.TestData; -public class GetCategoryExistsByIdHandlerUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { private readonly GetCategoryExistsByIdHandler handler; private readonly Mock reads = new(); - public GetCategoryExistsByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/RemoveProductHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs similarity index 96% rename from tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/RemoveProductHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs index 75f31b616..2be438cb7 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/RemoveProductHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs @@ -11,9 +11,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Admin.Remove; -using static ProductsData; +using static Data.Products.TestData; -public class RemoveProductHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly RemoveProductHandler handler; private readonly Mock reads = new(); @@ -23,7 +23,7 @@ public class RemoveProductHandlerUnitTests : ProductsBaseUnitTests private readonly AccountId AdminId = AccountId.New(); - public RemoveProductHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/CreateProductHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs similarity index 97% rename from tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/CreateProductHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs index 9617f2ff6..3979e8f1d 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/CreateProductHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs @@ -13,9 +13,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Creator.Create; -using static ProductsData; +using static Data.Products.TestData; -public class CreateProductHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly CreateProductHandler handler; private readonly Mock writes = new(); @@ -24,9 +24,9 @@ public class CreateProductHandlerUnitTests : ProductsBaseUnitTests private readonly Mock raiser = new(); private const decimal Volume = 15; - private readonly Product product = CreateProductWithId(id: ValidId); + private readonly Product product = CreateProduct(id: ValidId); - public CreateProductHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs similarity index 94% rename from tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs index 998016a63..9774e9eb5 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/DeleteProductHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs @@ -12,9 +12,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Creator.Delete; -using static ProductsData; +using static Data.Products.TestData; -public class DeleteProductHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly DeleteProductHandler handler; private readonly Mock reads = new(); @@ -23,9 +23,9 @@ public class DeleteProductHandlerUnitTests : ProductsBaseUnitTests private readonly Mock sender = new(); private readonly Mock raiser = new(); - private readonly Product product = CreateProductWithId(); + private readonly Product product = CreateProduct(); - public DeleteProductHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/EditProductHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs similarity index 96% rename from tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/EditProductHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs index 865a565d4..11a876d89 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/EditProductHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs @@ -11,9 +11,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Creator.Edit; -using static ProductsData; +using static Data.Products.TestData; -public class EditProductHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly EditProductHandler handler; private readonly Mock reads = new(); @@ -21,9 +21,9 @@ public class EditProductHandlerUnitTests : ProductsBaseUnitTests private readonly Mock sender = new(); private readonly Mock raiser = new(); - private readonly Product product = CreateProductWithId(); + private readonly Product product = CreateProduct(); - public EditProductHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/AddProductTagHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs similarity index 94% rename from tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/AddProductTagHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs index 808b67a73..d53bd4987 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/AddProductTagHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs @@ -10,9 +10,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Designer.AddTag; -using static ProductsData; +using static Data.Products.TestData; -public class AddProductTagHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly AddProductTagHandler handler; private readonly Mock reads = new(); @@ -24,7 +24,7 @@ public class AddProductTagHandlerUnitTests : ProductsBaseUnitTests private readonly static TagId tagId = TagId.New(); private readonly static AccountId callerId = AccountId.New(); - public AddProductTagHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/RemoveProductTagHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs similarity index 94% rename from tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/RemoveProductTagHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs index 276635823..41bb320f3 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/RemoveProductTagHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs @@ -10,9 +10,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Designer.RemoveTag; -using static ProductsData; +using static Data.Products.TestData; -public class RemoveProductTagHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly RemoveProductTagHandler handler; private readonly Mock reads = new(); @@ -24,7 +24,7 @@ public class RemoveProductTagHandlerUnitTests : ProductsBaseUnitTests private readonly static TagId tagId = TagId.New(); private readonly static AccountId callerId = AccountId.New(); - public RemoveProductTagHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/ReportProductHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs similarity index 96% rename from tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/ReportProductHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs index bf4f4bdff..6b4c53ebf 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/ReportProductHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs @@ -10,9 +10,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Designer.Report; -using static ProductsData; +using static Data.Products.TestData; -public class ReportProductHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly ReportProductHandler handler; private readonly Mock reads = new(); @@ -22,7 +22,7 @@ public class ReportProductHandlerUnitTests : ProductsBaseUnitTests private readonly Product product = CreateProduct(); - public ReportProductHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/ValidateProductHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs similarity index 96% rename from tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/ValidateProductHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs index 109bf8ac4..019388ca1 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/ValidateProductHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs @@ -10,9 +10,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Designer.Validate; -using static ProductsData; +using static Data.Products.TestData; -public class ValidateProductHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly ValidateProductHandler handler; private readonly Mock reads = new(); @@ -22,7 +22,7 @@ public class ValidateProductHandlerUnitTests : ProductsBaseUnitTests private readonly Product product = CreateProduct(); - public ValidateProductHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductCreatedHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs similarity index 85% rename from tests/UnitTests/Catalog/Application/Products/Events/Application/ProductCreatedHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs index 5ba5e10e7..739c19b1f 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductCreatedHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs @@ -2,11 +2,11 @@ using CustomCADs.Modules.Catalog.Domain.Repositories; using CustomCADs.Modules.Catalog.Domain.Repositories.Writes; -namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application; +namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application.Created; -using static ProductsData; +using static Data.Products.TestData; -public class ProductCreatedHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly ProductCreatedHandler handler; private readonly Mock writes = new(); @@ -14,7 +14,7 @@ public class ProductCreatedHandlerUnitTests : ProductsBaseUnitTests private static readonly TagId[] TagIds = []; - public ProductCreatedHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object); } diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductsPurchasedHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs similarity index 84% rename from tests/UnitTests/Catalog/Application/Products/Events/Application/ProductsPurchasedHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs index 22ab27041..241b1cc30 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductsPurchasedHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs @@ -2,16 +2,16 @@ using CustomCADs.Modules.Catalog.Domain.Repositories; using CustomCADs.Shared.Application.Events.Catalog; -namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application; +namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application.Purchased; -public class ProductsPurchasedHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly ProductsPurchasedHandler handler; private readonly Mock uow = new(); private static readonly ProductId[] ids = []; - public ProductsPurchasedHandlerUnitTests() + public Tests() { handler = new(uow.Object); } diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductViewedHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs similarity index 97% rename from tests/UnitTests/Catalog/Application/Products/Events/Application/ProductViewedHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs index 41107864f..ff7e0211f 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/ProductViewedHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs @@ -7,12 +7,12 @@ using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application; +namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application.Viewed; using static DomainConstants; -using static ProductsData; +using static Data.Products.TestData; -public class ProductViewedHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly ProductViewedHandler handler; private readonly Mock reads = new(); @@ -31,7 +31,7 @@ public class ProductViewedHandlerUnitTests : ProductsBaseUnitTests private readonly Product product = CreateProduct(); private static readonly DateTimeOffset viewedAt = DateTimeOffset.UtcNow; - public ProductViewedHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/ProductsBaseUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/ProductsBaseUnitTests.cs deleted file mode 100644 index c9dab3a3b..000000000 --- a/tests/UnitTests/Catalog/Application/Products/ProductsBaseUnitTests.cs +++ /dev/null @@ -1,51 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Files; - -namespace CustomCADs.UnitTests.Catalog.Application.Products; - -using static ProductsData; - -public class ProductsBaseUnitTests -{ - public static readonly CancellationToken ct = CancellationToken.None; - - protected static Product CreateProduct( - string? name = null, - string? description = null, - decimal? price = null, - AccountId? creatorId = null, - CategoryId? categoryId = null, - ImageId? imageId = null, - CadId? cadId = null - ) => Product.Create( - name: name ?? MinValidName, - description: description ?? MinValidDescription, - price: price ?? MinValidPrice, - creatorId: creatorId ?? ValidCreatorId, - categoryId: categoryId ?? ValidCategoryId, - imageId: imageId ?? ValidImageId, - cadId: cadId ?? ValidCadId - ); - - protected static Product CreateProductWithId( - string? name = null, - string? description = null, - decimal? price = null, - AccountId? creatorId = null, - CategoryId? categoryId = null, - ImageId? imageId = null, - CadId? cadId = null, - ProductId? id = null, - DateTimeOffset? uploadedAt = null - ) => Product.CreateWithId( - name: name ?? MinValidName, - description: description ?? MinValidDescription, - price: price ?? MinValidPrice, - creatorId: creatorId ?? ValidCreatorId, - categoryId: categoryId ?? ValidCategoryId, - imageId: imageId ?? ValidImageId, - cadId: cadId ?? ValidCadId, - id: id ?? ValidId, - uploadedAt: uploadedAt - ); -} diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/ProductsCountHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs similarity index 91% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/ProductsCountHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs index ec30889e4..bd204a931 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/ProductsCountHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs @@ -4,9 +4,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Creator.Count; -using static ProductsData; +using static Data.Products.TestData; -public class ProductsCountHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly ProductsCountHandler handler; private readonly Mock reads = new(); @@ -19,7 +19,7 @@ public class ProductsCountHandlerUnitTests : ProductsBaseUnitTests [ProductStatus.Removed] = 0, }; - public ProductsCountHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs similarity index 94% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs index 240057e04..15cd3b276 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/CreatorGetAllProductsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Creator.GetAll; -using static ProductsData; +using static Data.Products.TestData; -public class CreatorGetAllProductsHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly CreatorGetAllProductsHandler handler; private readonly Mock reads = new(); @@ -18,7 +18,7 @@ public class CreatorGetAllProductsHandlerUnitTests : ProductsBaseUnitTests private readonly ProductQuery query; private readonly Result result; - public CreatorGetAllProductsHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/CreatorGetProductByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs similarity index 95% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/CreatorGetProductByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs index d1976cafc..af6b3abca 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/CreatorGetProductByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs @@ -8,9 +8,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Creator.GetById; -using static ProductsData; +using static Data.Products.TestData; -public class CreatorGetProductByIdHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly CreatorGetProductByIdHandler handler; private readonly Mock reads = new(); @@ -18,7 +18,7 @@ public class CreatorGetProductByIdHandlerUnitTests : ProductsBaseUnitTests private readonly Product product = CreateProduct(); - public CreatorGetProductByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/GetProductCreatorSortingsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/Tests.cs similarity index 88% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/GetProductCreatorSortingsHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/Tests.cs index 488861fc2..2aea7fce8 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/GetProductCreatorSortingsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Creator.GetSortings; -public class GetProductCreatorSortingsHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly GetProductCreatorSortingsHandler handler = new(); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs similarity index 95% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs index 7182dff6e..dc682ce27 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/DesignerGetAllProductsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs @@ -8,9 +8,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Designer.GetAll; -using static ProductsData; +using static Data.Products.TestData; -public class DesignerGetAllProductsHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly DesignerGetAllProductsHandler handler; private readonly Mock reads = new(); @@ -21,7 +21,7 @@ public class DesignerGetAllProductsHandlerUnitTests : ProductsBaseUnitTests private readonly Result result; private readonly ProductStatus Status = ProductStatus.Unchecked; - public DesignerGetAllProductsHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/DesignerGetProductByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs similarity index 94% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/DesignerGetProductByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs index 682ff2914..e924d937c 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/DesignerGetProductByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Designer.GetById; -using static ProductsData; +using static Data.Products.TestData; -public class DesignerGetProductByIdHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly DesignerGetProductByIdHandler handler; private readonly Mock reads = new(); @@ -17,7 +17,7 @@ public class DesignerGetProductByIdHandlerUnitTests : ProductsBaseUnitTests private readonly Product product = CreateProduct(); - public DesignerGetProductByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/GetProductDesignerSortingsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/Tests.cs similarity index 88% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/GetProductDesignerSortingsHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/Tests.cs index 4058cf7d1..7c31ce40a 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/GetProductDesignerSortingsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Designer.GetSortings; -public class GetProductDesignerSortingsHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly GetProductDesignerSortingsHandler handler = new(); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs similarity index 95% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs index 7a954a929..bf6fc4995 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/GalleryGetAllProductsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Gallery.GetAll; -using static ProductsData; +using static Data.Products.TestData; -public class GalleryGetAllProductsHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly GalleryGetAllProductsHandler handler; private readonly Mock reads = new(); @@ -19,7 +19,7 @@ public class GalleryGetAllProductsHandlerUnitTests : ProductsBaseUnitTests private readonly ProductQuery query; private readonly Result result; - public GalleryGetAllProductsHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs similarity index 94% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs index e7898172d..9829657e0 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/GalleryGetProductByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs @@ -12,18 +12,18 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Gallery.GetById; -using static ProductsData; +using static Data.Products.TestData; -public class GalleryGetProductByIdHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly GalleryGetProductByIdHandler handler; private readonly Mock reads = new(); private readonly Mock sender = new(); private readonly Mock raiser = new(); - private readonly Product product = CreateProductWithId(id: ValidId); + private readonly Product product = CreateProduct(id: ValidId); - public GalleryGetProductByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/GetProductSortingsHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/Tests.cs similarity index 89% rename from tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/GetProductSortingsHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/Tests.cs index 688058811..5b1d7e99e 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/GetProductSortingsHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Gallery.GetSortings; -public class GetProductSortingsHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly GetProductGallerySortingsHandler handler = new(); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/BatchGetProductCadIdByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs similarity index 81% rename from tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/BatchGetProductCadIdByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs index cf15fb949..ba1933835 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/BatchGetProductCadIdByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.BatchCadIdById; -using static ProductsData; +using static Data.Products.TestData; -public class BatchGetProductCadIdByIdHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly BatchGetProductCadIdByIdHandler handler; private readonly Mock reads = new(); @@ -16,11 +16,11 @@ public class BatchGetProductCadIdByIdHandlerUnitTests : ProductsBaseUnitTests private readonly ProductQuery query; private readonly Result result; private readonly Product[] products = [ - CreateProductWithId(MinValidName, MinValidDescription, MinValidPrice, id: ProductId.New()), - CreateProductWithId(MaxValidName, MaxValidDescription, MaxValidPrice, id: ProductId.New()), + CreateProduct(MinValidName, MinValidDescription, MinValidPrice, id: ProductId.New()), + CreateProduct(MaxValidName, MaxValidDescription, MaxValidPrice, id: ProductId.New()), ]; - public BatchGetProductCadIdByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPricesById/BatchGetProductPriceByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs similarity index 79% rename from tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPricesById/BatchGetProductPriceByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs index a10875aeb..4efe83e80 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPricesById/BatchGetProductPriceByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs @@ -3,11 +3,11 @@ using CustomCADs.Shared.Application.UseCases.Products.Queries; using CustomCADs.Shared.Domain.Querying; -namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.BatchPricesById; +namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.BatchPriceById; -using static ProductsData; +using static Data.Products.TestData; -public class BatchGetProductPriceByIdHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly BatchGetProductPriceByIdHandler handler; private readonly Mock reads = new(); @@ -16,11 +16,11 @@ public class BatchGetProductPriceByIdHandlerUnitTests : ProductsBaseUnitTests private readonly ProductQuery query; private readonly Result result; private readonly Product[] products = [ - CreateProductWithId(MinValidName, MinValidDescription, MinValidPrice, id: ProductId.New()), - CreateProductWithId(MaxValidName, MaxValidDescription, MaxValidPrice, id: ProductId.New()), + CreateProduct(MinValidName, MinValidDescription, MinValidPrice, id: ProductId.New()), + CreateProduct(MaxValidName, MaxValidDescription, MaxValidPrice, id: ProductId.New()), ]; - public BatchGetProductPriceByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/GetProductExistsByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs similarity index 90% rename from tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/GetProductExistsByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs index d79651247..59c84fe3c 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/GetProductExistsByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs @@ -4,14 +4,14 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.GetExists; -public class GetProductExistsByIdHandlerUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { private readonly GetProductExistsByIdHandler handler; private readonly Mock reads = new(); private static readonly ProductId id = new(); - public GetProductExistsByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); } diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/CreateTagHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs similarity index 92% rename from tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/CreateTagHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs index a6b499b4c..e5cf687fb 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/CreateTagHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs @@ -4,9 +4,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Commands.Internal.Create; -using static TagsData; +using static Data.Tags.TestData; -public class CreateTagHandlerUnitTests : TagsBaseUnitTests +public class Tests : Data.Tags.BaseUnitTests { private readonly CreateTagHandler handler; private readonly Mock writes = new(); @@ -15,7 +15,7 @@ public class CreateTagHandlerUnitTests : TagsBaseUnitTests private readonly Tag tag = CreateTag(); - public CreateTagHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, cache.Object); diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/DeleteTagHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs similarity index 94% rename from tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/DeleteTagHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs index 1fb5cb0e7..9f6f5be96 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/DeleteTagHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Commands.Internal.Delete; -using static TagsData; +using static Data.Tags.TestData; -public class DeleteTagHandlerUnitTests : TagsBaseUnitTests +public class Tests : Data.Tags.BaseUnitTests { private readonly DeleteTagHandler handler; private readonly Mock uow = new(); @@ -18,7 +18,7 @@ public class DeleteTagHandlerUnitTests : TagsBaseUnitTests private static readonly Tag tag = CreateTag(); - public DeleteTagHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, cache.Object); diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/EditTagHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs similarity index 94% rename from tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/EditTagHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs index 64b367ac8..edb71c5c4 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/EditTagHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Commands.Internal.Edit; -using static TagsData; +using static Data.Tags.TestData; -public class EditTagHandlerUnitTests : TagsBaseUnitTests +public class Tests : Data.Tags.BaseUnitTests { private readonly EditTagHandler handler; private readonly Mock reads = new(); @@ -16,7 +16,7 @@ public class EditTagHandlerUnitTests : TagsBaseUnitTests private static readonly Tag tag = CreateTag(); - public EditTagHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, cache.Object); diff --git a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/GetAllTagHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/Tests.cs similarity index 86% rename from tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/GetAllTagHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/Tests.cs index b8c1267a8..c7088451c 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/GetAllTagHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/Tests.cs @@ -4,20 +4,20 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Queries.Internal.GetAll; -using static TagsData; +using static Data.Tags.TestData; -public class GetAllTagHandlerUnitTests : TagsBaseUnitTests +public class Tests : Data.Tags.BaseUnitTests { private readonly GetAllTagsHandler handler; private readonly Mock reads = new(); private readonly Mock> cache = new(); private readonly Tag[] tags = [ - Tag.CreateWithId(ValidId, MinValidName), - Tag.CreateWithId(ValidId, MaxValidName) + CreateTag(MinValidName), + CreateTag(MaxValidName) ]; - public GetAllTagHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); diff --git a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/GetTagByIdHandlerUnitTests.cs b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs similarity index 90% rename from tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/GetTagByIdHandlerUnitTests.cs rename to tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs index d8a76c59a..24af1973b 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/GetTagByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Queries.Internal.GetById; -using static TagsData; +using static Data.Tags.TestData; -public class GetTagByIdHandlerUnitTests : TagsBaseUnitTests +public class Tests : Data.Tags.BaseUnitTests { private readonly GetTagByIdHandler handler; private readonly Mock reads = new(); @@ -13,7 +13,7 @@ public class GetTagByIdHandlerUnitTests : TagsBaseUnitTests private readonly static TagId id = ValidId; - public GetTagByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); diff --git a/tests/UnitTests/Catalog/Application/Tags/TagsBaseUnitTests.cs b/tests/UnitTests/Catalog/Application/Tags/TagsBaseUnitTests.cs deleted file mode 100644 index 4dc8dbed0..000000000 --- a/tests/UnitTests/Catalog/Application/Tags/TagsBaseUnitTests.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Application.Tags; - -using static TagsData; - -public class TagsBaseUnitTests -{ - public static readonly CancellationToken ct = CancellationToken.None; - - protected static Tag CreateTag(TagId? id = null, string? name = null) - => Tag.CreateWithId(id ?? ValidId, name ?? MinValidName); -} diff --git a/tests/UnitTests/Catalog/Data/Categories/BaseUnitTests.cs b/tests/UnitTests/Catalog/Data/Categories/BaseUnitTests.cs new file mode 100644 index 000000000..62a20a124 --- /dev/null +++ b/tests/UnitTests/Catalog/Data/Categories/BaseUnitTests.cs @@ -0,0 +1,14 @@ +using CustomCADs.Modules.Catalog.Domain.Categories; +using CustomCADs.Shared.Domain.TypedIds.Catalog; + +namespace CustomCADs.UnitTests.Catalog.Data.Categories; + +using static TestData; + +public class BaseUnitTests +{ + public static readonly CancellationToken ct = CancellationToken.None; + + protected static Category CreateCategory(string name = ValidName, string description = ValidDescription, CategoryId? id = null) + => Category.CreateWithId(id ?? ValidId, name, description); +} diff --git a/tests/UnitTests/Catalog/Data/CategoriesData.cs b/tests/UnitTests/Catalog/Data/Categories/TestData.cs similarity index 88% rename from tests/UnitTests/Catalog/Data/CategoriesData.cs rename to tests/UnitTests/Catalog/Data/Categories/TestData.cs index f913dafe0..5a8307b85 100644 --- a/tests/UnitTests/Catalog/Data/CategoriesData.cs +++ b/tests/UnitTests/Catalog/Data/Categories/TestData.cs @@ -1,11 +1,11 @@ -using CustomCADs.Modules.Catalog.Domain.Categories; +using CustomCADs.Modules.Catalog.Domain.Categories; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.UnitTests.Catalog.Data; +namespace CustomCADs.UnitTests.Catalog.Data.Categories; using static CategoryConstants; -public static class CategoriesData +public static class TestData { public const string ValidName = "CategoryA"; public static readonly string MinValidName = new('a', NameMinLength + 1); diff --git a/tests/UnitTests/Catalog/Data/Products/BaseUnitTests.cs b/tests/UnitTests/Catalog/Data/Products/BaseUnitTests.cs new file mode 100644 index 000000000..fcf5830cc --- /dev/null +++ b/tests/UnitTests/Catalog/Data/Products/BaseUnitTests.cs @@ -0,0 +1,35 @@ +using CustomCADs.Modules.Catalog.Domain.Products; +using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Catalog; +using CustomCADs.Shared.Domain.TypedIds.Files; + +namespace CustomCADs.UnitTests.Catalog.Data.Products; + +using static Data.Products.TestData; + +public class BaseUnitTests +{ + public static readonly CancellationToken ct = CancellationToken.None; + + protected static Product CreateProduct( + string? name = null, + string? description = null, + decimal? price = null, + AccountId? creatorId = null, + CategoryId? categoryId = null, + ImageId? imageId = null, + CadId? cadId = null, + DateTimeOffset? uploadedAt = null, + ProductId? id = null + ) => Product.CreateWithId( + name: name ?? MinValidName, + description: description ?? MinValidDescription, + price: price ?? MinValidPrice, + creatorId: creatorId ?? ValidCreatorId, + categoryId: categoryId ?? ValidCategoryId, + imageId: imageId ?? ValidImageId, + cadId: cadId ?? ValidCadId, + id: id ?? ValidId, + uploadedAt: uploadedAt + ); +} diff --git a/tests/UnitTests/Catalog/Data/ProductsData.cs b/tests/UnitTests/Catalog/Data/Products/TestData.cs similarity index 91% rename from tests/UnitTests/Catalog/Data/ProductsData.cs rename to tests/UnitTests/Catalog/Data/Products/TestData.cs index 1babc3700..ce606474c 100644 --- a/tests/UnitTests/Catalog/Data/ProductsData.cs +++ b/tests/UnitTests/Catalog/Data/Products/TestData.cs @@ -1,13 +1,13 @@ -using CustomCADs.Modules.Catalog.Domain.Products; +using CustomCADs.Modules.Catalog.Domain.Products; using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Catalog; using CustomCADs.Shared.Domain.TypedIds.Files; -namespace CustomCADs.UnitTests.Catalog.Data; +namespace CustomCADs.UnitTests.Catalog.Data.Products; using static ProductConstants; -public static class ProductsData +public static class TestData { public static readonly string MinValidName = new('a', NameMinLength + 1); public static readonly string MaxValidName = new('a', NameMaxLength - 1); diff --git a/tests/UnitTests/Catalog/Data/Tags/BaseUnitTests.cs b/tests/UnitTests/Catalog/Data/Tags/BaseUnitTests.cs new file mode 100644 index 000000000..44c38a7a1 --- /dev/null +++ b/tests/UnitTests/Catalog/Data/Tags/BaseUnitTests.cs @@ -0,0 +1,14 @@ +using CustomCADs.Modules.Catalog.Domain.Tags; +using CustomCADs.Shared.Domain.TypedIds.Catalog; + +namespace CustomCADs.UnitTests.Catalog.Data.Tags; + +using static TestData; + +public class BaseUnitTests +{ + public static readonly CancellationToken ct = CancellationToken.None; + + protected static Tag CreateTag(string? name = null, TagId? id = null) + => Tag.CreateWithId(id ?? ValidId, name ?? MinValidName); +} diff --git a/tests/UnitTests/Catalog/Data/TagsData.cs b/tests/UnitTests/Catalog/Data/Tags/TestData.cs similarity index 79% rename from tests/UnitTests/Catalog/Data/TagsData.cs rename to tests/UnitTests/Catalog/Data/Tags/TestData.cs index 9bfddc008..112ad8fb6 100644 --- a/tests/UnitTests/Catalog/Data/TagsData.cs +++ b/tests/UnitTests/Catalog/Data/Tags/TestData.cs @@ -1,11 +1,11 @@ -using CustomCADs.Modules.Catalog.Domain.Tags; +using CustomCADs.Modules.Catalog.Domain.Tags; using CustomCADs.Shared.Domain.TypedIds.Catalog; -namespace CustomCADs.UnitTests.Catalog.Data; +namespace CustomCADs.UnitTests.Catalog.Data.Tags; using static TagConstants; -public static class TagsData +public static class TestData { public static readonly string MinValidName = new('a', NameMinLength + 1); public static readonly string MaxValidName = new('a', NameMaxLength - 1); diff --git a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/CategoryDescriptionData.cs b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/CategoryDescriptionData.cs deleted file mode 100644 index 6c4b29d5d..000000000 --- a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/CategoryDescriptionData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Description; - -public class CategoryDescriptionData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/Data/CategoryCreateInvalidData.cs b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/InvalidData.cs similarity index 51% rename from tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/Data/CategoryCreateInvalidData.cs rename to tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/InvalidData.cs index 89d78c5d2..2bd492b15 100644 --- a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/Data/CategoryCreateInvalidData.cs +++ b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/InvalidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Description.Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Description; -using static CategoriesData; +using static Data.Categories.TestData; -public class CategoryCreateInvalidData : CategoryDescriptionData +public class InvalidData : TheoryData { - public CategoryCreateInvalidData() + public InvalidData() { Add(InvalidDescription); Add(MinInvalidDescription); diff --git a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/CategoryDescriptionUnitTests.cs b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/Tests.cs similarity index 66% rename from tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/CategoryDescriptionUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/Tests.cs index 5642d2316..369f158bc 100644 --- a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/CategoryDescriptionUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/Tests.cs @@ -1,12 +1,11 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Description; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Description; -public class CategoryDescriptionUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { [Theory] - [ClassData(typeof(CategoryCreateValidData))] + [ClassData(typeof(ValidData))] public void SetDescription_ShouldNotThrowException_WhenDescriptionIsValid(string description) { var category = CreateCategory(); @@ -15,7 +14,7 @@ public void SetDescription_ShouldNotThrowException_WhenDescriptionIsValid(string } [Theory] - [ClassData(typeof(CategoryCreateValidData))] + [ClassData(typeof(ValidData))] public void SetDescription_SetsDescription_WhenDescriptionIsValid(string description) { var category = CreateCategory(); @@ -26,7 +25,7 @@ public void SetDescription_SetsDescription_WhenDescriptionIsValid(string descrip } [Theory] - [ClassData(typeof(CategoryCreateInvalidData))] + [ClassData(typeof(InvalidData))] public void SetDescription_ThrowsException_WhenDescriptionIsInvalid(string description) { var category = CreateCategory(); diff --git a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/Data/CategoryCreateValidData.cs b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/ValidData.cs similarity index 51% rename from tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/Data/CategoryCreateValidData.cs rename to tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/ValidData.cs index a2cd242d3..e34cc3bf3 100644 --- a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/Data/CategoryCreateValidData.cs +++ b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Description/ValidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Description.Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Description; -using static CategoriesData; +using static Data.Categories.TestData; -public class CategoryCreateValidData : CategoryDescriptionData +public class ValidData : TheoryData { - public CategoryCreateValidData() + public ValidData() { Add(ValidDescription); Add(MinValidDescription); diff --git a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/CategoryNameData.cs b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/CategoryNameData.cs deleted file mode 100644 index 5b16766c5..000000000 --- a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/CategoryNameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Name; - -public class CategoryNameData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/Data/CategogryNameInvalidData.cs b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/InvalidData.cs similarity index 50% rename from tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/Data/CategogryNameInvalidData.cs rename to tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/InvalidData.cs index 4c79a1c4b..7111c2f0a 100644 --- a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/Data/CategogryNameInvalidData.cs +++ b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/InvalidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Name.Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Name; -using static CategoriesData; +using static Data.Categories.TestData; -public class CategogryNameInvalidData : CategoryNameData +public class InvalidData : TheoryData { - public CategogryNameInvalidData() + public InvalidData() { Add(InvalidName); Add(MinInvalidName); diff --git a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/CategoryNameUnitTests.cs b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/Tests.cs similarity index 61% rename from tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/CategoryNameUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/Tests.cs index 3549b66d3..3b0adeea1 100644 --- a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/CategoryNameUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/Tests.cs @@ -1,21 +1,21 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Name; - + using CustomCADs.Shared.Domain.Exceptions; -using Data; -public class CategoryNameUnitTests : CategoriesBaseUnitTests +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Name; + +public class Tests : Data.Categories.BaseUnitTests { [Theory] - [ClassData(typeof(CategoryNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_ShouldNotThrowException_WhenNameIsValid(string name) { - var role = CreateCategory(); + var category = CreateCategory(); - role.SetName(name); + category.SetName(name); } [Theory] - [ClassData(typeof(CategoryNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_SetsName_WhenNameIsValid(string name) { var category = CreateCategory(); @@ -26,7 +26,7 @@ public void SetName_SetsName_WhenNameIsValid(string name) } [Theory] - [ClassData(typeof(CategogryNameInvalidData))] + [ClassData(typeof(InvalidData))] public void SetName_ThrowsException_WhenNameIsInvalid(string name) { var category = CreateCategory(); diff --git a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/Data/CategoryNameValidData.cs b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/ValidData.cs similarity index 50% rename from tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/Data/CategoryNameValidData.cs rename to tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/ValidData.cs index 64decb256..1774a3bbc 100644 --- a/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/Data/CategoryNameValidData.cs +++ b/tests/UnitTests/Catalog/Domain/Categories/Behaviors/Name/ValidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Name.Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Behaviors.Name; -using static CategoriesData; +using static Data.Categories.TestData; -public class CategoryNameValidData : CategoryNameData +public class ValidData : TheoryData { - public CategoryNameValidData() + public ValidData() { Add(ValidName); Add(MinValidName); diff --git a/tests/UnitTests/Catalog/Domain/Categories/CategoriesBaseUnitTests.cs b/tests/UnitTests/Catalog/Domain/Categories/CategoriesBaseUnitTests.cs deleted file mode 100644 index d3049d1af..000000000 --- a/tests/UnitTests/Catalog/Domain/Categories/CategoriesBaseUnitTests.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories; - -using static CategoriesData; - -public class CategoriesBaseUnitTests -{ - protected static Category CreateCategory(string name = ValidName, string description = ValidDescription) - => Category.Create(name, description); -} diff --git a/tests/UnitTests/Catalog/Domain/Categories/Create/CategoryCreateData.cs b/tests/UnitTests/Catalog/Domain/Categories/Create/CategoryCreateData.cs deleted file mode 100644 index ffa5da822..000000000 --- a/tests/UnitTests/Catalog/Domain/Categories/Create/CategoryCreateData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create; - -public class CategoryCreateData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateInvalidDescriptionData.cs b/tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateInvalidDescriptionData.cs deleted file mode 100644 index d4aa2b767..000000000 --- a/tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateInvalidDescriptionData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create.Data; - -using static CategoriesData; - -public class CategoryCreateInvalidDescriptionData : CategoryCreateData -{ - public CategoryCreateInvalidDescriptionData() - { - Add(ValidName, InvalidDescription); - Add(MinValidName, MinInvalidDescription); - Add(MaxValidName, MaxInvalidDescription); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateInvalidNameData.cs b/tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateInvalidNameData.cs deleted file mode 100644 index 732c4a80c..000000000 --- a/tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateInvalidNameData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create.Data; - -using static CategoriesData; - -public class CategoryCreateInvalidNameData : CategoryCreateData -{ - public CategoryCreateInvalidNameData() - { - Add(InvalidName, ValidDescription); - Add(MinInvalidName, MinValidDescription); - Add(MaxInvalidName, MaxValidDescription); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Categories/Create/InvalidData.cs b/tests/UnitTests/Catalog/Domain/Categories/Create/InvalidData.cs new file mode 100644 index 000000000..34db0de45 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Categories/Create/InvalidData.cs @@ -0,0 +1,19 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create; + +using static Data.Categories.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + // Name + Add(InvalidName, ValidDescription); + Add(MinInvalidName, MinValidDescription); + Add(MaxInvalidName, MaxValidDescription); + + // Description + Add(ValidName, InvalidDescription); + Add(MinValidName, MinInvalidDescription); + Add(MaxValidName, MaxInvalidDescription); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Categories/Create/Normal/Tests.cs b/tests/UnitTests/Catalog/Domain/Categories/Create/Normal/Tests.cs new file mode 100644 index 000000000..d92da17b2 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Categories/Create/Normal/Tests.cs @@ -0,0 +1,34 @@ +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create.Normal; + +public class Tests : Data.Categories.BaseUnitTests +{ + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldNotThrowException_WhenCategoryIsValid(string name, string description) + { + Category.Create(name, description); + } + + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldPopulateProperties_WhenCategoryIsValid(string name, string description) + { + var category = Category.Create(name, description); + + Assert.Multiple( + () => Assert.Equal(category.Name, name), + () => Assert.Equal(category.Description, description) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenCategoryIsInvalid(string name, string description) + { + Assert.Throws>( + () => Category.Create(name, description) + ); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateValidData.cs b/tests/UnitTests/Catalog/Domain/Categories/Create/ValidData.cs similarity index 60% rename from tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateValidData.cs rename to tests/UnitTests/Catalog/Domain/Categories/Create/ValidData.cs index 5df1267a9..64b96bef0 100644 --- a/tests/UnitTests/Catalog/Domain/Categories/Create/Data/CategoryCreateValidData.cs +++ b/tests/UnitTests/Catalog/Domain/Categories/Create/ValidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create.Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create; -using static CategoriesData; +using static Data.Categories.TestData; -public class CategoryCreateValidData : CategoryCreateData +public class ValidData : TheoryData { - public CategoryCreateValidData() + public ValidData() { Add(ValidName, ValidDescription); Add(MinValidName, MinValidDescription); diff --git a/tests/UnitTests/Catalog/Domain/Categories/Create/WithId/CategoryCreateWithIdUnitTests.cs b/tests/UnitTests/Catalog/Domain/Categories/Create/WithId/CategoryCreateWithIdUnitTests.cs deleted file mode 100644 index 2f1b98f25..000000000 --- a/tests/UnitTests/Catalog/Domain/Categories/Create/WithId/CategoryCreateWithIdUnitTests.cs +++ /dev/null @@ -1,36 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create.WithId; - -using CustomCADs.Shared.Domain.Exceptions; -using Data; - -public class CategoryCreateWithIdUnitTests : CategoriesBaseUnitTests -{ - [Theory] - [ClassData(typeof(CategoryCreateValidData))] - public void CreateWithId_ShouldNotThrowException_WhenCategoryIsValid(string name, string description) - { - CreateCategory(name, description); - } - - [Theory] - [ClassData(typeof(CategoryCreateValidData))] - public void CreateWithId_ShouldPopulateProperties_WhenCategoryIsValid(string name, string description) - { - var category = CreateCategory(name, description); - - Assert.Multiple( - () => Assert.Equal(category.Name, name), - () => Assert.Equal(category.Description, description) - ); - } - - [Theory] - [ClassData(typeof(CategoryCreateInvalidNameData))] - [ClassData(typeof(CategoryCreateInvalidDescriptionData))] - public void CreateWithId_ShouldThrowException_WhenCategoryIsInvalid(string name, string description) - { - Assert.Throws>( - () => CreateCategory(name, description) - ); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Categories/Create/Normal/CategoryCreateUnitTests.cs b/tests/UnitTests/Catalog/Domain/Categories/Create/WithId/Tests.cs similarity index 62% rename from tests/UnitTests/Catalog/Domain/Categories/Create/Normal/CategoryCreateUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Categories/Create/WithId/Tests.cs index b995edba2..f7b03776e 100644 --- a/tests/UnitTests/Catalog/Domain/Categories/Create/Normal/CategoryCreateUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Categories/Create/WithId/Tests.cs @@ -1,19 +1,18 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create.Normal; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Categories.Create.WithId; -public class CategoryCreateUnitTests : CategoriesBaseUnitTests +public class Tests : Data.Categories.BaseUnitTests { [Theory] - [ClassData(typeof(CategoryCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldNotThrowException_WhenCategoryIsValid(string name, string description) { CreateCategory(name, description); } [Theory] - [ClassData(typeof(CategoryCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldPopulateProperties_WhenCategoryIsValid(string name, string description) { var category = CreateCategory(name, description); @@ -25,8 +24,7 @@ public void Create_ShouldPopulateProperties_WhenCategoryIsValid(string name, str } [Theory] - [ClassData(typeof(CategoryCreateInvalidNameData))] - [ClassData(typeof(CategoryCreateInvalidDescriptionData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenCategoryIsInvalid(string name, string description) { Assert.Throws>( diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/AddProductPurchaseData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/AddProductPurchaseData.cs deleted file mode 100644 index 11fdc7856..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/AddProductPurchaseData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.Counts.AddPurchase; - -public class AddProductPurchaseData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/Data/AddProductPurchaseValidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/Data/AddProductPurchaseValidData.cs deleted file mode 100644 index 1e2dbb1ba..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/Data/AddProductPurchaseValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.Counts.AddPurchase.Data; - -public class AddProductPurchaseValidData : AddProductPurchaseData -{ - public AddProductPurchaseValidData() - { - Add(1); - Add(3); - Add(5); - Add(10); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/AddProductPurchaseUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/Tests.cs similarity index 78% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/AddProductPurchaseUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/Tests.cs index 031906fae..ac2737bf2 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/AddProductPurchaseUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddPurchase/Tests.cs @@ -1,8 +1,6 @@ namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.Counts.AddPurchase; -using Data; - -public class AddProductPurchaseUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Fact] public void Add_ShouldNotThrowException() @@ -12,7 +10,10 @@ public void Add_ShouldNotThrowException() } [Theory] - [ClassData(typeof(AddProductPurchaseValidData))] + [InlineData(1)] + [InlineData(3)] + [InlineData(5)] + [InlineData(10)] public void Add_ShouldIncreasePurchaseCountResult(int iterations) { var product = CreateProduct(); diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/AddProductViewData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/AddProductViewData.cs deleted file mode 100644 index c0ec4a8e4..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/AddProductViewData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.Counts.AddView; - -public class AddProductViewData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/Data/AddProductViewValidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/Data/AddProductViewValidData.cs deleted file mode 100644 index 619a06205..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/Data/AddProductViewValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.Counts.AddView.Data; - -public class AddProductViewValidData : AddProductViewData -{ - public AddProductViewValidData() - { - Add(1); - Add(3); - Add(5); - Add(10); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/AddProductViewUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/Tests.cs similarity index 78% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/AddProductViewUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/Tests.cs index ca17601f0..77a851b49 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/AddProductViewUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/Counts/AddView/Tests.cs @@ -1,8 +1,6 @@ namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.Counts.AddView; -using Data; - -public class AddProductViewUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Fact] public void Add_ShouldNotThrowException() @@ -12,7 +10,10 @@ public void Add_ShouldNotThrowException() } [Theory] - [ClassData(typeof(AddProductViewValidData))] + [InlineData(1)] + [InlineData(3)] + [InlineData(5)] + [InlineData(10)] public void Add_ShouldIncreaseViewCountResult(int iterations) { var product = CreateProduct(); diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetCategoryId/SetProductCategoryIdUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetCategoryId/Tests.cs similarity index 81% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/SetCategoryId/SetProductCategoryIdUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/SetCategoryId/Tests.cs index 3b27e2a69..5801b863e 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetCategoryId/SetProductCategoryIdUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetCategoryId/Tests.cs @@ -1,8 +1,8 @@ namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetCategoryId; -using static ProductsData; +using static Data.Products.TestData; -public class SetProductCategoryIdUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Fact] public void SetCategoryId_ShouldNotThrowException() diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Data/SetProductDescriptionInvalidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Data/SetProductDescriptionInvalidData.cs deleted file mode 100644 index 8fd90a64a..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Data/SetProductDescriptionInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetDescription.Data; - -using static ProductsData; - -public class SetProductDescriptionInvalidData : SetProductDescriptionData -{ - public SetProductDescriptionInvalidData() - { - Add(MinInvalidDescription); - Add(MaxInvalidDescription); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Data/SetProductDescriptionValidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Data/SetProductDescriptionValidData.cs deleted file mode 100644 index 52c9f9bc7..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Data/SetProductDescriptionValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetDescription.Data; - -using static ProductsData; - -public class SetProductDescriptionValidData : SetProductDescriptionData -{ - public SetProductDescriptionValidData() - { - Add(MinValidDescription); - Add(MaxValidDescription); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/InvalidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/InvalidData.cs new file mode 100644 index 000000000..c08a9c150 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/InvalidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetDescription; + +using static Data.Products.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(MinInvalidDescription); + Add(MaxInvalidDescription); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/SetProductDescriptionData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/SetProductDescriptionData.cs deleted file mode 100644 index a4e636f93..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/SetProductDescriptionData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetDescription; - -public class SetProductDescriptionData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/SetProductDescriptionUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Tests.cs similarity index 62% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/SetProductDescriptionUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Tests.cs index eae052a60..80a96eb4d 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/SetProductDescriptionUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/Tests.cs @@ -1,19 +1,18 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetDescription; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetDescription; -public class SetProductDescriptionUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Theory] - [ClassData(typeof(SetProductDescriptionValidData))] + [ClassData(typeof(ValidData))] public void SetDescription_ShouldNotThrow_WhenDescriptionIsValid(string description) { CreateProduct().SetDescription(description); } [Theory] - [ClassData(typeof(SetProductDescriptionValidData))] + [ClassData(typeof(ValidData))] public void SetDescription_ShouldPopulateProperties_WhenDescriptionIsValid(string description) { var product = CreateProduct(); @@ -22,7 +21,7 @@ public void SetDescription_ShouldPopulateProperties_WhenDescriptionIsValid(strin } [Theory] - [ClassData(typeof(SetProductDescriptionInvalidData))] + [ClassData(typeof(InvalidData))] public void SetDescription_ShouldThrowException_WhenDescriptionIsNotValid(string description) { Assert.Throws>( diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/ValidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/ValidData.cs new file mode 100644 index 000000000..c3ea677c3 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetDescription/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetDescription; + +using static Data.Products.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(MinValidDescription); + Add(MaxValidDescription); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Data/SetProductNameInvalidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Data/SetProductNameInvalidData.cs deleted file mode 100644 index 1358e6407..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Data/SetProductNameInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetName.Data; - -using static ProductsData; - -public class SetProductNameInvalidData : SetProductNameData -{ - public SetProductNameInvalidData() - { - Add(MinInvalidName); - Add(MaxInvalidName); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Data/SetProductNameValidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Data/SetProductNameValidData.cs deleted file mode 100644 index 7c526ac9d..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Data/SetProductNameValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetName.Data; - -using static ProductsData; - -public class SetProductNameValidData : SetProductNameData -{ - public SetProductNameValidData() - { - Add(MinValidName); - Add(MaxValidName); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/InvalidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/InvalidData.cs new file mode 100644 index 000000000..934e20ef5 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/InvalidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetName; + +using static Data.Products.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(MinInvalidName); + Add(MaxInvalidName); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/SetProductNameData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/SetProductNameData.cs deleted file mode 100644 index 3cfd6edae..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/SetProductNameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetName; - -public class SetProductNameData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/SetProductNameUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Tests.cs similarity index 59% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/SetProductNameUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Tests.cs index 3c582cf29..76be215ef 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/SetProductNameUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/Tests.cs @@ -1,19 +1,18 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetName; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetName; -public class SetProductNameUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Theory] - [ClassData(typeof(SetProductNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_ShouldNotThrow_WhenNameIsValid(string name) { CreateProduct().SetName(name); } [Theory] - [ClassData(typeof(SetProductNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_ShouldPopulateProperties_WhenNameIsValid(string name) { var product = CreateProduct(); @@ -22,7 +21,7 @@ public void SetName_ShouldPopulateProperties_WhenNameIsValid(string name) } [Theory] - [ClassData(typeof(SetProductNameInvalidData))] + [ClassData(typeof(InvalidData))] public void SetName_ShouldThrowException_WhenNameIsNotValid(string name) { Assert.Throws>( diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/ValidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/ValidData.cs new file mode 100644 index 000000000..ab955cf40 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetName/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetName; + +using static Data.Products.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(MinValidName); + Add(MaxValidName); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Data/SetProductPriceInvalidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Data/SetProductPriceInvalidData.cs deleted file mode 100644 index f788f2b27..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Data/SetProductPriceInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetPrice.Data; - -using static ProductsData; - -public class SetProductPriceInvalidData : SetProductPriceData -{ - public SetProductPriceInvalidData() - { - Add(MinInvalidPrice); - Add(MaxInvalidPrice); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Data/SetProductPriceValidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Data/SetProductPriceValidData.cs deleted file mode 100644 index 9417dccb2..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Data/SetProductPriceValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetPrice.Data; - -using static ProductsData; - -public class SetProductPriceValidData : SetProductPriceData -{ - public SetProductPriceValidData() - { - Add(MinValidPrice); - Add(MaxValidPrice); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/InvalidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/InvalidData.cs new file mode 100644 index 000000000..833bbc44b --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/InvalidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetPrice; + +using static Data.Products.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(MinInvalidPrice); + Add(MaxInvalidPrice); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/SetProductPriceData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/SetProductPriceData.cs deleted file mode 100644 index 1b19cc892..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/SetProductPriceData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetPrice; - -public class SetProductPriceData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/SetProductPriceUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Tests.cs similarity index 60% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/SetProductPriceUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Tests.cs index 57e844e16..b0b95dbbb 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/SetProductPriceUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/Tests.cs @@ -1,19 +1,18 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetPrice; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetPrice; -public class SetProductPriceUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Theory] - [ClassData(typeof(SetProductPriceValidData))] + [ClassData(typeof(ValidData))] public void SetPrice_ShouldNotThrow_WhenPriceIsValid(decimal price) { CreateProduct().SetPrice(price); } [Theory] - [ClassData(typeof(SetProductPriceValidData))] + [ClassData(typeof(ValidData))] public void SetPrice_ShouldPopulateProperties_WhenPriceIsValid(decimal price) { var product = CreateProduct(); @@ -22,7 +21,7 @@ public void SetPrice_ShouldPopulateProperties_WhenPriceIsValid(decimal price) } [Theory] - [ClassData(typeof(SetProductPriceInvalidData))] + [ClassData(typeof(InvalidData))] public void SetPrice_ShouldThrowException_WhenPriceIsNotValid(decimal price) { Assert.Throws>( diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/ValidData.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/ValidData.cs new file mode 100644 index 000000000..990482d26 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetPrice/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetPrice; + +using static Data.Products.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(MinValidPrice); + Add(MaxValidPrice); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Removed/ProductRemoveUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Removed/Tests.cs similarity index 89% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Removed/ProductRemoveUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Removed/Tests.cs index 815638431..6a85f4ed5 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Removed/ProductRemoveUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Removed/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetStatus.Removed; -using static ProductsData; +using static Data.Products.TestData; -public class ProductRemoveUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Fact] public void Remove_ShouldNotThrowException_WhenStatusIsValid() diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Reported/ProductReportUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Reported/Tests.cs similarity index 89% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Reported/ProductReportUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Reported/Tests.cs index 98172781c..16215f2bd 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Reported/ProductReportUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Reported/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetStatus.Reported; -using static ProductsData; +using static Data.Products.TestData; -public class ProductReportUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Fact] public void Report_ShouldNotThrowException_WhenStatusIsValid() diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Unchecked/ProductUncheckUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Unchecked/Tests.cs similarity index 88% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Unchecked/ProductUncheckUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Unchecked/Tests.cs index 927ae2a94..354a43444 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Unchecked/ProductUncheckUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Unchecked/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetStatus.Unchecked; -using static ProductsData; +using static Data.Products.TestData; -public class ProductUncheckUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Fact] public void Uncheck_ShouldNotThrowException_WhenStatusIsValid() diff --git a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Validated/ProductValidateUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Validated/Tests.cs similarity index 89% rename from tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Validated/ProductValidateUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Validated/Tests.cs index 5ca4ebac2..b9e4cc419 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Validated/ProductValidateUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Behaviors/SetStatus/Validated/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Catalog.Domain.Products.Behaviors.SetStatus.Validated; -using static ProductsData; +using static Data.Products.TestData; -public class ProductValidateUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Fact] public void Validate_ShouldNotThrowException_WhenStatusIsValid() diff --git a/tests/UnitTests/Catalog/Domain/Products/Create/Data/CreateProductInvalidData.cs b/tests/UnitTests/Catalog/Domain/Products/Create/Data/CreateProductInvalidData.cs deleted file mode 100644 index 0790729e5..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Create/Data/CreateProductInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create.Data; - -using static ProductsData; - -public class ProductCreateInvalidNameData : ProductCreateData -{ - public ProductCreateInvalidNameData() - { - Add(MinInvalidName, MinValidDescription, MinValidPrice); - Add(MaxInvalidName, MaxValidDescription, MaxValidPrice); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateInvalidDescriptionData.cs b/tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateInvalidDescriptionData.cs deleted file mode 100644 index 507247d60..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateInvalidDescriptionData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create.Data; - -using static ProductsData; - -public class ProductCreateInvalidDescriptionData : ProductCreateData -{ - public ProductCreateInvalidDescriptionData() - { - Add(MinValidName, MinInvalidDescription, MinValidPrice); - Add(MaxValidName, MaxInvalidDescription, MaxValidPrice); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateInvalidPriceData.cs b/tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateInvalidPriceData.cs deleted file mode 100644 index e905d2c4e..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateInvalidPriceData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create.Data; - -using static ProductsData; - -public class ProductCreateInvalidPriceData : ProductCreateData -{ - public ProductCreateInvalidPriceData() - { - Add(MinValidName, MinValidDescription, MinInvalidPrice); - Add(MaxValidName, MaxValidDescription, MaxInvalidPrice); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Create/InvalidData.cs b/tests/UnitTests/Catalog/Domain/Products/Create/InvalidData.cs new file mode 100644 index 000000000..bdb4b9682 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Products/Create/InvalidData.cs @@ -0,0 +1,21 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create; + +using static Data.Products.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + // Name + Add(MinInvalidName, MinValidDescription, MinValidPrice); + Add(MaxInvalidName, MaxValidDescription, MaxValidPrice); + + // Description + Add(MinValidName, MinInvalidDescription, MinValidPrice); + Add(MaxValidName, MaxInvalidDescription, MaxValidPrice); + + // Price + Add(MinValidName, MinValidDescription, MinInvalidPrice); + Add(MaxValidName, MaxValidDescription, MaxInvalidPrice); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Products/Create/Normal/Tests.cs b/tests/UnitTests/Catalog/Domain/Products/Create/Normal/Tests.cs new file mode 100644 index 000000000..4b5202134 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Products/Create/Normal/Tests.cs @@ -0,0 +1,63 @@ +using CustomCADs.Modules.Catalog.Domain.Products.Enums; +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create.Normal; + +using static Data.Products.TestData; + +public class Tests : Data.Products.BaseUnitTests +{ + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldNotThrowException_WhenProductIsValid(string name, string description, decimal price) + { + Product.Create( + name: name, + description: description, + price: price, + creatorId: ValidCreatorId, + categoryId: ValidCategoryId, + imageId: ValidImageId, + cadId: ValidCadId + ); + } + + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldPopulateProperties_WhenProductIsValid(string name, string description, decimal price) + { + Product product = Product.Create( + name: name, + description: description, + price: price, + creatorId: ValidCreatorId, + categoryId: ValidCategoryId, + imageId: ValidImageId, + cadId: ValidCadId + ); + + Assert.Multiple( + () => Assert.Equal(name, product.Name), + () => Assert.Equal(description, product.Description), + () => Assert.Equal(price, product.Price), + () => Assert.Equal(ProductStatus.Unchecked, product.Status) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenProductIsNotValid(string name, string description, decimal price) + { + Assert.Throws>( + () => Product.Create( + name: name, + description: description, + price: price, + creatorId: ValidCreatorId, + categoryId: ValidCategoryId, + imageId: ValidImageId, + cadId: ValidCadId + ) + ); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Products/Create/ProductCreateData.cs b/tests/UnitTests/Catalog/Domain/Products/Create/ProductCreateData.cs deleted file mode 100644 index 22c16c537..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Create/ProductCreateData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create; - -public class ProductCreateData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateValidData.cs b/tests/UnitTests/Catalog/Domain/Products/Create/ValidData.cs similarity index 60% rename from tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateValidData.cs rename to tests/UnitTests/Catalog/Domain/Products/Create/ValidData.cs index 0ab6fcb8f..eca4d65e1 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Create/Data/ProductCreateValidData.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Create/ValidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create.Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create; -using static ProductsData; +using static Data.Products.TestData; -public class ProductCreateValidData : ProductCreateData +public class ValidData : TheoryData { - public ProductCreateValidData() + public ValidData() { Add(MinValidName, MinValidDescription, MinValidPrice); Add(MaxValidName, MaxValidDescription, MaxValidPrice); diff --git a/tests/UnitTests/Catalog/Domain/Products/Create/WithId/ProductCreateWithIdUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Create/WithId/ProductCreateWithIdUnitTests.cs deleted file mode 100644 index 24351f1a8..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/Create/WithId/ProductCreateWithIdUnitTests.cs +++ /dev/null @@ -1,57 +0,0 @@ -using CustomCADs.Modules.Catalog.Domain.Products.Enums; - -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create.WithId; - -using CustomCADs.Shared.Domain.Exceptions; -using Data; -using static ProductsData; - -public class ProductCreateWithIdUnitTests : ProductsBaseUnitTests -{ - [Theory] - [ClassData(typeof(ProductCreateValidData))] - public void CreateWithId_ShouldNotThrowException_WhenProductIsValid(string name, string description, decimal price) - { - CreateProductWithId( - id: ValidId, - name: name, - description: description, - price: price - ); - } - - [Theory] - [ClassData(typeof(ProductCreateValidData))] - public void CreateWithId_ShouldPopulateProperties_WhenProductIsValid(string name, string description, decimal price) - { - Product product = CreateProductWithId( - id: ValidId, - name: name, - description: description, - price: price - ); - - Assert.Multiple( - () => Assert.Equal(name, product.Name), - () => Assert.Equal(description, product.Description), - () => Assert.Equal(price, product.Price), - () => Assert.Equal(ProductStatus.Unchecked, product.Status) - ); - } - - [Theory] - [ClassData(typeof(ProductCreateInvalidNameData))] - [ClassData(typeof(ProductCreateInvalidDescriptionData))] - [ClassData(typeof(ProductCreateInvalidPriceData))] - public void CreateWithId_ShouldThrowException_WhenProductIsNotValid(string name, string description, decimal price) - { - Assert.Throws>( - () => CreateProductWithId( - id: ValidId, - name: name, - description: description, - price: price - ) - ); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Products/Create/Normal/ProductCreateUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/Create/WithId/Tests.cs similarity index 72% rename from tests/UnitTests/Catalog/Domain/Products/Create/Normal/ProductCreateUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Products/Create/WithId/Tests.cs index 99143723c..c5ddaa3c5 100644 --- a/tests/UnitTests/Catalog/Domain/Products/Create/Normal/ProductCreateUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Products/Create/WithId/Tests.cs @@ -1,17 +1,18 @@ using CustomCADs.Modules.Catalog.Domain.Products.Enums; +using CustomCADs.Shared.Domain.Exceptions; -namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create.Normal; +namespace CustomCADs.UnitTests.Catalog.Domain.Products.Create.WithId; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +using static Data.Products.TestData; -public class ProductCreateUnitTests : ProductsBaseUnitTests +public class Tests : Data.Products.BaseUnitTests { [Theory] - [ClassData(typeof(ProductCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldNotThrowException_WhenProductIsValid(string name, string description, decimal price) { CreateProduct( + id: ValidId, name: name, description: description, price: price @@ -19,10 +20,11 @@ public void Create_ShouldNotThrowException_WhenProductIsValid(string name, strin } [Theory] - [ClassData(typeof(ProductCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldPopulateProperties_WhenProductIsValid(string name, string description, decimal price) { Product product = CreateProduct( + id: ValidId, name: name, description: description, price: price @@ -37,13 +39,12 @@ public void Create_ShouldPopulateProperties_WhenProductIsValid(string name, stri } [Theory] - [ClassData(typeof(ProductCreateInvalidNameData))] - [ClassData(typeof(ProductCreateInvalidDescriptionData))] - [ClassData(typeof(ProductCreateInvalidPriceData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenProductIsNotValid(string name, string description, decimal price) { Assert.Throws>( () => CreateProduct( + id: ValidId, name: name, description: description, price: price diff --git a/tests/UnitTests/Catalog/Domain/Products/ProductsBaseUnitTests.cs b/tests/UnitTests/Catalog/Domain/Products/ProductsBaseUnitTests.cs deleted file mode 100644 index 21c6adbae..000000000 --- a/tests/UnitTests/Catalog/Domain/Products/ProductsBaseUnitTests.cs +++ /dev/null @@ -1,48 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Catalog; -using CustomCADs.Shared.Domain.TypedIds.Files; - -namespace CustomCADs.UnitTests.Catalog.Domain.Products; - -using static ProductsData; - -public class ProductsBaseUnitTests -{ - protected static Product CreateProduct( - string? name = null, - string? description = null, - decimal? price = null, - AccountId? creatorId = null, - CategoryId? categoryId = null, - ImageId? imageId = null, - CadId? cadId = null - ) => Product.Create( - name: name ?? MinValidName, - description: description ?? MinValidDescription, - price: price ?? MinValidPrice, - creatorId: creatorId ?? ValidCreatorId, - categoryId: categoryId ?? ValidCategoryId, - imageId: imageId ?? ValidImageId, - cadId: cadId ?? ValidCadId - ); - - protected static Product CreateProductWithId( - ProductId? id = null, - string? name = null, - string? description = null, - decimal? price = null, - AccountId? creatorId = null, - CategoryId? categoryId = null, - ImageId? imageId = null, - CadId? cadId = null - ) => Product.CreateWithId( - name: name ?? MinValidName, - description: description ?? MinValidDescription, - price: price ?? MinValidPrice, - creatorId: creatorId ?? ValidCreatorId, - categoryId: categoryId ?? ValidCategoryId, - imageId: imageId ?? ValidImageId, - cadId: cadId ?? ValidCadId, - id: id - ); -} diff --git a/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/Data/SetTagNameInvalidData.cs b/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/InvalidData.cs similarity index 50% rename from tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/Data/SetTagNameInvalidData.cs rename to tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/InvalidData.cs index 4732b27cd..f4ec90b52 100644 --- a/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/Data/SetTagNameInvalidData.cs +++ b/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/InvalidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Behaviors.SetName.Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Behaviors.SetName; -using static TagsData; +using static Data.Tags.TestData; -public class SetTagNameInvalidData : SetTagNameData +public class InvalidData : TheoryData { - public SetTagNameInvalidData() + public InvalidData() { Add(MinInvalidName); Add(MaxInvalidName); diff --git a/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/SetTagNameData.cs b/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/SetTagNameData.cs deleted file mode 100644 index 31148ad0f..000000000 --- a/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/SetTagNameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Behaviors.SetName; - -public class SetTagNameData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/SetTagNameUnitTests.cs b/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/Tests.cs similarity index 65% rename from tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/SetTagNameUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/Tests.cs index a3e9858e5..8be9a7060 100644 --- a/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/SetTagNameUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/Tests.cs @@ -1,19 +1,19 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Behaviors.SetName; - + using CustomCADs.Shared.Domain.Exceptions; -using Data; -public class SetTagNameUnitTests : TagsBaseUnitTests +namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Behaviors.SetName; + +public class Tests : Data.Tags.BaseUnitTests { [Theory] - [ClassData(typeof(SetTagNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_ShouldNotThrow_WhenNameIsValid(string name) { CreateTag().SetName(name); } [Theory] - [ClassData(typeof(SetTagNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_ShouldPopulateProperties_WhenNameIsValid(string name) { var tag = CreateTag(); @@ -22,7 +22,7 @@ public void SetName_ShouldPopulateProperties_WhenNameIsValid(string name) } [Theory] - [ClassData(typeof(SetTagNameInvalidData))] + [ClassData(typeof(InvalidData))] public void SetName_ShouldThrowException_WhenNameIsNotValid(string name) { Assert.Throws>( diff --git a/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/Data/SetTagNameValidData.cs b/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/ValidData.cs similarity index 50% rename from tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/Data/SetTagNameValidData.cs rename to tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/ValidData.cs index 2209e9c63..fcc896221 100644 --- a/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/Data/SetTagNameValidData.cs +++ b/tests/UnitTests/Catalog/Domain/Tags/Behaviors/SetName/ValidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Behaviors.SetName.Data; +namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Behaviors.SetName; -using static TagsData; +using static Data.Tags.TestData; -public class SetTagNameValidData : SetTagNameData +public class ValidData : TheoryData { - public SetTagNameValidData() + public ValidData() { Add(MinValidName); Add(MaxValidName); diff --git a/tests/UnitTests/Catalog/Domain/Tags/Create/Data/TagCreateInvalidNameData.cs b/tests/UnitTests/Catalog/Domain/Tags/Create/Data/TagCreateInvalidNameData.cs deleted file mode 100644 index 293d5d320..000000000 --- a/tests/UnitTests/Catalog/Domain/Tags/Create/Data/TagCreateInvalidNameData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Create.Data; - -using static TagsData; - -public class TagCreateInvalidNameData : TagCreateData -{ - public TagCreateInvalidNameData() - { - Add(MinInvalidName); - Add(MaxInvalidName); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Tags/Create/Data/TagCreateValidData.cs b/tests/UnitTests/Catalog/Domain/Tags/Create/Data/TagCreateValidData.cs deleted file mode 100644 index e62c0371e..000000000 --- a/tests/UnitTests/Catalog/Domain/Tags/Create/Data/TagCreateValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Create.Data; - -using static TagsData; - -public class TagCreateValidData : TagCreateData -{ - public TagCreateValidData() - { - Add(MinValidName); - Add(MaxValidName); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Tags/Create/InvalidData.cs b/tests/UnitTests/Catalog/Domain/Tags/Create/InvalidData.cs new file mode 100644 index 000000000..eef2c8918 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Tags/Create/InvalidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Create; + +using static Data.Tags.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(MinInvalidName); + Add(MaxInvalidName); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Tags/Create/Normal/TagCreateUnitTests.cs b/tests/UnitTests/Catalog/Domain/Tags/Create/Normal/Tests.cs similarity index 55% rename from tests/UnitTests/Catalog/Domain/Tags/Create/Normal/TagCreateUnitTests.cs rename to tests/UnitTests/Catalog/Domain/Tags/Create/Normal/Tests.cs index ef9292e36..0c0a86a5d 100644 --- a/tests/UnitTests/Catalog/Domain/Tags/Create/Normal/TagCreateUnitTests.cs +++ b/tests/UnitTests/Catalog/Domain/Tags/Create/Normal/Tests.cs @@ -1,32 +1,32 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Create.Normal; - + using CustomCADs.Shared.Domain.Exceptions; -using Data; -public class TagCreateUnitTests : TagsBaseUnitTests +namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Create.Normal; + +public class Tests : Data.Tags.BaseUnitTests { [Theory] - [ClassData(typeof(TagCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldNotThrowException_WhenProductIsValid(string name) { - CreateTag(name); + Tag.Create(name); } [Theory] - [ClassData(typeof(TagCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldPopulateProperties_WhenProductIsValid(string name) { - Tag tag = CreateTag(name); + Tag tag = Tag.Create(name); Assert.Equal(name, tag.Name); } [Theory] - [ClassData(typeof(TagCreateInvalidNameData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenProductIsNotValid(string name) { Assert.Throws>( - () => CreateTag(name) + () => Tag.Create(name) ); } } diff --git a/tests/UnitTests/Catalog/Domain/Tags/Create/TagCreateData.cs b/tests/UnitTests/Catalog/Domain/Tags/Create/TagCreateData.cs deleted file mode 100644 index f8aa46e46..000000000 --- a/tests/UnitTests/Catalog/Domain/Tags/Create/TagCreateData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Create; - -public class TagCreateData : TheoryData; diff --git a/tests/UnitTests/Catalog/Domain/Tags/Create/ValidData.cs b/tests/UnitTests/Catalog/Domain/Tags/Create/ValidData.cs new file mode 100644 index 000000000..d57517547 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Tags/Create/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Create; + +using static Data.Tags.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(MinValidName); + Add(MaxValidName); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Tags/Create/WithId/TagCreateWithIdUnitTests.cs b/tests/UnitTests/Catalog/Domain/Tags/Create/WithId/TagCreateWithIdUnitTests.cs deleted file mode 100644 index fd7532ce9..000000000 --- a/tests/UnitTests/Catalog/Domain/Tags/Create/WithId/TagCreateWithIdUnitTests.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Create.WithId; - -using CustomCADs.Shared.Domain.Exceptions; -using Data; -using static TagsData; - -public class TagCreateWithIdUnitTests : TagsBaseUnitTests -{ - [Theory] - [ClassData(typeof(TagCreateValidData))] - public void CreateWithId_ShouldNotThrowException_WhenProductIsValid(string name) - { - CreateTagWithId(ValidId, name); - } - - [Theory] - [ClassData(typeof(TagCreateValidData))] - public void CreateWithId_ShouldPopulateProperties_WhenProductIsValid(string name) - { - Tag tag = CreateTagWithId(ValidId, name); - - Assert.Equal(name, tag.Name); - } - - [Theory] - [ClassData(typeof(TagCreateInvalidNameData))] - public void CreateWithId_ShouldThrowException_WhenProductIsNotValid(string name) - { - Assert.Throws>( - () => CreateTagWithId(ValidId, name) - ); - } -} diff --git a/tests/UnitTests/Catalog/Domain/Tags/Create/WithId/Tests.cs b/tests/UnitTests/Catalog/Domain/Tags/Create/WithId/Tests.cs new file mode 100644 index 000000000..bbbd4c6a2 --- /dev/null +++ b/tests/UnitTests/Catalog/Domain/Tags/Create/WithId/Tests.cs @@ -0,0 +1,36 @@ +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Catalog.Domain.Tags.Create.WithId; + +using static Data.Tags.TestData; + +public class Tests : Data.Tags.BaseUnitTests +{ + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldNotThrowException_WhenProductIsValid(string name) + { + CreateTag(name); + } + + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldPopulateProperties_WhenProductIsValid(string name) + { + Tag tag = CreateTag(name, ValidId); + + Assert.Multiple( + () => Assert.Equal(ValidId, tag.Id), + () => Assert.Equal(name, tag.Name) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenProductIsNotValid(string name) + { + Assert.Throws>( + () => CreateTag(name) + ); + } +} diff --git a/tests/UnitTests/Catalog/Domain/Tags/TagsBaseUnitTests.cs b/tests/UnitTests/Catalog/Domain/Tags/TagsBaseUnitTests.cs deleted file mode 100644 index 152f64557..000000000 --- a/tests/UnitTests/Catalog/Domain/Tags/TagsBaseUnitTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Catalog; - -namespace CustomCADs.UnitTests.Catalog.Domain.Tags; - -using static TagsData; - -public class TagsBaseUnitTests -{ - protected static Tag CreateTag( - string? name = null - ) => Tag.Create( - name: name ?? MinValidName - ); - - protected static Tag CreateTagWithId( - TagId? id = null, - string? name = null - ) => Tag.CreateWithId( - id: id ?? ValidId, - name: name ?? MinValidName - ); -} diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/RemoveCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs similarity index 95% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/RemoveCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs index db4cd613f..ee100634e 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/RemoveCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs @@ -10,9 +10,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Admin.Remove; -using static CustomsData; +using static Data.Customs.TestData; -public class RemoveCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly RemoveCustomHandler handler; private readonly Mock reads = new(); @@ -22,7 +22,7 @@ public class RemoveCustomHandlerUnitTests : CustomsBaseUnitTests private static readonly AccountId adminId = AccountId.New(); private readonly Custom custom = CreateCustom(); - public RemoveCustomHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/AdminSetCustomCategoryHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs similarity index 93% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/AdminSetCustomCategoryHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs index a65343e34..001d2f50e 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/AdminSetCustomCategoryHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Admin.SetCategory; -using static CustomsData; +using static Data.Customs.TestData; -public class AdminSetCustomCategoryHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly AdminSetCustomCategoryHandler handler; private readonly Mock reads = new(); @@ -16,7 +16,7 @@ public class AdminSetCustomCategoryHandlerUnitTests : CustomsBaseUnitTests private readonly Custom custom = CreateCustom(); - public AdminSetCustomCategoryHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/CreateCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs similarity index 95% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/CreateCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs index 004c8218a..e4414dd6c 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/CreateCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs @@ -9,9 +9,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Create; -using static CustomsData; +using static Data.Customs.TestData; -public class CreateCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly CreateCustomHandler handler; private readonly Mock> writes = new(); @@ -19,7 +19,7 @@ public class CreateCustomHandlerUnitTests : CustomsBaseUnitTests private readonly Mock sender = new(); private readonly Mock raiser = new(); - public CreateCustomHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, sender.Object, raiser.Object); @@ -31,7 +31,7 @@ public CreateCustomHandlerUnitTests() x.BuyerId == ValidBuyerId ), ct - )).ReturnsAsync(CreateCustomWithId(id: ValidId)); + )).ReturnsAsync(CreateCustom(id: ValidId)); sender.Setup(x => x.SendQueryAsync( It.IsAny(), diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/DeleteCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs similarity index 91% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/DeleteCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs index b5743b388..fefde5765 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/DeleteCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs @@ -8,9 +8,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Delete; -using static CustomsData; +using static Data.Customs.TestData; -public class DeleteCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly DeleteCustomHandler handler; private readonly Mock reads = new(); @@ -20,9 +20,9 @@ public class DeleteCustomHandlerUnitTests : CustomsBaseUnitTests private static readonly CustomId id = CustomId.New(); private static readonly AccountId buyerId = AccountId.New(); - private readonly Custom custom = CreateCustomWithId(id, buyerId: buyerId); + private readonly Custom custom = CreateCustom(id: id, buyerId: buyerId); - public DeleteCustomHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/EditCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs similarity index 92% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/EditCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs index 33b96197b..dcd6844a7 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/EditCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs @@ -8,9 +8,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Edit; -using static CustomsData; +using static Data.Customs.TestData; -public class EditCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly EditCustomHandler handler; private readonly Mock reads = new(); @@ -19,9 +19,9 @@ public class EditCustomHandlerUnitTests : CustomsBaseUnitTests private static readonly CustomId id = CustomId.New(); private static readonly AccountId buyerId = AccountId.New(); - private readonly Custom custom = CreateCustomWithId(buyerId: buyerId); + private readonly Custom custom = CreateCustom(buyerId: buyerId); - public EditCustomHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/PurchaseCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs similarity index 97% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/PurchaseCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs index 86fcb560c..fb3f4022e 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/PurchaseCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs @@ -13,9 +13,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.Normal; -using static CustomsData; +using static Data.Customs.TestData; -public class PurchaseCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly PurchaseCustomHandler handler; private readonly Mock reads = new(); @@ -30,7 +30,7 @@ public class PurchaseCustomHandlerUnitTests : CustomsBaseUnitTests buyerId: ValidBuyerId ); - public PurchaseCustomHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, payment.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidCityData.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidCityData.cs similarity index 61% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidCityData.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidCityData.cs index 7f768eef3..d3bdeecc4 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidCityData.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidCityData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; -public class PurchaseCustomWithDeliveryInvalidCityData : PurchaseCustomWithDeliveryData +public class InvalidCityData : Theory { - public PurchaseCustomWithDeliveryInvalidCityData() + public InvalidCityData() { Add("payment-method-id-1", 2, "shipment-service-1", "Bulgaria", string.Empty, "Flora", null, "customcads@gmail.com"); Add("payment-method-id-2", 5, "shipment-service-2", "Romania", null!, "Brailles", "+359359359359", null); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidCountryData.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidCountryData.cs similarity index 60% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidCountryData.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidCountryData.cs index f8b7a04aa..4ce178bdd 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidCountryData.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidCountryData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; -public class PurchaseCustomWithDeliveryInvalidCountryData : PurchaseCustomWithDeliveryData +public class InvalidCountryData : Theory { - public PurchaseCustomWithDeliveryInvalidCountryData() + public InvalidCountryData() { Add("payment-method-id-1", 2, "shipment-service-1", string.Empty, "Sofia", "Flora", null, "customcads@gmail.com"); Add("payment-method-id-2", 5, "shipment-service-2", null!, "Bucharest", "Brailles", "+359359359359", null); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidEmailData.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidEmailData.cs similarity index 72% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidEmailData.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidEmailData.cs index 54d61575b..000b23451 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidEmailData.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidEmailData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; -public class PurchaseCustomWithDeliveryInvalidEmailData : PurchaseCustomWithDeliveryData +public class InvalidEmailData : Theory { - public PurchaseCustomWithDeliveryInvalidEmailData() + public InvalidEmailData() { Add("payment-method-id-1", 2, "shipment-service-1", "Bulgaria", "Sofia", "Flora", null, "@gmail.com"); Add("payment-method-id-1", 5, "shipment-service-1", "Bulgaria", "Sofia", "Flora", null, "customcads_gmail.com"); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidPhoneData.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidPhoneData.cs similarity index 61% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidPhoneData.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidPhoneData.cs index 21fcdf1b1..cb3ea6385 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidPhoneData.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidPhoneData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; -public class PurchaseCustomWithDeliveryInvalidPhoneData : PurchaseCustomWithDeliveryData +public class InvalidPhoneData : Theory { - public PurchaseCustomWithDeliveryInvalidPhoneData() + public InvalidPhoneData() { Add("payment-method-id-1", 2, "shipment-service-1", "Bulgaria", "Sofi a", "Flora", "0359359359", "customcads@gmail.com"); Add("payment-method-id-2", 5, "shipment-service-2", "Romania", "Bucharest", "Brailles", "+359 359 359 359", null); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidShipmentServiceData.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidShipmentServiceData.cs similarity index 56% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidShipmentServiceData.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidShipmentServiceData.cs index b942a6b70..2fcc62841 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryInvalidShipmentServiceData.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/InvalidShipmentServiceData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; -public class PurchaseCustomWithDeliveryInvalidShipmentServiceData : PurchaseCustomWithDeliveryData +public class InvalidShipmentServiceData : Theory { - public PurchaseCustomWithDeliveryInvalidShipmentServiceData() + public InvalidShipmentServiceData() { Add("payment-method-id-1", 2, string.Empty, "Bulgaria", "Sofia", "Flora", null, "customcads@gmail.com"); Add("payment-method-id-2", 5, null!, "Romania", "Bucharest", "Brailles", "+359359359359", null); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryData.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryData.cs deleted file mode 100644 index fd1070fec..000000000 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; - -public class PurchaseCustomWithDeliveryData : TheoryData; diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs similarity index 96% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs index e2d2945bf..846438cb9 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs @@ -16,9 +16,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; -using static CustomsData; +using static Data.Customs.TestData; -public class PurchaseCustomWithDeliveryHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly PurchaseCustomWithDeliveryHandler handler; private readonly Mock reads = new(); @@ -30,13 +30,9 @@ public class PurchaseCustomWithDeliveryHandlerUnitTests : CustomsBaseUnitTests private static readonly AccountId buyerId = AccountId.New(); private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); private static readonly ContactDto contact = new(null, null); - private readonly Custom custom = CreateCustomWithId( - id: ValidId, - buyerId: ValidBuyerId, - forDelivery: true - ); + private readonly Custom custom = CreateCustom(forDelivery: true); - public PurchaseCustomWithDeliveryHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, payment.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Theory.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Theory.cs new file mode 100644 index 000000000..9b51541b5 --- /dev/null +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Theory.cs @@ -0,0 +1,3 @@ +namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; + +public class Theory : TheoryData; diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryValidData.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/ValidData.cs similarity index 62% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryValidData.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/ValidData.cs index e18a770b4..d65c5f95d 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Data/PurchaseCustomWithDeliveryValidData.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/ValidData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery.Data; +namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; -public class PurchaseCustomWithDeliveryValidData : PurchaseCustomWithDeliveryData +public class ValidData : Theory { - public PurchaseCustomWithDeliveryValidData() + public ValidData() { Add("payment-method-id-1", 2, "shipment-service-1", "Bulgaria", "Sofia", "Flora", null, "customcads@gmail.com"); Add("payment-method-id-2", 5, "shipment-service-2", "Romania", "Bucharest", "Brailles", "+359359359359", null); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryValidatorUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs similarity index 86% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryValidatorUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs index 51a3189ef..1e66938c7 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/PurchaseCustomWithDeliveryValidatorUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs @@ -1,13 +1,11 @@ using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Customers.Purchase.WithDelivery; using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Printing; using FluentValidation.TestHelper; namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; -using CustomCADs.Shared.Domain.TypedIds.Printing; -using Data; - -public class PurchaseCustomWithDeliveryValidatorUnitTests : CustomsBaseUnitTests +public class Validator : Data.Customs.BaseUnitTests { private readonly PurchaseCustomWithDeliveryValidator validator = new(); @@ -16,7 +14,7 @@ public class PurchaseCustomWithDeliveryValidatorUnitTests : CustomsBaseUnitTests private static readonly CustomizationId customizationId = CustomizationId.New(); [Theory] - [ClassData(typeof(PurchaseCustomWithDeliveryValidData))] + [ClassData(typeof(ValidData))] public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -39,11 +37,11 @@ public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, } [Theory] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidShipmentServiceData))] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidCountryData))] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidCityData))] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidPhoneData))] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidEmailData))] + [ClassData(typeof(InvalidShipmentServiceData))] + [ClassData(typeof(InvalidCountryData))] + [ClassData(typeof(InvalidCityData))] + [ClassData(typeof(InvalidPhoneData))] + [ClassData(typeof(InvalidEmailData))] public async Task Validate_ShouldBeInvalid_WhenCartIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -66,7 +64,7 @@ public async Task Validate_ShouldBeInvalid_WhenCartIsNotValid(string paymentMeth } [Theory] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidShipmentServiceData))] + [ClassData(typeof(InvalidShipmentServiceData))] public async Task Validate_ShouldReturnProperErrors_WhenShipmentServiceIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -89,7 +87,7 @@ public async Task Validate_ShouldReturnProperErrors_WhenShipmentServiceIsNotVali } [Theory] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidCountryData))] + [ClassData(typeof(InvalidCountryData))] public async Task Validate_ShouldReturnProperErrors_WhenCountryIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -112,7 +110,7 @@ public async Task Validate_ShouldReturnProperErrors_WhenCountryIsNotValid(string } [Theory] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidCityData))] + [ClassData(typeof(InvalidCityData))] public async Task Validate_ShouldReturnProperErrors_WhenCityIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -135,7 +133,7 @@ public async Task Validate_ShouldReturnProperErrors_WhenCityIsNotValid(string pa } [Theory] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidPhoneData))] + [ClassData(typeof(InvalidPhoneData))] public async Task Validate_ShouldReturnProperErrors_WhenPhoneIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange @@ -158,7 +156,7 @@ public async Task Validate_ShouldReturnProperErrors_WhenPhoneIsNotValid(string p } [Theory] - [ClassData(typeof(PurchaseCustomWithDeliveryInvalidEmailData))] + [ClassData(typeof(InvalidEmailData))] public async Task Validate_ShouldReturnProperErrors_WhenEmailIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/SetCustomDeliveryHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs similarity index 95% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/SetCustomDeliveryHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs index 54b917655..faf9f09bf 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/SetCustomDeliveryHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs @@ -9,9 +9,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.SetDelivery; -using static CustomsData; +using static Data.Customs.TestData; -public class SetCustomDeliveryHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly SetCustomDeliveryHandler handler; private readonly Mock reads = new(); @@ -23,7 +23,7 @@ public class SetCustomDeliveryHandlerUnitTests : CustomsBaseUnitTests private static readonly AccountId buyerId = AccountId.New(); private readonly Custom custom = CreateCustom(forDelivery: !value); - public SetCustomDeliveryHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/AcceptCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs similarity index 96% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/AcceptCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs index 7dba7c8a2..82e8be288 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/AcceptCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs @@ -11,9 +11,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Designer.Accept; -using static CustomsData; +using static Data.Customs.TestData; -public class AcceptCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly AcceptCustomHandler handler; private readonly Mock reads = new(); @@ -23,7 +23,7 @@ public class AcceptCustomHandlerUnitTests : CustomsBaseUnitTests private readonly Custom custom = CreateCustom(); - public AcceptCustomHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/BeginCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs similarity index 96% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/BeginCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs index 51ead2e65..621f526d2 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/BeginCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs @@ -10,9 +10,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Designer.Begin; -using static CustomsData; +using static Data.Customs.TestData; -public class BeginCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly BeginCustomHandler handler; private readonly Mock reads = new(); @@ -22,7 +22,7 @@ public class BeginCustomHandlerUnitTests : CustomsBaseUnitTests private static readonly AccountId designerId = AccountId.New(); private readonly Custom custom = CreateCustom(); - public BeginCustomHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/CancelCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs similarity index 96% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/CancelCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs index 1d7b3a40a..d008e4dd7 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/CancelCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs @@ -10,9 +10,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Designer.Cancel; -using static CustomsData; +using static Data.Customs.TestData; -public class CancelCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly CancelCustomHandler handler; private readonly Mock reads = new(); @@ -22,7 +22,7 @@ public class CancelCustomHandlerUnitTests : CustomsBaseUnitTests private static readonly AccountId designerId = AccountId.New(); private readonly Custom custom = CreateCustom(); - public CancelCustomHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/FinishCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs similarity index 97% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/FinishCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs index 880f1a255..195ff420b 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/FinishCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs @@ -12,9 +12,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Designer.Finish; -using static CustomsData; +using static Data.Customs.TestData; -public class FinishCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly FinishCustomHandler handler; private readonly Mock reads = new(); @@ -25,7 +25,7 @@ public class FinishCustomHandlerUnitTests : CustomsBaseUnitTests private static readonly AccountId designerId = AccountId.New(); private readonly Custom custom = CreateCustom(); - public FinishCustomHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/ReportCustomHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs similarity index 96% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/ReportCustomHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs index 118038531..3f105b436 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/ReportCustomHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs @@ -12,9 +12,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Designer.Report; -using static CustomsData; +using static Data.Customs.TestData; -public class ReportCustomHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly ReportCustomHandler handler; private readonly Mock reads = new(); @@ -25,7 +25,7 @@ public class ReportCustomHandlerUnitTests : CustomsBaseUnitTests private static readonly AccountId designerId = AccountId.New(); private readonly Custom custom = CreateCustom(); - public ReportCustomHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, raiser.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/DesignerSetCustomCategoryHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs similarity index 95% rename from tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/DesignerSetCustomCategoryHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs index 72c89c383..70cc0c40c 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/DesignerSetCustomCategoryHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Designer.SetCategory; -using static CustomsData; +using static Data.Customs.TestData; -public class DesignerSetCustomCategoryHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly DesignerSetCustomCategoryHandler handler; private readonly Mock reads = new(); @@ -17,7 +17,7 @@ public class DesignerSetCustomCategoryHandlerUnitTests : CustomsBaseUnitTests private readonly Custom custom = CreateCustom(); - public DesignerSetCustomCategoryHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/CustomsBaseUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/CustomsBaseUnitTests.cs deleted file mode 100644 index 80464c771..000000000 --- a/tests/UnitTests/Customs/Application/Customs/CustomsBaseUnitTests.cs +++ /dev/null @@ -1,31 +0,0 @@ -using CustomCADs.Modules.Customs.Domain.Customs.Enums; -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Catalog; - -namespace CustomCADs.UnitTests.Customs.Application.Customs; - -using static CustomsData; - -public class CustomsBaseUnitTests -{ - public static readonly CancellationToken ct = CancellationToken.None; - - public static Custom CreateCustom(string? name = null, string? description = null, bool? forDelivery = null, AccountId? buyerId = null, CategoryId? categoryId = null, CustomCategorySetter? setter = null) - => Custom.Create( - name: name ?? MinValidName, - description: description ?? MinValidDescription, - forDelivery: forDelivery ?? false, - buyerId: buyerId ?? ValidBuyerId, - category: (categoryId ?? ValidCategoryId, setter ?? CustomCategorySetter.Customer) - ); - - public static Custom CreateCustomWithId(CustomId? id = null, string? name = null, string? description = null, bool? forDelivery = null, AccountId? buyerId = null, CategoryId? categoryId = null, CustomCategorySetter? setter = null) - => Custom.CreateWithId( - id: id ?? ValidId, - name: name ?? MinValidName, - description: description ?? MinValidDescription, - delivery: forDelivery ?? false, - buyerId: buyerId ?? ValidBuyerId, - category: (categoryId ?? ValidCategoryId, setter ?? CustomCategorySetter.Customer) - ); -} diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs similarity index 93% rename from tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs index 6bb633fbf..775f796fe 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs @@ -9,9 +9,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Events.Application.DeliveryRequested; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomDeliveryRequestedApplicationEventHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly CustomDeliveryRequestedApplicationEventHandler handler; private readonly Mock reads = new(); @@ -23,9 +23,9 @@ public class CustomDeliveryRequestedApplicationEventHandlerUnitTests : CustomsBa private const int Count = 3; private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); private static readonly ContactDto contact = new("0123456789", null); - private readonly Custom custom = CreateCustomWithId(forDelivery: true); + private readonly Custom custom = CreateCustom(forDelivery: true); - public CustomDeliveryRequestedApplicationEventHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs similarity index 94% rename from tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs index 09a005dc6..05d55f0fa 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs @@ -11,9 +11,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Events.Application.PaymentCompleted; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomPaymentCompletedApplicationEventHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private CustomPaymentCompletedApplicationEventHandler handler; @@ -24,9 +24,9 @@ public class CustomPaymentCompletedApplicationEventHandlerUnitTests : CustomsBas private const string ToEmail = "user123@gmail.com"; private const string ClientUrl = "https://www.site123.com"; - private readonly Custom custom = CreateCustomWithId(forDelivery: false); + private readonly Custom custom = CreateCustom(forDelivery: false); - public CustomPaymentCompletedApplicationEventHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, sender.Object, email.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/CalculateCustomShipmentHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs similarity index 94% rename from tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/CalculateCustomShipmentHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs index ed629be03..fc275c75a 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/CalculateCustomShipmentHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Customers.CalculateShipment; -using static CustomsData; +using static Data.Customs.TestData; -public class CalculateCustomShipmentHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly CalculateCustomShipmentHandler handler; private readonly Mock reads = new(); @@ -20,7 +20,7 @@ public class CalculateCustomShipmentHandlerUnitTests : CustomsBaseUnitTests new(default, string.Empty, string.Empty, default, default) ]; - public CalculateCustomShipmentHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/CountCustomsHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs similarity index 92% rename from tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/CountCustomsHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs index bd9026b10..a3d1b3bb7 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/CountCustomsHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs @@ -4,9 +4,9 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Customers.Count; -using static CustomsData; +using static Data.Customs.TestData; -public class CountCustomsHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly CountCustomsHandler handler; private readonly Mock reads = new(); @@ -21,7 +21,7 @@ public class CountCustomsHandlerUnitTests : CustomsBaseUnitTests [CustomStatus.Reported] = 6, }; - public CountCustomsHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/CustomerGetCustomByIdHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs similarity index 93% rename from tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/CustomerGetCustomByIdHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs index 7cb4b7145..724043d1b 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/CustomerGetCustomByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs @@ -8,17 +8,17 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Customers.GetById; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomerGetCustomByIdHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly CustomerGetCustomByIdHandler handler; private readonly Mock reads = new(); private readonly Mock sender = new(); - private readonly Custom custom = CreateCustomWithId(); + private readonly Custom custom = CreateCustom(); - public CustomerGetCustomByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/DesignerGetCustomByIdHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs similarity index 94% rename from tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/DesignerGetCustomByIdHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs index 99a01c422..1c2a86e7f 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/DesignerGetCustomByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs @@ -8,17 +8,17 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Designers.GetById; -using static CustomsData; +using static Data.Customs.TestData; -public class DesignerGetCustomByIdHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly DesignerGetCustomByIdHandler handler; private readonly Mock reads = new(); private readonly Mock sender = new(); - private readonly Custom custom = CreateCustomWithId(); + private readonly Custom custom = CreateCustom(); - public DesignerGetCustomByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllPurchasedCartsUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs similarity index 94% rename from tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllPurchasedCartsUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs index 9b489bf17..819909b8e 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/GetAllPurchasedCartsUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs @@ -10,18 +10,18 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Shared.GetAll; -using static CustomsData; +using static Data.Customs.TestData; using static DomainConstants.Users; -public class GetAllCustomsUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly GetAllCustomsHandler handler; private readonly Mock reads = new(); private readonly Mock sender = new(); private readonly Custom[] customs = [ - CreateCustomWithId(id: ValidId), - CreateCustomWithId(id: ValidId), + CreateCustom(id: ValidId), + CreateCustom(id: ValidId), ]; private readonly Dictionary customers = new() { @@ -37,7 +37,7 @@ public class GetAllCustomsUnitTests : CustomsBaseUnitTests }; private readonly CustomQuery query; - public GetAllCustomsUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/GetCustomPaymentStatusesHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/Tests.cs similarity index 88% rename from tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/GetCustomPaymentStatusesHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/Tests.cs index 5001e3800..8cfb3dee1 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/GetCustomPaymentStatusesHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Shared.GetPaymentStatuses; -public class GetCustomPaymentStatusesHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly GetCustomPaymentStatusesHandler handler = new(); diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/GetCustomSortingsHandlerUnitTests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/Tests.cs similarity index 89% rename from tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/GetCustomSortingsHandlerUnitTests.cs rename to tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/Tests.cs index 0341073ec..9f8841393 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/GetCustomSortingsHandlerUnitTests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Shared.GetSortings; -public class GetCustomSortingsHandlerUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private readonly GetCustomSortingsHandler handler = new(); diff --git a/tests/UnitTests/Customs/Application/GlobalUsings.cs b/tests/UnitTests/Customs/Application/GlobalUsings.cs index 53639c137..81188b8cb 100644 --- a/tests/UnitTests/Customs/Application/GlobalUsings.cs +++ b/tests/UnitTests/Customs/Application/GlobalUsings.cs @@ -1,5 +1,4 @@ global using CustomCADs.Modules.Customs.Domain.Customs; global using CustomCADs.Shared.Domain.TypedIds.Customs; -global using CustomCADs.UnitTests.Customs.Data; global using Moq; global using Xunit; diff --git a/tests/UnitTests/Customs/Data/Customs/BaseUnitTests.cs b/tests/UnitTests/Customs/Data/Customs/BaseUnitTests.cs new file mode 100644 index 000000000..7cbcd85d1 --- /dev/null +++ b/tests/UnitTests/Customs/Data/Customs/BaseUnitTests.cs @@ -0,0 +1,32 @@ +using CustomCADs.Modules.Customs.Domain.Customs; +using CustomCADs.Modules.Customs.Domain.Customs.Enums; +using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Catalog; +using CustomCADs.Shared.Domain.TypedIds.Customs; + +namespace CustomCADs.UnitTests.Customs.Data.Customs; + +using static TestData; + +public class BaseUnitTests +{ + public static readonly CancellationToken ct = CancellationToken.None; + + public static Custom CreateCustom( + string? name = null, + string? description = null, + bool? forDelivery = null, + AccountId? buyerId = null, + CategoryId? categoryId = null, + CustomCategorySetter? setter = null, + CustomId? id = null + ) + => Custom.CreateWithId( + id: id ?? ValidId, + name: name ?? MinValidName, + description: description ?? MinValidDescription, + delivery: forDelivery ?? false, + buyerId: buyerId ?? ValidBuyerId, + category: (categoryId ?? ValidCategoryId, setter ?? CustomCategorySetter.Customer) + ); +} diff --git a/tests/UnitTests/Customs/Data/CustomsData.cs b/tests/UnitTests/Customs/Data/Customs/TestData.cs similarity index 95% rename from tests/UnitTests/Customs/Data/CustomsData.cs rename to tests/UnitTests/Customs/Data/Customs/TestData.cs index 6981686c2..7a9e22544 100644 --- a/tests/UnitTests/Customs/Data/CustomsData.cs +++ b/tests/UnitTests/Customs/Data/Customs/TestData.cs @@ -6,11 +6,11 @@ using CustomCADs.Shared.Domain.TypedIds.Files; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.UnitTests.Customs.Data; +namespace CustomCADs.UnitTests.Customs.Data.Customs; using static CustomConstants; -public static class CustomsData +public static class TestData { public static readonly string MinValidName = new('a', NameMinLength + 1); public static readonly string MaxValidName = new('a', NameMaxLength - 1); diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetCategory/CustomSetCategoryUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetCategory/Tests.cs similarity index 74% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/SetCategory/CustomSetCategoryUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/SetCategory/Tests.cs index 1043c502d..434290172 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetCategory/CustomSetCategoryUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetCategory/Tests.cs @@ -4,9 +4,9 @@ namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetCategory; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomSetCategoryUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { [Fact] public void SetCategory_ShouldNotThrowException() @@ -18,7 +18,7 @@ public void SetCategory_ShouldNotThrowException() [Fact] public void SetCategory_ShouldPersistProperties() { - Custom custom = CreateCustomWithId(); + Custom custom = CreateCustom(); custom.SetCategory((ValidCategoryId, CustomCategorySetter.Customer)); Assert.Multiple( () => Assert.Equal(ValidCategoryId, custom.Category?.Id), @@ -75,4 +75,48 @@ public void SetCategory_ShouldThrowException_WhenInvalidCustomStatus(CustomStatu () => custom.SetCategory((ValidCategoryId, CustomCategorySetter.Customer)) ); } + + private static Custom CreateCustomWithStatus(CustomStatus status) + { + Custom custom = CreateCustom(); + + switch (status) + { + case CustomStatus.Pending: + break; + + case CustomStatus.Accepted: + custom.Accept(ValidDesignerId); + break; + + case CustomStatus.Begun: + custom.Accept(ValidDesignerId); + custom.Begin(); + break; + + case CustomStatus.Finished: + custom.Accept(ValidDesignerId); + custom.Begin(); + custom.Finish(ValidCadId, ValidPrice); + break; + + case CustomStatus.Completed: + custom.Accept(ValidDesignerId); + custom.Begin(); + custom.Finish(ValidCadId, ValidPrice); + custom.Complete(customizationId: null); + break; + + case CustomStatus.Reported: + custom.Report(); + break; + + case CustomStatus.Removed: + custom.Report(); + custom.Remove(); + break; + } + + return custom; + } } diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/CustomSetNameData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/CustomSetNameData.cs deleted file mode 100644 index bd12622ab..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/CustomSetNameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDelivery; - -public class CustomSetNameData : TheoryData; diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/Data/CustomSetDeliveryValidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/Data/CustomSetDeliveryValidData.cs deleted file mode 100644 index cb32ae91d..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/Data/CustomSetDeliveryValidData.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDelivery.Data; - -public class CustomSetDeliveryValidData : TheoryData -{ - public CustomSetDeliveryValidData() - { - Add(true); - Add(false); - } -} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/CustomSetDeliveryUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/Tests.cs similarity index 63% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/CustomSetDeliveryUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/Tests.cs index 567581abf..7ea178746 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/CustomSetDeliveryUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/Tests.cs @@ -1,19 +1,18 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDelivery; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDelivery; -public class CustomSetDeliveryUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { [Theory] - [ClassData(typeof(CustomSetDeliveryValidData))] + [ClassData(typeof(ValidData))] public void SetDelivery_ShouldNotThrowException_WhenCustomValid(bool forDelivery) { CreateCustom().SetDelivery(forDelivery); } [Theory] - [ClassData(typeof(CustomSetDeliveryValidData))] + [ClassData(typeof(ValidData))] public void SetDelivery_ShouldPopulateProperties(bool forDelivery) { var Custom = CreateCustom(); @@ -22,7 +21,7 @@ public void SetDelivery_ShouldPopulateProperties(bool forDelivery) } [Theory] - [ClassData(typeof(CustomSetDeliveryValidData))] + [ClassData(typeof(ValidData))] public void SetDelivery_ShouldThrowException_WhenNameInvalid(bool forDelivery) { Assert.Throws>(() => diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/ValidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/ValidData.cs new file mode 100644 index 000000000..348a58198 --- /dev/null +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDelivery/ValidData.cs @@ -0,0 +1,10 @@ +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDelivery; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(true); + Add(false); + } +} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/CustomSetDescriptionData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/CustomSetDescriptionData.cs deleted file mode 100644 index 9ea9e0138..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/CustomSetDescriptionData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDescription; - -public class CustomSetDescriptionData : TheoryData; diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Data/CustomSetDescriptionInvalidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Data/CustomSetDescriptionInvalidData.cs deleted file mode 100644 index 9bb1975e9..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Data/CustomSetDescriptionInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDescription.Data; - -using static CustomsData; - -public class CustomSetDescriptionInvalidData : CustomSetDescriptionData -{ - public CustomSetDescriptionInvalidData() - { - Add(MinInvalidDescription); - Add(MaxInvalidDescription); - } -} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Data/CustomSetDescriptionValidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Data/CustomSetDescriptionValidData.cs deleted file mode 100644 index cadaaf23a..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Data/CustomSetDescriptionValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDescription.Data; - -using static CustomsData; - -public class CustomSetDescriptionValidData : CustomSetDescriptionData -{ - public CustomSetDescriptionValidData() - { - Add(MinValidDescription); - Add(MaxValidDescription); - } -} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/InvalidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/InvalidData.cs new file mode 100644 index 000000000..d414648a5 --- /dev/null +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/InvalidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDescription; + +using static Data.Customs.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(MinInvalidDescription); + Add(MaxInvalidDescription); + } +} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/CustomSetDescriptionUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Tests.cs similarity index 53% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/CustomSetDescriptionUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Tests.cs index 337f833be..3973b8275 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/CustomSetDescriptionUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/Tests.cs @@ -1,28 +1,28 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDescription; - + using CustomCADs.Shared.Domain.Exceptions; -using Data; -public class CustomSetDescriptionUnitTests : CustomsBaseUnitTests +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDescription; + +public class Tests : Data.Customs.BaseUnitTests { [Theory] - [ClassData(typeof(CustomSetDescriptionValidData))] + [ClassData(typeof(ValidData))] public void SetDescription_ShouldNotThrowException_WhenCustomValid(string description) { CreateCustom().SetDescription(description); } [Theory] - [ClassData(typeof(CustomSetDescriptionValidData))] + [ClassData(typeof(ValidData))] public void SetDescription_ShouldPopulateProperties(string description) { - var Custom = CreateCustom(); - Custom.SetDescription(description); - Assert.Equal(description, Custom.Description); + var custom = CreateCustom(); + custom.SetDescription(description); + Assert.Equal(description, custom.Description); } [Theory] - [ClassData(typeof(CustomSetDescriptionInvalidData))] + [ClassData(typeof(InvalidData))] public void SetDescription_ShouldThrowException_WhenDescriptionInvalid(string description) { Assert.Throws>( diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/ValidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/ValidData.cs new file mode 100644 index 000000000..ea7b77467 --- /dev/null +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetDescription/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetDescription; + +using static Data.Customs.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(MinValidDescription); + Add(MaxValidDescription); + } +} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/CustomSetNameData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/CustomSetNameData.cs deleted file mode 100644 index ccc70781e..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/CustomSetNameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetName; - -public class CustomSetNameData : TheoryData; diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Data/CustomSetNameInvalidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Data/CustomSetNameInvalidData.cs deleted file mode 100644 index 4b353ea26..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Data/CustomSetNameInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetName.Data; - -using static CustomsData; - -public class CustomSetNameInvalidData : CustomSetNameData -{ - public CustomSetNameInvalidData() - { - Add(MinInvalidName); - Add(MaxInvalidName); - } -} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Data/CustomSetNameValidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Data/CustomSetNameValidData.cs deleted file mode 100644 index 13bcc2f7d..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Data/CustomSetNameValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetName.Data; - -using static CustomsData; - -public class CustomSetNameValidData : CustomSetNameData -{ - public CustomSetNameValidData() - { - Add(MinValidName); - Add(MaxValidName); - } -} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/InvalidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/InvalidData.cs new file mode 100644 index 000000000..c6a6827d9 --- /dev/null +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/InvalidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetName; + +using static Data.Customs.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(MinInvalidName); + Add(MaxInvalidName); + } +} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/CustomSetNameUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Tests.cs similarity index 64% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/CustomSetNameUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Tests.cs index cc22e953e..83b4a9c4d 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/CustomSetNameUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/Tests.cs @@ -1,19 +1,19 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetName; - + using CustomCADs.Shared.Domain.Exceptions; -using Data; -public class CustomSetNameUnitTests : CustomsBaseUnitTests +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetName; + +public class Tests : Data.Customs.BaseUnitTests { [Theory] - [ClassData(typeof(CustomSetNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_ShouldNotThrowException_WhenCustomValid(string name) { CreateCustom().SetName(name); } [Theory] - [ClassData(typeof(CustomSetNameValidData))] + [ClassData(typeof(ValidData))] public void SetName_ShouldPopulateProperties(string name) { var Custom = CreateCustom(); @@ -22,7 +22,7 @@ public void SetName_ShouldPopulateProperties(string name) } [Theory] - [ClassData(typeof(CustomSetNameInvalidData))] + [ClassData(typeof(InvalidData))] public void SetName_ShouldThrowException_WhenNameInvalid(string name) { Assert.Throws>( diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/ValidData.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/ValidData.cs new file mode 100644 index 000000000..6b3f633ee --- /dev/null +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/SetName/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.SetName; + +using static Data.Customs.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(MinValidName); + Add(MaxValidName); + } +} diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomAcceptUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Accept/Tests.cs similarity index 95% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomAcceptUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Accept/Tests.cs index ce7085c95..a6654846b 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomAcceptUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Accept/Tests.cs @@ -1,10 +1,10 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Accept; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomAcceptUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private static readonly Func expectValidationException = Assert.Throws; diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomBeginUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Begin/Tests.cs similarity index 94% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomBeginUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Begin/Tests.cs index abc9a43bd..0e421f8f1 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomBeginUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Begin/Tests.cs @@ -1,10 +1,10 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Begin; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomBeginUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private static readonly Func expectValidationException = Assert.Throws; diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomCancelUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Cancel/Tests.cs similarity index 95% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomCancelUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Cancel/Tests.cs index 831d2d787..9ce851a21 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomCancelUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Cancel/Tests.cs @@ -1,10 +1,10 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Cancel; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomCancelUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private static readonly Func expectValidationException = Assert.Throws; diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomCompleteUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Complete/Tests.cs similarity index 95% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomCompleteUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Complete/Tests.cs index af8cce4a9..cbd3e0975 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomCompleteUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Complete/Tests.cs @@ -1,10 +1,10 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Complete; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomCompleteUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private static readonly Func expectValidationException = Assert.Throws; diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomFinishUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Finish/Tests.cs similarity index 96% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomFinishUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Finish/Tests.cs index 8c10b3f7d..639e0079c 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomFinishUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Finish/Tests.cs @@ -2,11 +2,11 @@ using CustomCADs.Modules.Customs.Domain.Customs.States.Entities; using CustomCADs.Shared.Domain.Exceptions; -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Finish; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomFinishUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private static readonly Func expectValidationException = Assert.Throws; diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomRemoveUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Remove/Tests.cs similarity index 93% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomRemoveUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Remove/Tests.cs index 1c70332bb..227f6a574 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomRemoveUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Remove/Tests.cs @@ -1,10 +1,10 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Remove; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomRemoveUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private static readonly Func expectValidationException = Assert.Throws; diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomReportUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Report/Tests.cs similarity index 95% rename from tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomReportUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Report/Tests.cs index 175d06585..88433fa9f 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/CustomReportUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Report/Tests.cs @@ -1,10 +1,10 @@ using CustomCADs.Modules.Customs.Domain.Customs.Enums; -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Report; -using static CustomsData; +using static Data.Customs.TestData; -public class CustomReportUnitTests : CustomsBaseUnitTests +public class Tests : Data.Customs.BaseUnitTests { private static readonly Func expectValidationException = Assert.Throws; diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/CustomCreateData.cs b/tests/UnitTests/Customs/Domain/Customs/Create/CustomCreateData.cs deleted file mode 100644 index e2f4aa762..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Create/CustomCreateData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create; - -public class CustomCreateData : TheoryData; diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateInvalidDescriptionData.cs b/tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateInvalidDescriptionData.cs deleted file mode 100644 index bc9efb76d..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateInvalidDescriptionData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create.Data; - -using static CustomsData; - -public class CustomCreateInvalidDescriptionData : CustomCreateData -{ - public CustomCreateInvalidDescriptionData() - { - Add(MinValidName, MinInvalidDescription, true); - Add(MaxValidName, MaxInvalidDescription, false); - } -} diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateInvalidNameData.cs b/tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateInvalidNameData.cs deleted file mode 100644 index ec7c20c0c..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateInvalidNameData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create.Data; - -using static CustomsData; - -public class CustomCreateInvalidNameData : CustomCreateData -{ - public CustomCreateInvalidNameData() - { - Add(MinInvalidName, MinValidDescription, true); - Add(MaxInvalidName, MaxValidDescription, false); - } -} diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateValidData.cs b/tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateValidData.cs deleted file mode 100644 index 5274034d9..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Create/Data/CustomCreateValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create.Data; - -using static CustomsData; - -public class CustomCreateValidData : CustomCreateData -{ - public CustomCreateValidData() - { - Add(MinValidName, MinValidDescription, true); - Add(MaxValidName, MaxValidDescription, false); - } -} diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/InvalidData.cs b/tests/UnitTests/Customs/Domain/Customs/Create/InvalidData.cs new file mode 100644 index 000000000..00dc5384a --- /dev/null +++ b/tests/UnitTests/Customs/Domain/Customs/Create/InvalidData.cs @@ -0,0 +1,17 @@ +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create; + +using static Data.Customs.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + // Name + Add(MinInvalidName, MinValidDescription, true); + Add(MaxInvalidName, MaxValidDescription, false); + + // Description + Add(MinValidName, MinInvalidDescription, true); + Add(MaxValidName, MaxInvalidDescription, false); + } +} diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/Normal/Tests.cs b/tests/UnitTests/Customs/Domain/Customs/Create/Normal/Tests.cs new file mode 100644 index 000000000..bd96fb4f8 --- /dev/null +++ b/tests/UnitTests/Customs/Domain/Customs/Create/Normal/Tests.cs @@ -0,0 +1,42 @@ +using CustomCADs.Modules.Customs.Domain.Customs.Enums; +using CustomCADs.Shared.Domain.Exceptions; +using CustomCADs.Shared.Domain.TypedIds.Catalog; + +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create.Normal; + +using static Data.Customs.TestData; + +public class Tests : Data.Customs.BaseUnitTests +{ + private static readonly (CategoryId, CustomCategorySetter) Category = (ValidCategoryId, CustomCategorySetter.Customer); + + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldNotThrowException_WhenCustomIsValid(string name, string description, bool delivery) + { + Custom.Create(name, description, delivery, ValidBuyerId, Category); + } + + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldPopulateProperties(string name, string description, bool forDelivery) + { + var custom = Custom.Create(name, description, forDelivery, ValidBuyerId, Category); + + Assert.Multiple( + () => Assert.Equal(name, custom.Name), + () => Assert.Equal(description, custom.Description), + () => Assert.Equal(forDelivery, custom.ForDelivery), + () => Assert.Equal(ValidBuyerId, custom.BuyerId) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenCustomIsInvalid(string name, string description, bool delivery) + { + Assert.Throws>( + () => Custom.Create(name, description, delivery, ValidBuyerId, Category) + ); + } +} diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/ValidData.cs b/tests/UnitTests/Customs/Domain/Customs/Create/ValidData.cs new file mode 100644 index 000000000..92f74080f --- /dev/null +++ b/tests/UnitTests/Customs/Domain/Customs/Create/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create; + +using static Data.Customs.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(MinValidName, MinValidDescription, true); + Add(MaxValidName, MaxValidDescription, false); + } +} diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/WithId/CustomCreateWitIdUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Create/WithId/CustomCreateWitIdUnitTests.cs deleted file mode 100644 index 42555402a..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/Create/WithId/CustomCreateWitIdUnitTests.cs +++ /dev/null @@ -1,42 +0,0 @@ -using CustomCADs.Shared.Domain.Exceptions; - -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create.WithId; - -using static CustomsData; - -public class CustomCreateWitIdUnitTests : CustomsBaseUnitTests -{ - [Theory] - [ClassData(typeof(Data.CustomCreateValidData))] - public void CreateWithId_ShouldNotThrowException_WhenCustomIsValid(string name, string description, bool delivery) - { - CreateCustomWithId(ValidId, name, description, delivery, ValidBuyerId); - } - - [Theory] - [ClassData(typeof(Data.CustomCreateValidData))] - public void CreateWithId_ShouldPopulateProperties(string name, string description, bool forDelivery) - { - var custom = CreateCustomWithId(ValidId, name, description, forDelivery, ValidBuyerId); - - Assert.Multiple( - () => Assert.Equal(ValidId, custom.Id), - () => Assert.Equal(name, custom.Name), - () => Assert.Equal(description, custom.Description), - () => Assert.Equal(forDelivery, custom.ForDelivery), - () => Assert.Equal(ValidBuyerId, custom.BuyerId) - ); - } - - [Theory] - [ClassData(typeof(Data.CustomCreateInvalidNameData))] - [ClassData(typeof(Data.CustomCreateInvalidDescriptionData))] - public void CreateWithId_ShouldThrowException_WhenCustomIsInvalid(string name, string description, bool delivery) - { - Assert.Throws>((Action)(() => - { - CustomsBaseUnitTests.CreateCustomWithId(CustomsData.ValidId, name, description, (bool?)delivery, ValidBuyerId); - CreateCustom(name, description, delivery, ValidBuyerId); - })); - } -} diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/Normal/CustomCreateUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/Create/WithId/Tests.cs similarity index 58% rename from tests/UnitTests/Customs/Domain/Customs/Create/Normal/CustomCreateUnitTests.cs rename to tests/UnitTests/Customs/Domain/Customs/Create/WithId/Tests.cs index 8f13ebb76..82620f126 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Create/Normal/CustomCreateUnitTests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Create/WithId/Tests.cs @@ -1,25 +1,26 @@ -namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create.Normal; +using CustomCADs.Shared.Domain.Exceptions; -using CustomCADs.Shared.Domain.Exceptions; -using Data; -using static CustomsData; +namespace CustomCADs.UnitTests.Customs.Domain.Customs.Create.WithId; -public class CustomCreateUnitTests : CustomsBaseUnitTests +using static Data.Customs.TestData; + +public class Tests : Data.Customs.BaseUnitTests { [Theory] - [ClassData(typeof(CustomCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldNotThrowException_WhenCustomIsValid(string name, string description, bool delivery) { CreateCustom(name, description, delivery, ValidBuyerId); } [Theory] - [ClassData(typeof(CustomCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldPopulateProperties(string name, string description, bool forDelivery) { var custom = CreateCustom(name, description, forDelivery, ValidBuyerId); Assert.Multiple( + () => Assert.Equal(ValidId, custom.Id), () => Assert.Equal(name, custom.Name), () => Assert.Equal(description, custom.Description), () => Assert.Equal(forDelivery, custom.ForDelivery), @@ -28,12 +29,12 @@ public void Create_ShouldPopulateProperties(string name, string description, boo } [Theory] - [ClassData(typeof(CustomCreateInvalidNameData))] - [ClassData(typeof(CustomCreateInvalidDescriptionData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenCustomIsInvalid(string name, string description, bool delivery) { - Assert.Throws>( - () => CreateCustom(name, description, delivery, ValidBuyerId) - ); + Assert.Throws>((Action)(() => + { + Data.Customs.BaseUnitTests.CreateCustom(name, description, (bool?)delivery, ValidBuyerId); + })); } } diff --git a/tests/UnitTests/Customs/Domain/Customs/CustomsBaseUnitTests.cs b/tests/UnitTests/Customs/Domain/Customs/CustomsBaseUnitTests.cs deleted file mode 100644 index aced6ce11..000000000 --- a/tests/UnitTests/Customs/Domain/Customs/CustomsBaseUnitTests.cs +++ /dev/null @@ -1,73 +0,0 @@ -using CustomCADs.Modules.Customs.Domain.Customs.Enums; -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Catalog; - -namespace CustomCADs.UnitTests.Customs.Domain.Customs; - -using static CustomsData; - -public class CustomsBaseUnitTests -{ - public static Custom CreateCustom(string? name = null, string? description = null, bool? forDelivery = null, AccountId? buyerId = null, CategoryId? categoryId = null, CustomCategorySetter? setter = null) - => Custom.Create( - name: name ?? MinValidName, - description: description ?? MinValidDescription, - forDelivery: forDelivery ?? false, - buyerId: buyerId ?? ValidBuyerId, - category: (categoryId ?? ValidCategoryId, setter ?? CustomCategorySetter.Customer) - ); - - public static Custom CreateCustomWithId(CustomId? id = null, string? name = null, string? description = null, bool? forDelivery = null, AccountId? buyerId = null, CategoryId? categoryId = null, CustomCategorySetter? setter = null) - => Custom.CreateWithId( - id: id ?? ValidId, - name: name ?? MinValidName, - description: description ?? MinValidDescription, - delivery: forDelivery ?? false, - buyerId: buyerId ?? ValidBuyerId, - category: (categoryId ?? ValidCategoryId, setter ?? CustomCategorySetter.Customer) - ); - - protected static Custom CreateCustomWithStatus(CustomStatus status) - { - Custom custom = CreateCustom(); - - switch (status) - { - case CustomStatus.Pending: - break; - - case CustomStatus.Accepted: - custom.Accept(ValidDesignerId); - break; - - case CustomStatus.Begun: - custom.Accept(ValidDesignerId); - custom.Begin(); - break; - - case CustomStatus.Finished: - custom.Accept(ValidDesignerId); - custom.Begin(); - custom.Finish(ValidCadId, ValidPrice); - break; - - case CustomStatus.Completed: - custom.Accept(ValidDesignerId); - custom.Begin(); - custom.Finish(ValidCadId, ValidPrice); - custom.Complete(customizationId: null); - break; - - case CustomStatus.Reported: - custom.Report(); - break; - - case CustomStatus.Removed: - custom.Report(); - custom.Remove(); - break; - } - - return custom; - } -} diff --git a/tests/UnitTests/Customs/Domain/GlobalUsings.cs b/tests/UnitTests/Customs/Domain/GlobalUsings.cs index 106230236..1383d2a85 100644 --- a/tests/UnitTests/Customs/Domain/GlobalUsings.cs +++ b/tests/UnitTests/Customs/Domain/GlobalUsings.cs @@ -1,4 +1,2 @@ global using CustomCADs.Modules.Customs.Domain.Customs; -global using CustomCADs.Shared.Domain.TypedIds.Customs; -global using CustomCADs.UnitTests.Customs.Data; global using Xunit; diff --git a/tests/UnitTests/Delivery/Application/GlobalUsings.cs b/tests/UnitTests/Delivery/Application/GlobalUsings.cs index 1849b5ab4..d092257f4 100644 --- a/tests/UnitTests/Delivery/Application/GlobalUsings.cs +++ b/tests/UnitTests/Delivery/Application/GlobalUsings.cs @@ -1,5 +1,4 @@ global using CustomCADs.Modules.Delivery.Domain.Shipments; global using CustomCADs.Shared.Domain.TypedIds.Delivery; -global using CustomCADs.UnitTests.Delivery.Data; global using Moq; global using Xunit; diff --git a/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/CancelShipmentHandlerUnitTests.cs b/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs similarity index 94% rename from tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/CancelShipmentHandlerUnitTests.cs rename to tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs index 5334faf16..d8cf73047 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/CancelShipmentHandlerUnitTests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Commands.Internal.Cancel; -using static ShipmentsData; +using static Data.Shipments.TestData; -public class CancelShipmentHandlerUnitTests : ShipmentsBaseUnitTests +public class Tests : Data.Shipments.BaseUnitTests { private readonly CancelShipmentHandler handler; private readonly Mock reads = new(); @@ -18,7 +18,7 @@ public class CancelShipmentHandlerUnitTests : ShipmentsBaseUnitTests private const string Comment = "Cancelling due to unpredicted travelling abroad"; - public CancelShipmentHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, delivery.Object); diff --git a/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/CreateShipmentHandlerUnitTests.cs b/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs similarity index 95% rename from tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/CreateShipmentHandlerUnitTests.cs rename to tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs index 4c45d06b5..4dbfa73b4 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/CreateShipmentHandlerUnitTests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs @@ -8,9 +8,9 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Commands.Shared.Create; -using static ShipmentsData; +using static Data.Shipments.TestData; -public class CreateShipmentHandlerUnitTests : ShipmentsBaseUnitTests +public class Tests : Data.Shipments.BaseUnitTests { private readonly CreateShipmentHandler handler; private readonly Mock> writes = new(); @@ -18,14 +18,14 @@ public class CreateShipmentHandlerUnitTests : ShipmentsBaseUnitTests private readonly Mock sender = new(); private readonly Mock delivery = new(); - public CreateShipmentHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, sender.Object, delivery.Object); writes.Setup(x => x.AddAsync( It.Is(x => x.BuyerId == ValidBuyerId), ct - )).ReturnsAsync(CreateShipmentWithId()); + )).ReturnsAsync(CreateShipment()); sender.Setup(x => x.SendQueryAsync( It.Is(x => x.Id == ValidBuyerId), diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/GetAllShipmentsHandlerUnitTests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/Tests.cs similarity index 92% rename from tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/GetAllShipmentsHandlerUnitTests.cs rename to tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/Tests.cs index cc21abb1d..b2bc4eeb1 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/GetAllShipmentsHandlerUnitTests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/Tests.cs @@ -5,7 +5,7 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Internal.GetAll; -public class GetAllShipmentsHandlerUnitTests : ShipmentsBaseUnitTests +public class Tests : Data.Shipments.BaseUnitTests { private readonly GetAllShipmentsHandler handler; private readonly Mock reads = new(); @@ -18,7 +18,7 @@ public class GetAllShipmentsHandlerUnitTests : ShipmentsBaseUnitTests ]; private readonly ShipmentQuery shipmentQuery = new(new(), null, null); - public GetAllShipmentsHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/GetShipmentSortingsHandlerUnitTests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/Tests.cs similarity index 88% rename from tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/GetShipmentSortingsHandlerUnitTests.cs rename to tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/Tests.cs index 45e4a68f0..ec753e42f 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/GetShipmentSortingsHandlerUnitTests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Internal.GetSortings; -public class GetShipmentSortingsHandlerUnitTests : ShipmentsBaseUnitTests +public class Tests : Data.Shipments.BaseUnitTests { private readonly GetShipmentSortingsHandler handler = new(); diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/GetShipmentTrackHandlerUnitTests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs similarity index 86% rename from tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/GetShipmentTrackHandlerUnitTests.cs rename to tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs index 16e16fef4..7de52e4c7 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/GetShipmentTrackHandlerUnitTests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Internal.GetTrack; -using static ShipmentsData; +using static Data.Shipments.TestData; -public class GetShipmentTrackHandlerUnitTests : ShipmentsBaseUnitTests +public class Tests : Data.Shipments.BaseUnitTests { private readonly GetShipmentTracksHandler handler; private readonly Mock reads = new(); @@ -16,7 +16,7 @@ public class GetShipmentTrackHandlerUnitTests : ShipmentsBaseUnitTests private static readonly ShipmentTrackDto[] statuses = CreateShipmentTracksDtos(); - public GetShipmentTrackHandlerUnitTests() + public Tests() { handler = new(reads.Object, delivery.Object); @@ -96,4 +96,14 @@ await Assert.ThrowsAsync>( async () => await handler.Handle(query, ct) ); } + + private static ShipmentTrackDto[] CreateShipmentTracksDtos(int count = 4, string message = "Message") + => [.. + Enumerable.Range(1, count).Select(i => new ShipmentTrackDto( + DateTime: DateTimeOffset.UtcNow.AddSeconds(i), + Place: null, + IsDelivered: false, + Message: message + i + )) + ]; } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/GetShipmentWaybillHandlerUnitTests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs similarity index 95% rename from tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/GetShipmentWaybillHandlerUnitTests.cs rename to tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs index 0f0675ac6..d88612eea 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/GetShipmentWaybillHandlerUnitTests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Internal.GetWaybill; using static DomainConstants.Users; -using static ShipmentsData; +using static Data.Shipments.TestData; -public class GetShipmentWaybillHandlerUnitTests : ShipmentsBaseUnitTests +public class Tests : Data.Shipments.BaseUnitTests { private readonly GetShipmentWaybillHandler handler; private readonly Mock reads = new(); @@ -17,7 +17,7 @@ public class GetShipmentWaybillHandlerUnitTests : ShipmentsBaseUnitTests private static readonly byte[] bytes = [1, 2, 3, 4, 5, 6]; - public GetShipmentWaybillHandlerUnitTests() + public Tests() { handler = new(reads.Object, delivery.Object); diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Data/CalculateShipmentInvalidData.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/InvalidData.cs similarity index 72% rename from tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Data/CalculateShipmentInvalidData.cs rename to tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/InvalidData.cs index 106ecc098..cb075005f 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Data/CalculateShipmentInvalidData.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/InvalidData.cs @@ -1,8 +1,8 @@ -namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Shared.Data; +namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Shared.Calculate; -public class CalculateShipmentInvalidData : TheoryData +public class InvalidData : TheoryData { - public CalculateShipmentInvalidData() + public InvalidData() { // Country Add(null!, "Burgas", "Slivnitsa"); diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/CalculateShipmentHandlerUnitTests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs similarity index 93% rename from tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/CalculateShipmentHandlerUnitTests.cs rename to tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs index f92d2922b..6e4756970 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/CalculateShipmentHandlerUnitTests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs @@ -4,9 +4,9 @@ using CustomCADs.Shared.Application.Dtos.Delivery; using CustomCADs.Shared.Application.UseCases.Shipments.Queries; -namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Shared; +namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Shared.Calculate; -public class CalculateShipmentHandlerUnitTests : ShipmentsBaseUnitTests +public class Tests : Data.Shipments.BaseUnitTests { private readonly CalculateShipmentHandler handler; private readonly Mock delivery = new(); @@ -17,7 +17,7 @@ public class CalculateShipmentHandlerUnitTests : ShipmentsBaseUnitTests private static readonly double[] weights = [0, 1, 2, 3, 4, 5, 6]; private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); - public CalculateShipmentHandlerUnitTests() + public Tests() { handler = new(delivery.Object); diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/CalculateShipmentValidatorUnitTests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Validator.cs similarity index 88% rename from tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/CalculateShipmentValidatorUnitTests.cs rename to tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Validator.cs index 3425c77fc..5990d6355 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/CalculateShipmentValidatorUnitTests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Validator.cs @@ -3,9 +3,9 @@ using CustomCADs.Shared.Application.UseCases.Shipments.Queries; using FluentValidation.TestHelper; -namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Shared; +namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Shared.Calculate; -public class CalculateShipmentValidatorUnitTests : ShipmentsBaseUnitTests +public class Validator : Data.Shipments.BaseUnitTests { private readonly CalculateShipmentValidator validator = new(); @@ -26,7 +26,7 @@ public async Task Validate_ShouldBeValid_WhenAddressIsValid() } [Theory] - [ClassData(typeof(Data.CalculateShipmentInvalidData))] + [ClassData(typeof(InvalidData))] public async Task Validate_ShouldBeInvalid_WhenAddressIsInvalid(string country, string city, string street) { // Arrange diff --git a/tests/UnitTests/Delivery/Application/Shipments/ShipmentsBaseUnitTests.cs b/tests/UnitTests/Delivery/Application/Shipments/ShipmentsBaseUnitTests.cs deleted file mode 100644 index cf10f162f..000000000 --- a/tests/UnitTests/Delivery/Application/Shipments/ShipmentsBaseUnitTests.cs +++ /dev/null @@ -1,71 +0,0 @@ -using CustomCADs.Modules.Delivery.Application.Contracts.Dtos; -using CustomCADs.Shared.Domain.TypedIds.Accounts; - -namespace CustomCADs.UnitTests.Delivery.Application.Shipments; - -using static ShipmentsData; - -public class ShipmentsBaseUnitTests -{ - protected static readonly CancellationToken ct = CancellationToken.None; - - public static Shipment CreateShipment( - AccountId? buyerId = null, - string? service = null, - string? email = null, - string? phone = null, - string? recipient = null, - int? count = null, - double? weight = null, - string? country = null, - string? city = null, - string? street = null - ) => Shipment.Create( - buyerId: buyerId ?? ValidBuyerId, - service: service ?? ValidService, - email: email ?? ValidEmail, - phone: phone ?? ValidPhone, - recipient: recipient ?? ValidRecipient, - count: count ?? MinValidCount, - weight: weight ?? MinValidWeight, - country: country ?? ValidCountry, - city: city ?? ValidCity, - street: street ?? ValidStreet - ); - - public static Shipment CreateShipmentWithId( - ShipmentId? id = null, - AccountId? buyerId = null, - string? service = null, - string? email = null, - string? phone = null, - string? recipient = null, - int? count = null, - double? weight = null, - string? country = null, - string? city = null, - string? street = null - ) => Shipment.CreateWithId( - id: id ?? ValidId, - buyerId: buyerId ?? ValidBuyerId, - service: service ?? ValidService, - email: email ?? ValidEmail, - phone: phone ?? ValidPhone, - recipient: recipient ?? ValidRecipient, - count: count ?? MinValidCount, - weight: weight ?? MinValidWeight, - country: country ?? ValidCountry, - city: city ?? ValidCity, - street: street ?? ValidStreet - ); - - protected static ShipmentTrackDto[] CreateShipmentTracksDtos(int count = 4, string message = "Message") - => [.. - Enumerable.Range(1, count).Select(i => new ShipmentTrackDto( - DateTime: DateTimeOffset.UtcNow.AddSeconds(i), - Place: null, - IsDelivered: false, - Message: message + i - )) - ]; -} diff --git a/tests/UnitTests/Delivery/Data/Shipments/BaseUnitTests.cs b/tests/UnitTests/Delivery/Data/Shipments/BaseUnitTests.cs new file mode 100644 index 000000000..7c987b513 --- /dev/null +++ b/tests/UnitTests/Delivery/Data/Shipments/BaseUnitTests.cs @@ -0,0 +1,38 @@ +using CustomCADs.Modules.Delivery.Domain.Shipments; +using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Delivery; + +namespace CustomCADs.UnitTests.Delivery.Data.Shipments; + +using static TestData; + +public partial class BaseUnitTests +{ + protected static readonly CancellationToken ct = CancellationToken.None; + + protected static Shipment CreateShipment( + AccountId? buyerId = null, + string? service = null, + string? email = null, + string? phone = null, + string? recipient = null, + int? count = null, + double? weight = null, + string? country = null, + string? city = null, + string? street = null, + ShipmentId? id = null + ) => Shipment.CreateWithId( + id: id ?? ValidId, + buyerId: buyerId ?? ValidBuyerId, + service: service ?? ValidService, + email: email ?? ValidEmail, + phone: phone ?? ValidPhone, + recipient: recipient ?? ValidRecipient, + count: count ?? MinValidCount, + weight: weight ?? MinValidWeight, + country: country ?? ValidCountry, + city: city ?? ValidCity, + street: street ?? ValidStreet + ); +} diff --git a/tests/UnitTests/Delivery/Data/ShipmentsData.cs b/tests/UnitTests/Delivery/Data/Shipments/TestData.cs similarity index 87% rename from tests/UnitTests/Delivery/Data/ShipmentsData.cs rename to tests/UnitTests/Delivery/Data/Shipments/TestData.cs index e383e04c3..1161c6b5e 100644 --- a/tests/UnitTests/Delivery/Data/ShipmentsData.cs +++ b/tests/UnitTests/Delivery/Data/Shipments/TestData.cs @@ -1,14 +1,12 @@ -using CustomCADs.Modules.Delivery.Domain.Shipments; -using CustomCADs.Shared.Domain; +using CustomCADs.Modules.Delivery.Domain.Shipments; using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Delivery; -namespace CustomCADs.UnitTests.Delivery.Data; +namespace CustomCADs.UnitTests.Delivery.Data.Shipments; -using static DomainConstants.Users; using static ShipmentConstants; -public static class ShipmentsData +public static class TestData { public const string ValidCountry = "Bulgaria"; public const string InvalidCountry = ""; diff --git a/tests/UnitTests/Delivery/Domain/GlobalUsings.cs b/tests/UnitTests/Delivery/Domain/GlobalUsings.cs index 0d2aae912..a2e725e34 100644 --- a/tests/UnitTests/Delivery/Domain/GlobalUsings.cs +++ b/tests/UnitTests/Delivery/Domain/GlobalUsings.cs @@ -1,3 +1,2 @@ global using CustomCADs.Modules.Delivery.Domain.Shipments; -global using CustomCADs.UnitTests.Delivery.Data; global using Xunit; diff --git a/tests/UnitTests/Delivery/Domain/Shipments/Create/Data/ShipmentCreateInvalidData.cs b/tests/UnitTests/Delivery/Domain/Shipments/Create/InvalidData.cs similarity index 89% rename from tests/UnitTests/Delivery/Domain/Shipments/Create/Data/ShipmentCreateInvalidData.cs rename to tests/UnitTests/Delivery/Domain/Shipments/Create/InvalidData.cs index ab42dcee5..4d2750075 100644 --- a/tests/UnitTests/Delivery/Domain/Shipments/Create/Data/ShipmentCreateInvalidData.cs +++ b/tests/UnitTests/Delivery/Domain/Shipments/Create/InvalidData.cs @@ -1,20 +1,10 @@ -namespace CustomCADs.UnitTests.Delivery.Domain.Shipments.Create.Data; +namespace CustomCADs.UnitTests.Delivery.Domain.Shipments.Create; -using static ShipmentsData; +using static Data.Shipments.TestData; -public class ShipmentCreateInvalidData : TheoryData< - string, - string?, - string?, - string, - int, - double, - string, - string, - string -> +public class InvalidData : Theory { - public ShipmentCreateInvalidData() + public InvalidData() { // Service Add(InvalidService, ValidEmail, ValidPhone, ValidRecipient, MaxValidCount, MaxValidWeight, ValidCountry, ValidCity, ValidStreet); @@ -46,3 +36,15 @@ public ShipmentCreateInvalidData() Add(ValidService, ValidEmail, ValidPhone, ValidRecipient, MaxValidCount, MaxValidWeight, ValidCountry, ValidCity, InvalidStreet); } } + +public class Theory : TheoryData< + string, + string?, + string?, + string, + int, + double, + string, + string, + string +>; diff --git a/tests/UnitTests/Delivery/Domain/Shipments/Create/WithId/ShipmentCreateWithIdUnitTestss.cs b/tests/UnitTests/Delivery/Domain/Shipments/Create/Normal/Tests.cs similarity index 52% rename from tests/UnitTests/Delivery/Domain/Shipments/Create/WithId/ShipmentCreateWithIdUnitTestss.cs rename to tests/UnitTests/Delivery/Domain/Shipments/Create/Normal/Tests.cs index cda4a1966..147369a95 100644 --- a/tests/UnitTests/Delivery/Domain/Shipments/Create/WithId/ShipmentCreateWithIdUnitTestss.cs +++ b/tests/UnitTests/Delivery/Domain/Shipments/Create/Normal/Tests.cs @@ -1,21 +1,43 @@ using CustomCADs.Shared.Domain.Exceptions; -namespace CustomCADs.UnitTests.Delivery.Domain.Shipments.Create.WithId; +namespace CustomCADs.UnitTests.Delivery.Domain.Shipments.Create.Normal; -using static ShipmentsData; +using static Data.Shipments.TestData; -public class ShipmentCreateWithIdUnitTestss : ShipmentsBaseUnitTests +public class Tests : Data.Shipments.BaseUnitTests { [Fact] - public void CreateWithId_ShouldNotThrowExcepion_WhenShipmentIsValid() + public void Create_ShouldNotThrowExcepion_WhenShipmentIsValid() { - CreateShipmentWithId(); + Shipment.Create( + buyerId: ValidBuyerId, + service: ValidService, + email: ValidEmail, + phone: ValidPhone, + recipient: ValidRecipient, + count: MinValidCount, + weight: MinValidWeight, + country: ValidCountry, + city: ValidCity, + street: ValidStreet + ); } [Fact] - public void CreateWithId_ShouldPopulateProperties_WhenShipmentIsValid() + public void Create_ShouldPopulateProperties_WhenShipmentIsValid() { - var shipment = CreateShipmentWithId(); + Shipment shipment = Shipment.Create( + buyerId: ValidBuyerId, + service: ValidService, + email: ValidEmail, + phone: ValidPhone, + recipient: ValidRecipient, + count: MinValidCount, + weight: MinValidWeight, + country: ValidCountry, + city: ValidCity, + street: ValidStreet + ); Assert.Multiple( () => Assert.Equal(ValidBuyerId, shipment.BuyerId), @@ -28,8 +50,8 @@ public void CreateWithId_ShouldPopulateProperties_WhenShipmentIsValid() } [Theory] - [ClassData(typeof(Data.ShipmentCreateInvalidData))] - public void CreateWithId_ShouldThrowException_WhenInvalid( + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenInvalid( string service, string? email, string? phone, @@ -42,7 +64,8 @@ string street ) { Assert.Throws>( - () => CreateShipmentWithId( + () => Shipment.Create( + buyerId: ValidBuyerId, service: service, email: email, phone: phone, diff --git a/tests/UnitTests/Delivery/Domain/Shipments/Create/Normal/ShipmentCreateUnitTests.cs b/tests/UnitTests/Delivery/Domain/Shipments/Create/WithId/Tests.cs similarity index 89% rename from tests/UnitTests/Delivery/Domain/Shipments/Create/Normal/ShipmentCreateUnitTests.cs rename to tests/UnitTests/Delivery/Domain/Shipments/Create/WithId/Tests.cs index 2d66cdd7d..0fb0faca8 100644 --- a/tests/UnitTests/Delivery/Domain/Shipments/Create/Normal/ShipmentCreateUnitTests.cs +++ b/tests/UnitTests/Delivery/Domain/Shipments/Create/WithId/Tests.cs @@ -1,10 +1,10 @@ using CustomCADs.Shared.Domain.Exceptions; -namespace CustomCADs.UnitTests.Delivery.Domain.Shipments.Create.Normal; +namespace CustomCADs.UnitTests.Delivery.Domain.Shipments.Create.WithId; -using static ShipmentsData; +using static Data.Shipments.TestData; -public class ShipmentCreateUnitTests : ShipmentsBaseUnitTests +public class Tests : Data.Shipments.BaseUnitTests { [Fact] public void Create_ShouldNotThrowExcepion_WhenShipmentIsValid() @@ -28,7 +28,7 @@ public void Create_ShouldPopulateProperties_WhenShipmentIsValid() } [Theory] - [ClassData(typeof(Data.ShipmentCreateInvalidData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenInvalid( string service, string? email, diff --git a/tests/UnitTests/Delivery/Domain/Shipments/ShipmentsBaseUnitTests.cs b/tests/UnitTests/Delivery/Domain/Shipments/ShipmentsBaseUnitTests.cs deleted file mode 100644 index 33388a613..000000000 --- a/tests/UnitTests/Delivery/Domain/Shipments/ShipmentsBaseUnitTests.cs +++ /dev/null @@ -1,59 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Delivery; - -namespace CustomCADs.UnitTests.Delivery.Domain.Shipments; - -using static ShipmentsData; - -public class ShipmentsBaseUnitTests -{ - protected static Shipment CreateShipment( - AccountId? buyerId = null, - string? service = null, - string? email = null, - string? phone = null, - string? recipient = null, - int? count = null, - double? weight = null, - string? country = null, - string? city = null, - string? street = null - ) => Shipment.Create( - buyerId: buyerId ?? ValidBuyerId, - service: service ?? ValidService, - email: email ?? ValidEmail, - phone: phone ?? ValidPhone, - recipient: recipient ?? ValidRecipient, - count: count ?? MinValidCount, - weight: weight ?? MinValidWeight, - country: country ?? ValidCountry, - city: city ?? ValidCity, - street: street ?? ValidStreet - ); - - protected static Shipment CreateShipmentWithId( - ShipmentId? id = null, - AccountId? buyerId = null, - string? service = null, - string? email = null, - string? phone = null, - string? recipient = null, - int? count = null, - double? weight = null, - string? country = null, - string? city = null, - string? street = null - ) => Shipment.CreateWithId( - id: id ?? ValidId, - buyerId: buyerId ?? ValidBuyerId, - service: service ?? ValidService, - email: email ?? ValidEmail, - phone: phone ?? ValidPhone, - recipient: recipient ?? ValidRecipient, - count: count ?? MinValidCount, - weight: weight ?? MinValidWeight, - country: country ?? ValidCountry, - city: city ?? ValidCity, - street: street ?? ValidStreet - ); -} diff --git a/tests/UnitTests/Files/Application/Cads/CadsBaseUnitTests.cs b/tests/UnitTests/Files/Application/Cads/CadsBaseUnitTests.cs deleted file mode 100644 index 983a0c86e..000000000 --- a/tests/UnitTests/Files/Application/Cads/CadsBaseUnitTests.cs +++ /dev/null @@ -1,16 +0,0 @@ -namespace CustomCADs.UnitTests.Files.Application.Cads; - -using CustomCADs.Modules.Files.Domain.Cads.ValueObjects; -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using static CadsData; - -public class CadsBaseUnitTests -{ - protected static readonly CancellationToken ct = CancellationToken.None; - - protected static Cad CreateCad(string? key = null, string? contentType = null, decimal? volume = null, Coordinates? camCoordinates = null, Coordinates? panCoordinates = null, AccountId? ownerId = null) - => Cad.Create(key ?? ValidKey, contentType ?? ValidContentType, volume ?? ValidVolume, camCoordinates ?? ValidCoords, panCoordinates ?? ValidCoords, ownerId ?? ValidOwnerId); - - protected static Cad CreateCadWithId(CadId? id = null, string? key = null, string? contentType = null, decimal? volume = null, Coordinates? camCoordinates = null, Coordinates? panCoordinates = null, AccountId? ownerId = null) - => Cad.CreateWithId(id ?? ValidId, key ?? ValidKey, contentType ?? ValidContentType, volume ?? ValidVolume, camCoordinates ?? ValidCoords, panCoordinates ?? ValidCoords, ownerId ?? ValidOwnerId); -} diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/CreateCadHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs similarity index 90% rename from tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/CreateCadHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs index a3ce7debf..42de3afbe 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/CreateCadHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs @@ -3,23 +3,23 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Internal.Create; -using static CadsData; +using static Data.Cads.TestData; -public class CreateCadHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly CreateCadHandler handler; private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); - public CreateCadHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, cache.Object); writes.Setup(x => x.AddAsync( It.Is(x => x.Key == ValidKey && x.ContentType == ValidContentType), ct - )).ReturnsAsync(CreateCadWithId(id: ValidId)); + )).ReturnsAsync(CreateCad(id: ValidId)); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/EditCadHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs similarity index 93% rename from tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/EditCadHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs index 5debdd20c..ea4501002 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/EditCadHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs @@ -5,18 +5,18 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Internal.Edit; -using static CadsData; +using static Data.Cads.TestData; -public class EditCadHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly EditCadHandler handler; private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); - private readonly Cad cad = CreateCadWithId(); + private readonly Cad cad = CreateCad(); - public EditCadHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, cache.Object); diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/SetCadCoordsHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs similarity index 94% rename from tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/SetCadCoordsHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs index 45df9b2ea..3cd857882 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/SetCadCoordsHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Internal.SetCoords; -using static CadsData; +using static Data.Cads.TestData; -public class SetCadCoordsHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly SetCadCoordsHandler handler; private readonly Mock reads = new(); @@ -17,9 +17,9 @@ public class SetCadCoordsHandlerUnitTests : CadsBaseUnitTests private static readonly CoordinatesDto camCoords = new(MinValidCoord, MinValidCoord, MinValidCoord); private static readonly CoordinatesDto panCoords = new(MaxValidCoord, MaxValidCoord, MaxValidCoord); - private readonly Cad cad = CreateCadWithId(); + private readonly Cad cad = CreateCad(); - public SetCadCoordsHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, cache.Object); reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/BatchDuplicateCadByIdHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs similarity index 93% rename from tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/BatchDuplicateCadByIdHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs index f1bfd0ec4..060b46071 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/BatchDuplicateCadByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Shared.BatchDuplicateById; -using static CadsData; +using static Data.Cads.TestData; -public class BatchDuplicateCadByIdHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly BatchDuplicateCadByIdHandler handler; private readonly Mock reads = new(); @@ -17,13 +17,13 @@ public class BatchDuplicateCadByIdHandlerUnitTests : CadsBaseUnitTests private readonly Mock> cache = new(); private readonly Cad[] cads = [ - CreateCadWithId(), + CreateCad(), ]; private readonly CadId[] Ids = [ValidId]; private readonly CadQuery query; private readonly Result result; - public BatchDuplicateCadByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, cache.Object); diff --git a/tests/UnitTests/Files/Application/Cads/Events/Application/ProductDeletedHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs similarity index 95% rename from tests/UnitTests/Files/Application/Cads/Events/Application/ProductDeletedHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs index ca734ce2e..b693db329 100644 --- a/tests/UnitTests/Files/Application/Cads/Events/Application/ProductDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Events.Application; -using static CadsData; +using static Data.Cads.TestData; -public class ProductDeletedHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly ProductDeletedHandler handler; private readonly Mock reads = new(); @@ -20,7 +20,7 @@ public class ProductDeletedHandlerUnitTests : CadsBaseUnitTests private static readonly Cad cad = CreateCad(); - public ProductDeletedHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, storage.Object, cache.Object); reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(cad); diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/CadDownloadPolicyMock.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/PolicyMock.cs similarity index 82% rename from tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/CadDownloadPolicyMock.cs rename to tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/PolicyMock.cs index 5e41b6a17..c6c1efb3d 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/CadDownloadPolicyMock.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/PolicyMock.cs @@ -2,7 +2,7 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Internal.PresignedUrls.Get; -public class CadDownloadPolicyMock : IFileDownloadPolicy +public class PolicyMock : IFileDownloadPolicy { public FileContextType Type => FileContextType.Product; diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/GetCadPresignedUrlGetHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs similarity index 91% rename from tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/GetCadPresignedUrlGetHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs index ab5f6bb86..578ce3451 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/GetCadPresignedUrlGetHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Internal.PresignedUrls.Get; -using static CadsData; +using static Data.Cads.TestData; -public class GetCadPresignedUrlGetHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly GetCadPresignedUrlGetHandler handler; private readonly Mock reads = new(); @@ -18,9 +18,9 @@ public class GetCadPresignedUrlGetHandlerUnitTests : CadsBaseUnitTests private const FileContextType Type = FileContextType.Product; private const string PresignedUrl = "PresignedUrl"; - public GetCadPresignedUrlGetHandlerUnitTests() + public Tests() { - handler = new(reads.Object, storage.Object, cache.Object, policies: [new CadDownloadPolicyMock()]); + handler = new(reads.Object, storage.Object, cache.Object, policies: [new PolicyMock()]); cache.Setup(x => x.GetOrCreateAsync( ValidId, diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/CadUploadPolicyMock.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/PolicyMock.cs similarity index 83% rename from tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/CadUploadPolicyMock.cs rename to tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/PolicyMock.cs index 3aa7d70fc..67ee01744 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/CadUploadPolicyMock.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/PolicyMock.cs @@ -2,7 +2,7 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Internal.PresignedUrls.Post; -public class CadUploadPolicyMock : IFileUploadPolicy +public class PolicyMock : IFileUploadPolicy { public FileContextType Type => FileContextType.Product; diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/GetCadPresignedUrlPostHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs similarity index 86% rename from tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/GetCadPresignedUrlPostHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs index 4a5aa9196..5fa996165 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/GetCadPresignedUrlPostHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Internal.PresignedUrls.Post; -using static CadsData; +using static Data.Cads.TestData; -public class GetCadPresignedUrlPostHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly GetCadPresignedUrlPostHandler handler; private readonly Mock storage = new(); @@ -17,9 +17,9 @@ public class GetCadPresignedUrlPostHandlerUnitTests : CadsBaseUnitTests public static readonly UploadFileRequest req = new("content-type", "file-name"); public static readonly UploadFileResponse res = new("generated-key", "presigned-url"); - public GetCadPresignedUrlPostHandlerUnitTests() + public Tests() { - handler = new(storage.Object, policies: [new CadUploadPolicyMock()]); + handler = new(storage.Object, policies: [new PolicyMock()]); storage.Setup(x => x.GetPresignedPostUrlAsync(Name, req)) .ReturnsAsync(res); diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/CadReplacePolicyMock.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/PolicyMock.cs similarity index 83% rename from tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/CadReplacePolicyMock.cs rename to tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/PolicyMock.cs index ca905979b..038086e8e 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/CadReplacePolicyMock.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/PolicyMock.cs @@ -2,7 +2,7 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Internal.PresignedUrls.Put; -public class CadReplacePolicyMock : IFileReplacePolicy +public class PolicyMock : IFileReplacePolicy { public FileContextType Type => FileContextType.Product; diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/GetCadPresignedUrlPutHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs similarity index 91% rename from tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/GetCadPresignedUrlPutHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs index 0536cff88..62b4661d8 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/GetCadPresignedUrlPutHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Internal.PresignedUrls.Put; -using static CadsData; +using static Data.Cads.TestData; -public class GetCadPresignedUrlPutHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly GetCadPresignedUrlPutHandler handler; private readonly Mock reads = new(); @@ -20,9 +20,9 @@ public class GetCadPresignedUrlPutHandlerUnitTests : CadsBaseUnitTests private static readonly Cad cad = CreateCad(); private static readonly UploadFileRequest req = new(ValidContentType, "Batman.glb"); - public GetCadPresignedUrlPutHandlerUnitTests() + public Tests() { - handler = new(reads.Object, storage.Object, cache.Object, policies: [new CadReplacePolicyMock()]); + handler = new(reads.Object, storage.Object, cache.Object, policies: [new PolicyMock()]); cache.Setup(x => x.GetOrCreateAsync( ValidId, diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/GetCadExistsByIdHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs similarity index 89% rename from tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/GetCadExistsByIdHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs index c4a744a97..bf4de278b 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/GetCadExistsByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs @@ -4,14 +4,14 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Shared.Exists; -using static CadsData; +using static Data.Cads.TestData; -public class CadExistsByIdHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly CadExistsByIdHandler handler; private readonly Mock reads = new(); - public CadExistsByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)).ReturnsAsync(true); diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/GetCadExistsByIdHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs similarity index 91% rename from tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/GetCadExistsByIdHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs index c374207e7..0bad00304 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/GetCadExistsByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Shared.IsPrintable; -using static CadsData; +using static Data.Cads.TestData; -public class IsCadPrintableByIdHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly IsCadPrintableByIdHandler handler; private readonly Mock reads = new(); @@ -15,7 +15,7 @@ public class IsCadPrintableByIdHandlerUnitTests : CadsBaseUnitTests private readonly Cad Cad = CreateCad(contentType: "not-a-printable-content-type"); - public IsCadPrintableByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); cache.Setup(x => x.GetOrCreateAsync( diff --git a/tests/UnitTests/Files/Application/GlobalUsings.cs b/tests/UnitTests/Files/Application/GlobalUsings.cs index d68289cc0..11807fd6e 100644 --- a/tests/UnitTests/Files/Application/GlobalUsings.cs +++ b/tests/UnitTests/Files/Application/GlobalUsings.cs @@ -2,6 +2,5 @@ global using CustomCADs.Modules.Files.Domain.Images; global using CustomCADs.Shared.Application.Abstractions.Cache; global using CustomCADs.Shared.Domain.TypedIds.Files; -global using CustomCADs.UnitTests.Files.Data; global using Moq; global using Xunit; diff --git a/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/CreateImageHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs similarity index 90% rename from tests/UnitTests/Files/Application/Images/Commands/Internal/Create/CreateImageHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs index 7ea96baee..54eed2719 100644 --- a/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/CreateImageHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs @@ -3,23 +3,23 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Commands.Internal.Create; -using static ImagesData; +using static Data.Images.TestData; -public class CreateImageHandlerUnitTests : ImagesBaseUnitTests +public class Tests : Data.Images.BaseUnitTests { private readonly CreateImageHandler handler; private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); - public CreateImageHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, cache.Object); writes.Setup(x => x.AddAsync( It.Is(x => x.Key == ValidKey && x.ContentType == ValidContentType), ct - )).ReturnsAsync(CreateImageWithId(id: ValidId)); + )).ReturnsAsync(CreateImage(id: ValidId)); } [Fact] diff --git a/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/EditImageHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs similarity index 92% rename from tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/EditImageHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs index bc1ee6fa4..7c0b6941a 100644 --- a/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/EditImageHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs @@ -5,18 +5,18 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Commands.Internal.Edit; -using static ImagesData; +using static Data.Images.TestData; -public class EditImageHandlerUnitTests : ImagesBaseUnitTests +public class Tests : Data.Images.BaseUnitTests { private readonly EditImageHandler handler; private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); - private readonly Image image = CreateImageWithId(); + private readonly Image image = CreateImage(); - public EditImageHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object, cache.Object); diff --git a/tests/UnitTests/Files/Application/Images/Events/Application/ProductDeletedHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs similarity index 95% rename from tests/UnitTests/Files/Application/Images/Events/Application/ProductDeletedHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs index 2be0bf8dc..4b7455a36 100644 --- a/tests/UnitTests/Files/Application/Images/Events/Application/ProductDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Events.Application; -using static ImagesData; +using static Data.Images.TestData; -public class ProductDeletedHandlerUnitTests : ImagesBaseUnitTests +public class Tests : Data.Images.BaseUnitTests { private readonly ProductDeletedHandler handler; private readonly Mock reads = new(); @@ -20,7 +20,7 @@ public class ProductDeletedHandlerUnitTests : ImagesBaseUnitTests private static readonly Image image = CreateImage(); - public ProductDeletedHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, storage.Object, cache.Object); reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(image); diff --git a/tests/UnitTests/Files/Application/Images/ImagesBaseUnitTests.cs b/tests/UnitTests/Files/Application/Images/ImagesBaseUnitTests.cs deleted file mode 100644 index 74ea6361b..000000000 --- a/tests/UnitTests/Files/Application/Images/ImagesBaseUnitTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace CustomCADs.UnitTests.Files.Application.Images; - -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using static ImagesData; - -public class ImagesBaseUnitTests -{ - protected static readonly CancellationToken ct = CancellationToken.None; - - protected static Image CreateImage(string? key = null, string? contentType = null, AccountId? ownerId = null) - => Image.Create(key ?? ValidKey, contentType ?? ValidContentType, ownerId ?? ValidOwnerId); - - protected static Image CreateImageWithId(ImageId? id = null, string? key = null, string? contentType = null, AccountId? ownerId = null) - => Image.CreateWithId(id ?? ValidId, key ?? ValidKey, contentType ?? ValidContentType, ownerId ?? ValidOwnerId); -} diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/ImageDownloadPolicyMock.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/PolicyMock.cs similarity index 82% rename from tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/ImageDownloadPolicyMock.cs rename to tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/PolicyMock.cs index 8fe6bf27d..0b7505c53 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/ImageDownloadPolicyMock.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/PolicyMock.cs @@ -2,7 +2,7 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.PresignedUrls.Get; -public class ImageDownloadPolicyMock : IFileDownloadPolicy +public class PolicyMock : IFileDownloadPolicy { public FileContextType Type => FileContextType.Product; diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/GetImagePresignedUrlGetHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs similarity index 91% rename from tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/GetImagePresignedUrlGetHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs index 5c908abc5..2ab8e6286 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/GetImagePresignedUrlGetHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.PresignedUrls.Get; -using static ImagesData; +using static Data.Images.TestData; -public class GetImagePresignedUrlGetHandlerUnitTests : ImagesBaseUnitTests +public class Tests : Data.Images.BaseUnitTests { private readonly GetImagePresignedUrlGetHandler handler; private readonly Mock reads = new(); @@ -18,9 +18,9 @@ public class GetImagePresignedUrlGetHandlerUnitTests : ImagesBaseUnitTests private const FileContextType Type = FileContextType.Product; private const string PresignedUrl = "PresignedUrl"; - public GetImagePresignedUrlGetHandlerUnitTests() + public Tests() { - handler = new(reads.Object, storage.Object, cache.Object, policies: [new ImageDownloadPolicyMock()]); + handler = new(reads.Object, storage.Object, cache.Object, policies: [new PolicyMock()]); cache.Setup(x => x.GetOrCreateAsync( ValidId, diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/ImageUploadPolicyMock.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/PolicyMock.cs similarity index 82% rename from tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/ImageUploadPolicyMock.cs rename to tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/PolicyMock.cs index e4b7e034a..e4323df83 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/ImageUploadPolicyMock.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/PolicyMock.cs @@ -2,7 +2,7 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.PresignedUrls.Post; -public class ImageUploadPolicyMock : IFileUploadPolicy +public class PolicyMock : IFileUploadPolicy { public FileContextType Type => FileContextType.Product; diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/GetImagePresignedUrlPostHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs similarity index 86% rename from tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/GetImagePresignedUrlPostHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs index 22179a0aa..b6fe5a562 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/GetImagePresignedUrlPostHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.PresignedUrls.Post; -using static ImagesData; +using static Data.Images.TestData; -public class GetImagePresignedUrlPostHandlerUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private readonly GetImagePresignedUrlPostHandler handler; private readonly Mock storage = new(); @@ -18,9 +18,9 @@ public class GetImagePresignedUrlPostHandlerUnitTests : CadsBaseUnitTests public static readonly UploadFileRequest req = new("content-type", "file-name"); public static readonly UploadFileResponse res = new("generated-key", "presigned-url"); - public GetImagePresignedUrlPostHandlerUnitTests() + public Tests() { - handler = new(storage.Object, policies: [new ImageUploadPolicyMock()]); + handler = new(storage.Object, policies: [new PolicyMock()]); storage.Setup(x => x.GetPresignedPostUrlAsync(Name, req)) .ReturnsAsync(res); diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/ImageReplacePolicyMock.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/PolicyMock.cs similarity index 82% rename from tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/ImageReplacePolicyMock.cs rename to tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/PolicyMock.cs index 3191bdf7a..31975e333 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/ImageReplacePolicyMock.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/PolicyMock.cs @@ -2,7 +2,7 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.PresignedUrls.Put; -public class ImageReplacePolicyMock : IFileReplacePolicy +public class PolicyMock : IFileReplacePolicy { public FileContextType Type => FileContextType.Product; diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/GetImagePresignedUrlPutHandlerUnitTests.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs similarity index 91% rename from tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/GetImagePresignedUrlPutHandlerUnitTests.cs rename to tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs index 2c0e00c38..02b842864 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/GetImagePresignedUrlPutHandlerUnitTests.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.PresignedUrls.Put; -using static ImagesData; +using static Data.Images.TestData; -public class GetImagePresignedUrlPutHandlerUnitTests : ImagesBaseUnitTests +public class Tests : Data.Images.BaseUnitTests { private readonly GetImagePresignedUrlPutHandler handler; private readonly Mock reads = new(); @@ -20,9 +20,9 @@ public class GetImagePresignedUrlPutHandlerUnitTests : ImagesBaseUnitTests private static readonly Image image = CreateImage(); private static readonly UploadFileRequest req = new(ValidContentType, "Batman.glb"); - public GetImagePresignedUrlPutHandlerUnitTests() + public Tests() { - handler = new(reads.Object, storage.Object, cache.Object, policies: [new ImageReplacePolicyMock()]); + handler = new(reads.Object, storage.Object, cache.Object, policies: [new PolicyMock()]); cache.Setup(x => x.GetOrCreateAsync( ValidId, diff --git a/tests/UnitTests/Files/Data/Cads/BaseUnitTests.cs b/tests/UnitTests/Files/Data/Cads/BaseUnitTests.cs new file mode 100644 index 000000000..19b965a5a --- /dev/null +++ b/tests/UnitTests/Files/Data/Cads/BaseUnitTests.cs @@ -0,0 +1,32 @@ +using CustomCADs.Modules.Files.Domain.Cads; +using CustomCADs.Modules.Files.Domain.Cads.ValueObjects; +using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Files; + +namespace CustomCADs.UnitTests.Files.Data.Cads; + +using static TestData; + +public class BaseUnitTests +{ + protected static readonly CancellationToken ct = CancellationToken.None; + + protected static Cad CreateCad( + string? key = null, + string? contentType = null, + decimal? volume = null, + Coordinates? camCoordinates = null, + Coordinates? panCoordinates = null, + AccountId? ownerId = null, + CadId? id = null + ) + => Cad.CreateWithId( + id: id ?? ValidId, + key: key ?? ValidKey, + contentType: contentType ?? ValidContentType, + volume: volume ?? ValidVolume, + camCoordinates: camCoordinates ?? new(), + panCoordinates: panCoordinates ?? new(), + ownerId: ownerId ?? ValidOwnerId + ); +} diff --git a/tests/UnitTests/Files/Data/CadsData.cs b/tests/UnitTests/Files/Data/Cads/TestData.cs similarity index 94% rename from tests/UnitTests/Files/Data/CadsData.cs rename to tests/UnitTests/Files/Data/Cads/TestData.cs index 6b4f6971e..2fb68d904 100644 --- a/tests/UnitTests/Files/Data/CadsData.cs +++ b/tests/UnitTests/Files/Data/Cads/TestData.cs @@ -3,11 +3,11 @@ using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Files; -namespace CustomCADs.UnitTests.Files.Data; +namespace CustomCADs.UnitTests.Files.Data.Cads; using static CadConstants.Coordinates; -public class CadsData +public class TestData { public const string ValidKey = "key-to-cad"; public const string InvalidKey = ""; diff --git a/tests/UnitTests/Files/Data/Images/BaseUnitTests.cs b/tests/UnitTests/Files/Data/Images/BaseUnitTests.cs new file mode 100644 index 000000000..8cd8b876e --- /dev/null +++ b/tests/UnitTests/Files/Data/Images/BaseUnitTests.cs @@ -0,0 +1,25 @@ +using CustomCADs.Modules.Files.Domain.Images; +using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Files; + +namespace CustomCADs.UnitTests.Files.Data.Images; + +using static TestData; + +public class BaseUnitTests +{ + protected static readonly CancellationToken ct = CancellationToken.None; + + protected static Image CreateImage( + string? key = null, + string? contentType = null, + AccountId? ownerId = null, + ImageId? id = null + ) + => Image.CreateWithId( + id: id ?? ValidId, + key: key ?? ValidKey, + contentType: contentType ?? ValidContentType, + ownerId: ownerId ?? ValidOwnerId + ); +} diff --git a/tests/UnitTests/Files/Data/ImagesData.cs b/tests/UnitTests/Files/Data/Images/TestData.cs similarity index 85% rename from tests/UnitTests/Files/Data/ImagesData.cs rename to tests/UnitTests/Files/Data/Images/TestData.cs index f95bb8516..a4775251d 100644 --- a/tests/UnitTests/Files/Data/ImagesData.cs +++ b/tests/UnitTests/Files/Data/Images/TestData.cs @@ -1,9 +1,9 @@ using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Files; -namespace CustomCADs.UnitTests.Files.Data; +namespace CustomCADs.UnitTests.Files.Data.Images; -public class ImagesData +public class TestData { public const string ValidKey = "key-to-image"; public const string InvalidKey = ""; diff --git a/tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/CadCamCoordinatesUnitTests.cs b/tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/Tests.cs similarity index 91% rename from tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/CadCamCoordinatesUnitTests.cs rename to tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/Tests.cs index 9c0065d2b..a1a34637f 100644 --- a/tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/CadCamCoordinatesUnitTests.cs +++ b/tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Files.Domain.Cads.Behaviors.CamCoordinates; -using static CadsData; +using static Data.Cads.TestData; -public class CadCamCoordinatesUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private static readonly Coordinates coords = new(MinValidCoord, MinValidCoord, MinValidCoord); diff --git a/tests/UnitTests/Files/Domain/Cads/Behaviors/ContentType/CadContentTypeUnitTests.cs b/tests/UnitTests/Files/Domain/Cads/Behaviors/ContentType/Tests.cs similarity index 89% rename from tests/UnitTests/Files/Domain/Cads/Behaviors/ContentType/CadContentTypeUnitTests.cs rename to tests/UnitTests/Files/Domain/Cads/Behaviors/ContentType/Tests.cs index 795fdee71..8f39622b6 100644 --- a/tests/UnitTests/Files/Domain/Cads/Behaviors/ContentType/CadContentTypeUnitTests.cs +++ b/tests/UnitTests/Files/Domain/Cads/Behaviors/ContentType/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Files.Domain.Cads.Behaviors.ContentType; -using static CadsData; +using static Data.Cads.TestData; -public class CadContentTypeUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { [Fact] public void SetContentType_ShouldNotThrowException_WhenContentTypeIsValid() diff --git a/tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/CadPanCoordinatesUnitTests.cs b/tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/Tests.cs similarity index 91% rename from tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/CadPanCoordinatesUnitTests.cs rename to tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/Tests.cs index bb397898c..19e99b2f7 100644 --- a/tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/CadPanCoordinatesUnitTests.cs +++ b/tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Files.Domain.Cads.Behaviors.PanCoordinates; -using static CadsData; +using static Data.Cads.TestData; -public class CadPanCoordinatesUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { private static readonly Coordinates coords = new(MinValidCoord, MinValidCoord, MinValidCoord); diff --git a/tests/UnitTests/Files/Domain/Cads/Behaviors/Volume/CadVolumeUnitTests.cs b/tests/UnitTests/Files/Domain/Cads/Behaviors/Volume/Tests.cs similarity index 88% rename from tests/UnitTests/Files/Domain/Cads/Behaviors/Volume/CadVolumeUnitTests.cs rename to tests/UnitTests/Files/Domain/Cads/Behaviors/Volume/Tests.cs index 7d332549c..fd54977a5 100644 --- a/tests/UnitTests/Files/Domain/Cads/Behaviors/Volume/CadVolumeUnitTests.cs +++ b/tests/UnitTests/Files/Domain/Cads/Behaviors/Volume/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Files.Domain.Cads.Behaviors.Volume; -using static CadsData; +using static Data.Cads.TestData; -public class CadVolumeUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { [Fact] public void SetKey_ShouldNotThrowException_WhenKeyIsValid() diff --git a/tests/UnitTests/Files/Domain/Cads/CadsBaseUnitTests.cs b/tests/UnitTests/Files/Domain/Cads/CadsBaseUnitTests.cs deleted file mode 100644 index 8abfe5ac4..000000000 --- a/tests/UnitTests/Files/Domain/Cads/CadsBaseUnitTests.cs +++ /dev/null @@ -1,46 +0,0 @@ -using CustomCADs.Modules.Files.Domain.Cads.ValueObjects; -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Files; - -namespace CustomCADs.UnitTests.Files.Domain.Cads; - -using static CadsData; - -public class CadsBaseUnitTests -{ - protected static Cad CreateCad( - string? key = null, - string? contentType = null, - decimal? volume = null, - Coordinates? camCoordinates = null, - Coordinates? panCoordinates = null, - AccountId? ownerId = null - ) - => Cad.Create( - key: key ?? ValidKey, - contentType: contentType ?? ValidContentType, - volume: volume ?? ValidVolume, - camCoordinates: camCoordinates ?? new(), - panCoordinates: panCoordinates ?? new(), - ownerId: ownerId ?? ValidOwnerId - ); - - protected static Cad CreateCadWithId( - CadId? id = null, - string? key = null, - string? contentType = null, - decimal? volume = null, - Coordinates? camCoordinates = null, - Coordinates? panCoordinates = null, - AccountId? ownerId = null - ) - => Cad.CreateWithId( - id: id ?? ValidId, - key: key ?? ValidKey, - contentType: contentType ?? ValidContentType, - volume: volume ?? ValidVolume, - camCoordinates: camCoordinates ?? new(), - panCoordinates: panCoordinates ?? new(), - ownerId: ownerId ?? ValidOwnerId - ); -} diff --git a/tests/UnitTests/Files/Domain/Cads/Create/Data/CadCreateInvalidData.cs b/tests/UnitTests/Files/Domain/Cads/Create/InvalidData.cs similarity index 76% rename from tests/UnitTests/Files/Domain/Cads/Create/Data/CadCreateInvalidData.cs rename to tests/UnitTests/Files/Domain/Cads/Create/InvalidData.cs index a57538a2c..546ccf275 100644 --- a/tests/UnitTests/Files/Domain/Cads/Create/Data/CadCreateInvalidData.cs +++ b/tests/UnitTests/Files/Domain/Cads/Create/InvalidData.cs @@ -1,12 +1,12 @@ using CustomCADs.Modules.Files.Domain.Cads.ValueObjects; -namespace CustomCADs.UnitTests.Files.Domain.Cads.Create.Data; +namespace CustomCADs.UnitTests.Files.Domain.Cads.Create; -using static CadsData; +using static Data.Cads.TestData; -public class CadCreateInvalidData : TheoryData +public class InvalidData : TheoryData { - public CadCreateInvalidData() + public InvalidData() { // Key diff --git a/tests/UnitTests/Files/Domain/Cads/Create/Normal/Tests.cs b/tests/UnitTests/Files/Domain/Cads/Create/Normal/Tests.cs new file mode 100644 index 000000000..040a22f6c --- /dev/null +++ b/tests/UnitTests/Files/Domain/Cads/Create/Normal/Tests.cs @@ -0,0 +1,38 @@ +using CustomCADs.Modules.Files.Domain.Cads.ValueObjects; +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Files.Domain.Cads.Create.Normal; + +using static Data.Cads.TestData; + +public class Tests : Data.Cads.BaseUnitTests +{ + [Fact] + public void Create_ShouldNotThrowExcepion_WhenCadIsValid() + { + Cad.Create(ValidKey, ValidContentType, ValidVolume, ValidCoords, ValidCoords, ValidOwnerId); + } + + [Fact] + public void Create_ShouldPopulateProperties_WhenCadIsValid() + { + var cad = Cad.Create(ValidKey, ValidContentType, ValidVolume, ValidCoords, ValidCoords, ValidOwnerId); + + Assert.Multiple( + () => Assert.Equal(ValidKey, cad.Key), + () => Assert.Equal(ValidContentType, cad.ContentType), + () => Assert.Equal(ValidVolume, cad.Volume), + () => Assert.Equal(ValidCoords, cad.CamCoordinates), + () => Assert.Equal(ValidCoords, cad.PanCoordinates) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenKeyIsInvalid(string key, string contentType, decimal volume, Coordinates camCoords, Coordinates panCoords) + { + Assert.Throws>( + () => Cad.Create(key, contentType, volume, camCoords, panCoords, ValidOwnerId) + ); + } +} diff --git a/tests/UnitTests/Files/Domain/Cads/Create/WithId/CadCreateWithIdUnitTests.cs b/tests/UnitTests/Files/Domain/Cads/Create/WithId/CadCreateWithIdUnitTests.cs deleted file mode 100644 index d66d3f265..000000000 --- a/tests/UnitTests/Files/Domain/Cads/Create/WithId/CadCreateWithIdUnitTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CustomCADs.Modules.Files.Domain.Cads.ValueObjects; -using CustomCADs.Shared.Domain.Exceptions; - -namespace CustomCADs.UnitTests.Files.Domain.Cads.Create.WithId; - -using static CadsData; - -public class CadCreateWithIdUnitTests : CadsBaseUnitTests -{ - [Fact] - public void CreateWithId_ShouldNotThrowExcepion_WhenCadIsValid() - { - CreateCadWithId(ValidId, ValidKey, ValidContentType, ValidVolume, ValidCoords, ValidCoords); - } - - [Fact] - public void CreateWithId_ShouldPopulateProperties_WhenCadIsValid() - { - var cad = CreateCadWithId(ValidId, ValidKey, ValidContentType, ValidVolume, ValidCoords, ValidCoords); - - Assert.Multiple( - () => Assert.Equal(ValidId, cad.Id), - () => Assert.Equal(ValidKey, cad.Key), - () => Assert.Equal(ValidContentType, cad.ContentType), - () => Assert.Equal(ValidVolume, cad.Volume), - () => Assert.Equal(ValidCoords, cad.CamCoordinates), - () => Assert.Equal(ValidCoords, cad.PanCoordinates) - ); - } - - [Theory] - [ClassData(typeof(Data.CadCreateInvalidData))] - public void CreateWithId_ShouldThrowException_WhenCadIsInvalid(string key, string contentType, decimal volume, Coordinates camCoords, Coordinates panCoords) - { - Assert.Throws>( - () => CreateCadWithId(ValidId, key, contentType, volume, camCoords, panCoords) - ); - } -} diff --git a/tests/UnitTests/Files/Domain/Cads/Create/Normal/CadCreateUnitTests.cs b/tests/UnitTests/Files/Domain/Cads/Create/WithId/Tests.cs similarity index 70% rename from tests/UnitTests/Files/Domain/Cads/Create/Normal/CadCreateUnitTests.cs rename to tests/UnitTests/Files/Domain/Cads/Create/WithId/Tests.cs index ba3343135..82a6a0bd8 100644 --- a/tests/UnitTests/Files/Domain/Cads/Create/Normal/CadCreateUnitTests.cs +++ b/tests/UnitTests/Files/Domain/Cads/Create/WithId/Tests.cs @@ -1,24 +1,25 @@ using CustomCADs.Modules.Files.Domain.Cads.ValueObjects; using CustomCADs.Shared.Domain.Exceptions; -namespace CustomCADs.UnitTests.Files.Domain.Cads.Create.Normal; +namespace CustomCADs.UnitTests.Files.Domain.Cads.Create.WithId; -using static CadsData; +using static Data.Cads.TestData; -public class CadCreateUnitTests : CadsBaseUnitTests +public class Tests : Data.Cads.BaseUnitTests { [Fact] public void Create_ShouldNotThrowExcepion_WhenCadIsValid() { - CreateCad(ValidKey, ValidContentType, ValidVolume, ValidCoords, ValidCoords); + CreateCad(); } [Fact] public void Create_ShouldPopulateProperties_WhenCadIsValid() { - var cad = CreateCad(ValidKey, ValidContentType, ValidVolume, ValidCoords, ValidCoords); + var cad = CreateCad(ValidKey, ValidContentType, ValidVolume, ValidCoords, ValidCoords, id: ValidId); Assert.Multiple( + () => Assert.Equal(ValidId, cad.Id), () => Assert.Equal(ValidKey, cad.Key), () => Assert.Equal(ValidContentType, cad.ContentType), () => Assert.Equal(ValidVolume, cad.Volume), @@ -28,8 +29,8 @@ public void Create_ShouldPopulateProperties_WhenCadIsValid() } [Theory] - [ClassData(typeof(Data.CadCreateInvalidData))] - public void Create_ShouldThrowException_WhenKeyIsInvalid(string key, string contentType, decimal volume, Coordinates camCoords, Coordinates panCoords) + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenCadIsInvalid(string key, string contentType, decimal volume, Coordinates camCoords, Coordinates panCoords) { Assert.Throws>( () => CreateCad(key, contentType, volume, camCoords, panCoords) diff --git a/tests/UnitTests/Files/Domain/GlobalUsings.cs b/tests/UnitTests/Files/Domain/GlobalUsings.cs index 5d5583bf1..402df97b6 100644 --- a/tests/UnitTests/Files/Domain/GlobalUsings.cs +++ b/tests/UnitTests/Files/Domain/GlobalUsings.cs @@ -1,4 +1,3 @@ global using CustomCADs.Modules.Files.Domain.Cads; global using CustomCADs.Modules.Files.Domain.Images; -global using CustomCADs.UnitTests.Files.Data; global using Xunit; diff --git a/tests/UnitTests/Files/Domain/Images/Behaviors/ContentType/ImageContentTypeUnitTests.cs b/tests/UnitTests/Files/Domain/Images/Behaviors/ContentType/Tests.cs similarity index 89% rename from tests/UnitTests/Files/Domain/Images/Behaviors/ContentType/ImageContentTypeUnitTests.cs rename to tests/UnitTests/Files/Domain/Images/Behaviors/ContentType/Tests.cs index 1ec4566c2..27953de76 100644 --- a/tests/UnitTests/Files/Domain/Images/Behaviors/ContentType/ImageContentTypeUnitTests.cs +++ b/tests/UnitTests/Files/Domain/Images/Behaviors/ContentType/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Files.Domain.Images.Behaviors.ContentType; -using static ImagesData; +using static Data.Images.TestData; -public class ImageContentTypeUnitTests : ImagesBaseUnitTests +public class Tests : Data.Images.BaseUnitTests { [Fact] public void SetContentType_ShouldNotThrowException_WhenContentTypeIsValid() diff --git a/tests/UnitTests/Files/Domain/Images/Create/Data/ImageCreateInvalidData.cs b/tests/UnitTests/Files/Domain/Images/Create/Data/ImageCreateInvalidData.cs deleted file mode 100644 index 49bcec3f0..000000000 --- a/tests/UnitTests/Files/Domain/Images/Create/Data/ImageCreateInvalidData.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace CustomCADs.UnitTests.Files.Domain.Images.Create.Data; - -using static ImagesData; - -public class ImageCreateInvalidData : TheoryData -{ - public ImageCreateInvalidData() - { - // Key - Add(InvalidKey, ValidContentType); - - // Content Type - Add(ValidKey, InvalidContentType); - } -} diff --git a/tests/UnitTests/Files/Domain/Images/Create/InvalidData.cs b/tests/UnitTests/Files/Domain/Images/Create/InvalidData.cs new file mode 100644 index 000000000..63cbf6529 --- /dev/null +++ b/tests/UnitTests/Files/Domain/Images/Create/InvalidData.cs @@ -0,0 +1,15 @@ +namespace CustomCADs.UnitTests.Files.Domain.Images.Create; + +using static Data.Images.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + // Key + Add(InvalidKey, ValidContentType); + + // Content Type + Add(ValidKey, InvalidContentType); + } +} diff --git a/tests/UnitTests/Files/Domain/Images/Create/Normal/ImageCreateUnitTests.cs b/tests/UnitTests/Files/Domain/Images/Create/Normal/Tests.cs similarity index 65% rename from tests/UnitTests/Files/Domain/Images/Create/Normal/ImageCreateUnitTests.cs rename to tests/UnitTests/Files/Domain/Images/Create/Normal/Tests.cs index c98ecf158..73699f1ce 100644 --- a/tests/UnitTests/Files/Domain/Images/Create/Normal/ImageCreateUnitTests.cs +++ b/tests/UnitTests/Files/Domain/Images/Create/Normal/Tests.cs @@ -2,20 +2,20 @@ namespace CustomCADs.UnitTests.Files.Domain.Images.Create.Normal; -using static ImagesData; +using static Data.Images.TestData; -public class ImageCreateUnitTests : ImagesBaseUnitTests +public class Tests : Data.Images.BaseUnitTests { [Fact] public void Create_ShouldNotThrowExcepion_WhenImageIsValid() { - CreateImage(ValidKey, ValidContentType); + Image.Create(ValidKey, ValidContentType, ValidOwnerId); } [Fact] public void Create_ShouldPopulateProperties_WhenImageIsValid() { - var image = CreateImage(key: ValidKey, contentType: ValidContentType); + var image = Image.Create(ValidKey, ValidContentType, ValidOwnerId); Assert.Multiple( () => Assert.Equal(ValidKey, image.Key), @@ -24,11 +24,11 @@ public void Create_ShouldPopulateProperties_WhenImageIsValid() } [Theory] - [ClassData(typeof(Data.ImageCreateInvalidData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenKeyIsInvalid(string key, string contentType) { Assert.Throws>( - () => CreateImage(key: key, contentType: contentType) + () => Image.Create(key, contentType, ValidOwnerId) ); } } diff --git a/tests/UnitTests/Files/Domain/Images/Create/WithId/ImageCreateWithIdUnitTests.cs b/tests/UnitTests/Files/Domain/Images/Create/WithId/ImageCreateWithIdUnitTests.cs deleted file mode 100644 index e590bf998..000000000 --- a/tests/UnitTests/Files/Domain/Images/Create/WithId/ImageCreateWithIdUnitTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -using CustomCADs.Shared.Domain.Exceptions; - -namespace CustomCADs.UnitTests.Files.Domain.Images.Create.WithId; - -using static ImagesData; - -public class ImageCreateWithIdUnitTests : ImagesBaseUnitTests -{ - [Fact] - public void CreateWithId_ShouldNotThrowExcepion_WhenImageIsValid() - { - CreateImageWithId(id: null, ValidKey, ValidContentType); - } - - [Fact] - public void CreateWithId_ShouldPopulateProperties_WhenImageIsValid() - { - var image = CreateImageWithId(id: null, ValidKey, ValidContentType); - - Assert.Multiple( - () => Assert.Equal(ValidKey, image.Key), - () => Assert.Equal(ValidContentType, image.ContentType) - ); - } - - [Theory] - [ClassData(typeof(Data.ImageCreateInvalidData))] - public void CreateWithId_ShouldThrowException_WhenImageIsInvalid(string key, string contentType) - { - Assert.Throws>( - () => CreateImageWithId(id: null, key, contentType) - ); - } -} diff --git a/tests/UnitTests/Files/Domain/Images/Create/WithId/Tests.cs b/tests/UnitTests/Files/Domain/Images/Create/WithId/Tests.cs new file mode 100644 index 000000000..1364d26c8 --- /dev/null +++ b/tests/UnitTests/Files/Domain/Images/Create/WithId/Tests.cs @@ -0,0 +1,35 @@ +using CustomCADs.Shared.Domain.Exceptions; +using CustomCADs.UnitTests.Files.Data.Images; + +namespace CustomCADs.UnitTests.Files.Domain.Images.Create.WithId; + +using static Data.Images.TestData; + +public class Tests : Data.Images.BaseUnitTests +{ + [Fact] + public void Create_ShouldNotThrowExcepion_WhenImageIsValid() + { + CreateImage(); + } + + [Fact] + public void Create_ShouldPopulateProperties_WhenImageIsValid() + { + var image = CreateImage(ValidKey, ValidContentType); + + Assert.Multiple( + () => Assert.Equal(ValidKey, image.Key), + () => Assert.Equal(ValidContentType, image.ContentType) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenImageIsInvalid(string key, string contentType) + { + Assert.Throws>( + () => CreateImage(key, contentType) + ); + } +} diff --git a/tests/UnitTests/Files/Domain/Images/ImagesBaseUnitTests.cs b/tests/UnitTests/Files/Domain/Images/ImagesBaseUnitTests.cs deleted file mode 100644 index 36349422e..000000000 --- a/tests/UnitTests/Files/Domain/Images/ImagesBaseUnitTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Files; - -namespace CustomCADs.UnitTests.Files.Domain.Images; - -using static ImagesData; - -public class ImagesBaseUnitTests -{ - protected static Image CreateImage(string? key = null, string? contentType = null, AccountId? ownerId = null) - => Image.Create(key ?? ValidKey, contentType ?? ValidContentType, ownerId ?? ValidOwnerId); - - protected static Image CreateImageWithId(ImageId? id = null, string? key = null, string? contentType = null, AccountId? ownerId = null) - => Image.CreateWithId(id ?? ImageId.New(), key ?? ValidKey, contentType ?? ValidContentType, ownerId ?? ValidOwnerId); -} diff --git a/tests/UnitTests/Idempotency/Application/GlobalUsings.cs b/tests/UnitTests/Idempotency/Application/GlobalUsings.cs index b9a9d139c..7e4830c10 100644 --- a/tests/UnitTests/Idempotency/Application/GlobalUsings.cs +++ b/tests/UnitTests/Idempotency/Application/GlobalUsings.cs @@ -1,4 +1,3 @@ global using CustomCADs.Modules.Idempotency.Domain.IdempotencyKeys; -global using CustomCADs.UnitTests.Idempotency.Data; global using Moq; global using Xunit; diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/BaseIdempotencyKeyUnitTests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/BaseIdempotencyKeyUnitTests.cs deleted file mode 100644 index e2ccc7146..000000000 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/BaseIdempotencyKeyUnitTests.cs +++ /dev/null @@ -1,24 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Idempotency; - -namespace CustomCADs.UnitTests.Idempotency.Application.IdempotencyKeys; - -using static IdempotencyKeysData; - -public class BaseIdempotencyKeyUnitTests -{ - protected static readonly CancellationToken ct = default; - - protected static IdempotencyKey CreateIdempotencyKey( - IdempotencyKeyId id, - string hash - ) => IdempotencyKey.Create( - id: id, - hash: hash - ); - - protected static IdempotencyKey CreateIdempotencyKey() - => IdempotencyKey.Create( - id: ValidId, - hash: ValidRequestHash - ); -} diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/CompleteIdempotencyKeyHandlerUnitTests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs similarity index 92% rename from tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/CompleteIdempotencyKeyHandlerUnitTests.cs rename to tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs index 9b552c07e..66cbb65ca 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/CompleteIdempotencyKeyHandlerUnitTests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs @@ -5,15 +5,15 @@ namespace CustomCADs.UnitTests.Idempotency.Application.IdempotencyKeys.Commands.Internal.Complete; -using static IdempotencyKeysData; +using static Data.IdempotencyKeys.TestData; -public class CompleteIdempotencyKeyHandlerUnitTests : BaseIdempotencyKeyUnitTests +public class Tests : Data.IdempotencyKeys.BaseUnitTests { private readonly CompleteIdempotencyKeyHandler handler; private readonly Mock reads = new(); private readonly Mock uow = new(); - public CompleteIdempotencyKeyHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/CreateIdempotencyKeyHandlerUnitTests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs similarity index 90% rename from tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/CreateIdempotencyKeyHandlerUnitTests.cs rename to tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs index b405621fb..f77c67dc0 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/CreateIdempotencyKeyHandlerUnitTests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs @@ -4,15 +4,15 @@ namespace CustomCADs.UnitTests.Idempotency.Application.IdempotencyKeys.Commands.Internal.Create; -using static IdempotencyKeysData; +using static Data.IdempotencyKeys.TestData; -public class CreateIdempotencyKeyHandlerUnitTests : BaseIdempotencyKeyUnitTests +public class Tests : Data.IdempotencyKeys.BaseUnitTests { private readonly CreateIdempotencyKeyHandler handler; private readonly Mock> writes = new(); private readonly Mock uow = new(); - public CreateIdempotencyKeyHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object); diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/DeleteIdempotencyKeyHandlerUnitTests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs similarity index 92% rename from tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/DeleteIdempotencyKeyHandlerUnitTests.cs rename to tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs index 4d68539e1..b11e2e2c1 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/DeleteIdempotencyKeyHandlerUnitTests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs @@ -5,16 +5,16 @@ namespace CustomCADs.UnitTests.Idempotency.Application.IdempotencyKeys.Commands.Internal.Delete; -using static IdempotencyKeysData; +using static Data.IdempotencyKeys.TestData; -public class DeleteIdempotencyKeyHandlerUnitTests : BaseIdempotencyKeyUnitTests +public class Tests : Data.IdempotencyKeys.BaseUnitTests { private readonly DeleteIdempotencyKeyHandler handler; private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); - public DeleteIdempotencyKeyHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object); diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/GetIdempotencyKeyHandlerUnitTests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs similarity index 93% rename from tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/GetIdempotencyKeyHandlerUnitTests.cs rename to tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs index 1f8621dd1..d55a2e733 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/GetIdempotencyKeyHandlerUnitTests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs @@ -4,16 +4,16 @@ namespace CustomCADs.UnitTests.Idempotency.Application.IdempotencyKeys.Queries.Internal.Get; -using static IdempotencyKeysData; +using static Data.IdempotencyKeys.TestData; -public class GetIdempotencyKeyHandlerUnitTests : BaseIdempotencyKeyUnitTests +public class Tests : Data.IdempotencyKeys.BaseUnitTests { private readonly GetIdempotencyKeyHandler handler; private readonly Mock reads = new(); private static readonly IdempotencyKey idempotencyKey = CreateIdempotencyKey(); - public GetIdempotencyKeyHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Idempotency/Data/IdempotencyKeys/BaseUnitTests.cs b/tests/UnitTests/Idempotency/Data/IdempotencyKeys/BaseUnitTests.cs new file mode 100644 index 000000000..a0c5f87e9 --- /dev/null +++ b/tests/UnitTests/Idempotency/Data/IdempotencyKeys/BaseUnitTests.cs @@ -0,0 +1,19 @@ +using CustomCADs.Modules.Idempotency.Domain.IdempotencyKeys; +using CustomCADs.Shared.Domain.TypedIds.Idempotency; + +namespace CustomCADs.UnitTests.Idempotency.Data.IdempotencyKeys; + +using static TestData; + +public class BaseUnitTests +{ + protected static readonly CancellationToken ct = CancellationToken.None; + + protected static IdempotencyKey CreateIdempotencyKey( + IdempotencyKeyId? id = null, + string? hash = null + ) => IdempotencyKey.Create( + id: id ?? ValidId, + hash: hash ?? ValidRequestHash + ); +} diff --git a/tests/UnitTests/Idempotency/Data/IdempotencyKeysData.cs b/tests/UnitTests/Idempotency/Data/IdempotencyKeys/TestData.cs similarity index 89% rename from tests/UnitTests/Idempotency/Data/IdempotencyKeysData.cs rename to tests/UnitTests/Idempotency/Data/IdempotencyKeys/TestData.cs index 0a61c6f9b..dc4b94b75 100644 --- a/tests/UnitTests/Idempotency/Data/IdempotencyKeysData.cs +++ b/tests/UnitTests/Idempotency/Data/IdempotencyKeys/TestData.cs @@ -1,11 +1,11 @@ using CustomCADs.Modules.Idempotency.Domain.IdempotencyKeys; using CustomCADs.Shared.Domain.TypedIds.Idempotency; -namespace CustomCADs.UnitTests.Idempotency.Data; +namespace CustomCADs.UnitTests.Idempotency.Data.IdempotencyKeys; using static IdempotencyKeyConstants; -public static class IdempotencyKeysData +public static class TestData { public const string ValidRequestHash = "abcdefghijk"; public const string InvalidRequestHash = ""; diff --git a/tests/UnitTests/Idempotency/Domain/GlobalUsings.cs b/tests/UnitTests/Idempotency/Domain/GlobalUsings.cs index 8d317451a..accc2746d 100644 --- a/tests/UnitTests/Idempotency/Domain/GlobalUsings.cs +++ b/tests/UnitTests/Idempotency/Domain/GlobalUsings.cs @@ -1,3 +1,2 @@ global using CustomCADs.Modules.Idempotency.Domain.IdempotencyKeys; -global using CustomCADs.UnitTests.Idempotency.Data; global using Xunit; diff --git a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/BaseIdempotencyKeyUnitTests.cs b/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/BaseIdempotencyKeyUnitTests.cs deleted file mode 100644 index 7870948ff..000000000 --- a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/BaseIdempotencyKeyUnitTests.cs +++ /dev/null @@ -1,22 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Idempotency; - -namespace CustomCADs.UnitTests.Idempotency.Domain.IdempotencyKeys; - -using static IdempotencyKeysData; - -public class BaseIdempotencyKeyUnitTests -{ - protected static IdempotencyKey CreateIdempotencyKey( - IdempotencyKeyId id, - string hash - ) => IdempotencyKey.Create( - id: id, - hash: hash - ); - - protected static IdempotencyKey CreateIdempotencyKey() - => IdempotencyKey.Create( - id: ValidId, - hash: ValidRequestHash - ); -} diff --git a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetResponseBody/IdempotencyKeySetResponseBodyUnitTests.cs b/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetResponseBody/Tests.cs similarity index 86% rename from tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetResponseBody/IdempotencyKeySetResponseBodyUnitTests.cs rename to tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetResponseBody/Tests.cs index d7ed55445..33de84072 100644 --- a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetResponseBody/IdempotencyKeySetResponseBodyUnitTests.cs +++ b/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetResponseBody/Tests.cs @@ -1,9 +1,10 @@ +using CustomCADs.Shared.Domain.Exceptions; + namespace CustomCADs.UnitTests.Idempotency.Domain.IdempotencyKeys.Behaviors.SetResponseBody; -using CustomCADs.Shared.Domain.Exceptions; -using static IdempotencyKeysData; +using static Data.IdempotencyKeys.TestData; -public class IdempotencyKeySetResponseBodyUnitTests : BaseIdempotencyKeyUnitTests +public class Tests : Data.IdempotencyKeys.BaseUnitTests { [Fact] public void SetResponseBody_ShouldNotThrow() diff --git a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetStatusCode/IdempotencyKeySetStatusCodeUnitTests.cs b/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetStatusCode/Tests.cs similarity index 86% rename from tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetStatusCode/IdempotencyKeySetStatusCodeUnitTests.cs rename to tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetStatusCode/Tests.cs index 493821ece..eab307bfe 100644 --- a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetStatusCode/IdempotencyKeySetStatusCodeUnitTests.cs +++ b/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Behaviors/SetStatusCode/Tests.cs @@ -1,9 +1,10 @@ +using CustomCADs.Shared.Domain.Exceptions; + namespace CustomCADs.UnitTests.Idempotency.Domain.IdempotencyKeys.Behaviors.SetStatusCode; -using CustomCADs.Shared.Domain.Exceptions; -using static IdempotencyKeysData; +using static Data.IdempotencyKeys.TestData; -public class IdempotencyKeySetStatusCodeUnitTests : BaseIdempotencyKeyUnitTests +public class Tests : Data.IdempotencyKeys.BaseUnitTests { [Fact] public void SetStatusCode_ShouldNotThrow() diff --git a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/Data/IdempotencyKeyCreateInvalidData.cs b/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/InvalidData.cs similarity index 56% rename from tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/Data/IdempotencyKeyCreateInvalidData.cs rename to tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/InvalidData.cs index aa6502ca5..04667dda2 100644 --- a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/Data/IdempotencyKeyCreateInvalidData.cs +++ b/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/InvalidData.cs @@ -1,12 +1,12 @@ using CustomCADs.Shared.Domain.TypedIds.Idempotency; -namespace CustomCADs.UnitTests.Idempotency.Domain.IdempotencyKeys.Create.Data; +namespace CustomCADs.UnitTests.Idempotency.Domain.IdempotencyKeys.Create; -using static IdempotencyKeysData; +using static Data.IdempotencyKeys.TestData; -public class IdempotencyKeyCreateInvalidData : TheoryData +public class InvalidData : TheoryData { - public IdempotencyKeyCreateInvalidData() + public InvalidData() { // Id Add(InvalidId, ValidRequestHash); diff --git a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/IdempotencyKeyCreateUnitTests.cs b/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/Tests.cs similarity index 75% rename from tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/IdempotencyKeyCreateUnitTests.cs rename to tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/Tests.cs index e4e9944c0..08ac4af71 100644 --- a/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/IdempotencyKeyCreateUnitTests.cs +++ b/tests/UnitTests/Idempotency/Domain/IdempotencyKeys/Create/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Idempotency.Domain.IdempotencyKeys.Create; -using static IdempotencyKeysData; +using static Data.IdempotencyKeys.TestData; -public class IdempotencyKeyCreateUnitTests : BaseIdempotencyKeyUnitTests +public class Tests : Data.IdempotencyKeys.BaseUnitTests { [Fact] public void Create_ShouldNotThrow() @@ -16,10 +16,7 @@ public void Create_ShouldNotThrow() [Fact] public void Create_ShouldPopulateProperties() { - IdempotencyKey idempotencyKey = CreateIdempotencyKey( - id: ValidId, - hash: ValidRequestHash - ); + IdempotencyKey idempotencyKey = CreateIdempotencyKey(); TimeSpan timeSinceCreation = DateTimeOffset.UtcNow - idempotencyKey.CreatedAt; Assert.Multiple( @@ -30,7 +27,7 @@ public void Create_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.IdempotencyKeyCreateInvalidData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrow_WhenIdempotencyKeyInvalid(IdempotencyKeyId id, string requestHash) { Assert.Throws>( diff --git a/tests/UnitTests/Identity/Application/GlobalUsings.cs b/tests/UnitTests/Identity/Application/GlobalUsings.cs index 3056110c4..21b808307 100644 --- a/tests/UnitTests/Identity/Application/GlobalUsings.cs +++ b/tests/UnitTests/Identity/Application/GlobalUsings.cs @@ -1,5 +1,4 @@ global using CustomCADs.Modules.Identity.Domain.Users; global using CustomCADs.Shared.Domain.TypedIds.Identity; -global using CustomCADs.UnitTests.Identity.Data; global using Moq; global using Xunit; diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/ChangeUsernameHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs similarity index 92% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/ChangeUsernameHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs index 7be6ccee3..79c2d472a 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/ChangeUsernameHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.ChangeUsername; -using static UsersData; +using static Data.Users.TestData; -public class ChangeUsernameHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly ChangeUsernameHandler handler; private readonly Mock service = new(); @@ -15,7 +15,7 @@ public class ChangeUsernameHandlerUnitTests : UsersBaseUnitTests private readonly User user = CreateUser(); - public ChangeUsernameHandlerUnitTests() + public Tests() { handler = new(service.Object, raiser.Object); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/DeleteUserHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs similarity index 90% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/DeleteUserHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs index b9e554f5f..e360ecbc9 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/DeleteUserHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Delete; -using static UsersData; +using static Data.Users.TestData; -public class DeleteUserHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly DeleteUserHandler handler; private readonly Mock service = new(); @@ -15,7 +15,7 @@ public class DeleteUserHandlerUnitTests : UsersBaseUnitTests private readonly User user = CreateUser(username: MaxValidUsername); - public DeleteUserHandlerUnitTests() + public Tests() { handler = new(service.Object, raiser.Object); } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/LoginUserHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs similarity index 95% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/LoginUserHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs index 1f456ee8a..5adbc6c63 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/LoginUserHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Login; -using static UsersData; +using static Data.Users.TestData; -public class LoginUserHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly LoginUserHandler handler; private readonly Mock service = new(); @@ -23,7 +23,7 @@ public class LoginUserHandlerUnitTests : UsersBaseUnitTests CsrfToken: new("csrf-token", DateTimeOffset.UtcNow) ); - public LoginUserHandlerUnitTests() + public Tests() { handler = new(service.Object, tokenService.Object); @@ -139,7 +139,7 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenUserNotVerified() { // Arrange - User unverifiedUser = CreateUser(email: new(ValidEmail, IsVerified: false)); + User unverifiedUser = CreateUser(email: ValidEmail, isVerified: false); service.Setup(x => x.GetByUsernameAsync(unverifiedUser.Username)).ReturnsAsync(unverifiedUser); LoginUserCommand command = new( diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/LogoutUserHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs similarity index 91% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/LogoutUserHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs index a933fabea..41f1aeb29 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/LogoutUserHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs @@ -5,9 +5,9 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Logout; -using static UsersData; +using static Data.Users.TestData; -public class LogoutUserHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly LogoutUserHandler handler; private readonly Mock service = new(); @@ -15,7 +15,7 @@ public class LogoutUserHandlerUnitTests : UsersBaseUnitTests private static readonly RefreshToken token = RefreshToken.Create("refresh-token", ValidFingerprint, ValidId, longerSession: false); private readonly User user = CreateUser(username: MaxValidUsername); - public LogoutUserHandlerUnitTests() + public Tests() { handler = new(service.Object); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/RefreshUserHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs similarity index 96% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/RefreshUserHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs index 34baa527f..1342093a6 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/RefreshUserHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Refresh; -using static UsersData; +using static Data.Users.TestData; -public class RefreshUserHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly RefreshUserHandler handler; private readonly Mock service = new(); @@ -24,7 +24,7 @@ public class RefreshUserHandlerUnitTests : UsersBaseUnitTests CsrfToken: new("csrf-token", DateTimeOffset.UtcNow) ); - public RefreshUserHandlerUnitTests() + public Tests() { handler = new(service.Object, tokenService.Object); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/RegisterUserHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs similarity index 95% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/RegisterUserHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs index 39e098ac8..97608929c 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/RegisterUserHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Register; -using static UsersData; +using static Data.Users.TestData; -public class RegisterUserHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly RegisterUserHandler handler; private readonly Mock service = new(); private readonly Mock sender = new(); - public RegisterUserHandlerUnitTests() + public Tests() { handler = new(service.Object, sender.Object); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/ResetUserPasswordHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs similarity index 86% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/ResetUserPasswordHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs index 069eca1f1..8184f130c 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/ResetUserPasswordHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.ResetPassword; -using static UsersData; +using static Data.Users.TestData; -public class ResetUserPasswordHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly ResetUserPasswordHandler handler; private readonly Mock service = new(); @@ -13,7 +13,7 @@ public class ResetUserPasswordHandlerUnitTests : UsersBaseUnitTests private const string Token = "email-token"; private readonly User user = CreateUser(); - public ResetUserPasswordHandlerUnitTests() + public Tests() { handler = new(service.Object); } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/ResetUserPasswordEmailHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs similarity index 93% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/ResetUserPasswordEmailHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs index 809e24cae..fe87bb206 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/ResetUserPasswordEmailHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs @@ -7,7 +7,7 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.ResetPasswordEmail; -public class ResetUserPasswordEmailHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly ResetPasswordEmailHandler handler; private readonly Mock service = new(); @@ -18,7 +18,7 @@ public class ResetUserPasswordEmailHandlerUnitTests : UsersBaseUnitTests private const string PreferredUrl = "preferred-url"; private readonly User user = CreateUser(); - public ResetUserPasswordEmailHandlerUnitTests() + public Tests() { settings.Setup(x => x.Value).Returns(new ClientUrlSettings(string.Empty, PreferredUrl)); handler = new(service.Object, raiser.Object, settings.Object); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/SingleSignOnUserUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs similarity index 97% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/SingleSignOnUserUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs index b28e83d39..8dbd2909c 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/SingleSignOnUserUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.SSO; -using static UsersData; +using static Data.Users.TestData; -public class SingleSignOnUserUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly SingleSignOnUserHandler handler; private readonly Mock service = new(); @@ -26,7 +26,7 @@ public class SingleSignOnUserUnitTests : UsersBaseUnitTests CsrfToken: new("csrf-token", DateTimeOffset.UtcNow) ); - public SingleSignOnUserUnitTests() + public Tests() { handler = new(service.Object, tokenService.Object, sender.Object); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/ToggleViewedProductsTrackingHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs similarity index 91% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/ToggleViewedProductsTrackingHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs index 41ab7eb44..ba9efa2e5 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/ToggleViewedProductsTrackingHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.ToggleViewedProductsTracking; -using static UsersData; +using static Data.Users.TestData; -public class ToggleViewedProductsTrackingHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly ToggleViewedProductsTrackingHandler handler; private readonly Mock sender = new(); @@ -17,7 +17,7 @@ public class ToggleViewedProductsTrackingHandlerUnitTests : UsersBaseUnitTests private const bool InitialTrackViewedProducts = false; - public ToggleViewedProductsTrackingHandlerUnitTests() + public Tests() { handler = new(sender.Object, raiser.Object); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/VerificationEmailHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs similarity index 94% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/VerificationEmailHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs index dc21ef340..52bc85b6e 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/VerificationEmailHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs @@ -7,7 +7,7 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.VerificationEmail; -public class VerificationEmailHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly VerificationEmailHandler handler; private readonly Mock service = new(); @@ -17,7 +17,7 @@ public class VerificationEmailHandlerUnitTests : UsersBaseUnitTests private const string Token = "email-token"; private readonly User user = CreateUser(); - public VerificationEmailHandlerUnitTests() + public Tests() { settings.Setup(x => x.Value).Returns(new ClientUrlSettings()); handler = new(service.Object, raiser.Object, settings.Object); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/VerifyUserEmailHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs similarity index 90% rename from tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/VerifyUserEmailHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs index e562d6cc4..0e22e2860 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/VerifyUserEmailHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs @@ -6,16 +6,16 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.VerifyEmail; -using static UsersData; +using static Data.Users.TestData; -public class VerifyUserEmailHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly VerifyUserEmailHandler handler; private readonly Mock service = new(); private readonly Mock tokenService = new(); private const string Token = "email-token"; - private readonly User User = CreateUser(email: new(ValidEmail, IsVerified: false)); + private readonly User User = CreateUser(email: ValidEmail, isVerified: false); private static readonly RefreshToken RefreshToken = RefreshToken.Create(Token, ValidFingerprint, ValidId, false); private static readonly TokensDto Tokens = new( Role: "role", @@ -24,7 +24,7 @@ public class VerifyUserEmailHandlerUnitTests : UsersBaseUnitTests CsrfToken: new("csrf-token", DateTimeOffset.UtcNow) ); - public VerifyUserEmailHandlerUnitTests() + public Tests() { handler = new(service.Object, tokenService.Object); @@ -83,7 +83,7 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenEmailVerified() { // Arrange - User verifiedUser = CreateUser(email: new(ValidEmail, IsVerified: true)); + User verifiedUser = CreateUser(email: ValidEmail, isVerified: true); service.Setup(x => x.GetByUsernameAsync(verifiedUser.Username)).ReturnsAsync(verifiedUser); VerifyUserEmailCommand command = new(verifiedUser.Username, Token, ValidFingerprint); diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerificationRequestedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs similarity index 83% rename from tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerificationRequestedHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs index 3b83e8407..1cc3a77bd 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerificationRequestedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs @@ -1,9 +1,9 @@ using CustomCADs.Modules.Identity.Application.Users.Events.Application.Emails.EmailVerification; using CustomCADs.Shared.Application.Abstractions.Email; -namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Emails; +namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Emails.EmailVerification; -public class EmailVerificationRequestedHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly EmailVerificationRequestedEventHandler handler; private readonly Mock email = new(); @@ -11,7 +11,7 @@ public class EmailVerificationRequestedHandlerUnitTests : UsersBaseUnitTests private const string Email = "recipient@gmail.com"; private const string Endpoint = "www.site.com"; - public EmailVerificationRequestedHandlerUnitTests() + public Tests() { handler = new(email.Object); } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordResetRequestedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs similarity index 84% rename from tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordResetRequestedHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs index 97c480bc8..cc4e28d67 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordResetRequestedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs @@ -1,9 +1,9 @@ using CustomCADs.Modules.Identity.Application.Users.Events.Application.Emails.PasswordReset; using CustomCADs.Shared.Application.Abstractions.Email; -namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Emails; +namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Emails.PasswordReset; -public class PasswordResetRequestedHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly PasswordResetRequestedEventHandler handler; private readonly Mock email = new(); @@ -11,7 +11,7 @@ public class PasswordResetRequestedHandlerUnitTests : UsersBaseUnitTests private const string Email = "recipient@gmail.com"; private const string Endpoint = "www.site.com"; - public PasswordResetRequestedHandlerUnitTests() + public Tests() { handler = new(email.Object); } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs similarity index 82% rename from tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs index 2da252e3a..a415acd1c 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleCreatedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs @@ -2,16 +2,16 @@ using CustomCADs.Modules.Identity.Application.Users.Events.Application.Roles; using CustomCADs.Shared.Application.Events.Account.Roles; -namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Roles; +namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Roles.Created; -using static UsersData; +using static Data.Users.TestData; -public class RoleCreatedHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly RoleCreatedHandler handler; private readonly Mock service = new(); - public RoleCreatedHandlerUnitTests() + public Tests() { handler = new(service.Object); } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs similarity index 82% rename from tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs index aafdd0127..8626ce9e6 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/RoleDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs @@ -2,16 +2,16 @@ using CustomCADs.Modules.Identity.Application.Users.Events.Application.Roles; using CustomCADs.Shared.Application.Events.Account.Roles; -namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Roles; +namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Roles.Deleted; -using static UsersData; +using static Data.Users.TestData; -public class RoleDeletedHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly RoleDeletedHandler handler; private readonly Mock service = new(); - public RoleDeletedHandlerUnitTests() + public Tests() { handler = new(service.Object); } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountCreatedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs similarity index 87% rename from tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountCreatedHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs index ccf86ae5e..87f72eb41 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountCreatedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs @@ -2,18 +2,18 @@ using CustomCADs.Modules.Identity.Application.Users.Events.Application.Users; using CustomCADs.Shared.Application.Events.Account.Accounts; -namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Users; +namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Users.Created; -using static UsersData; +using static Data.Users.TestData; -public class AccountCreatedHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly AccountCreatedHandler handler; private readonly Mock service = new(); private readonly User user = CreateUser(); - public AccountCreatedHandlerUnitTests() + public Tests() { handler = new(service.Object); } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountDeletedHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs similarity index 81% rename from tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountDeletedHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs index 960cc2903..bb578104a 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/AccountDeletedHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs @@ -2,16 +2,16 @@ using CustomCADs.Modules.Identity.Application.Users.Events.Application.Users; using CustomCADs.Shared.Application.Events.Account.Accounts; -namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Users; +namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Users.Deleted; -using static UsersData; +using static Data.Users.TestData; -public class AccountDeletedHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly AccountDeletedHandler handler; private readonly Mock service = new(); - public AccountDeletedHandlerUnitTests() + public Tests() { handler = new(service.Object); } diff --git a/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/GetUserByUsernameHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs similarity index 91% rename from tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/GetUserByUsernameHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs index b5e5a0288..8556422f4 100644 --- a/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/GetUserByUsernameHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs @@ -5,16 +5,16 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Queries.Internal.GetByUsername; -using static UsersData; +using static Data.Users.TestData; -public class GetUserByUsernameHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly GetUserByUsernameHandler handler; private readonly Mock service = new(); private readonly Mock sender = new(); - private readonly User user = CreateUserWithId(); + private readonly User user = CreateUser(); - public GetUserByUsernameHandlerUnitTests() + public Tests() { user.AddRefreshToken("refresh-token", ValidFingerprint, false); diff --git a/tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/GetUserByUsernameHandlerUnitTests.cs b/tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/Tests.cs similarity index 90% rename from tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/GetUserByUsernameHandlerUnitTests.cs rename to tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/Tests.cs index 73d579a5b..178eed329 100644 --- a/tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/GetUserByUsernameHandlerUnitTests.cs +++ b/tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/Tests.cs @@ -5,7 +5,7 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Queries.Shared.ClientUrl; -public class GetClientUrlHandlerUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private readonly GetClientUrlHandler handler; private readonly Mock> settings = new(); @@ -13,7 +13,7 @@ public class GetClientUrlHandlerUnitTests : UsersBaseUnitTests private const string All = "preferred-url.com,www.preferred-url.com,app.preferred-url.com"; private const string Preferred = "www.preferred-url.com"; - public GetClientUrlHandlerUnitTests() + public Tests() { handler = new(settings.Object); diff --git a/tests/UnitTests/Identity/Application/Users/UsersBaseUnitTests.cs b/tests/UnitTests/Identity/Application/Users/UsersBaseUnitTests.cs deleted file mode 100644 index 48c57fcf6..000000000 --- a/tests/UnitTests/Identity/Application/Users/UsersBaseUnitTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -using CustomCADs.Modules.Identity.Domain.Users.Entities; -using CustomCADs.Modules.Identity.Domain.Users.ValueObjects; -using CustomCADs.Shared.Domain.TypedIds.Accounts; - -namespace CustomCADs.UnitTests.Identity.Application.Users; - -using static UsersData; - -public class UsersBaseUnitTests -{ - protected private readonly CancellationToken ct = default; - - protected static User CreateUser( - string? role = null, - string? username = null, - Email? email = null, - AccountId? accountId = null - ) => User.Create( - role ?? ValidRole, - username ?? MinValidUsername, - email ?? new(ValidEmail, true), - accountId ?? ValidAccountId - ); - - protected static User CreateUserWithId( - UserId? id = null, - string? role = null, - string? username = null, - Email? email = null, - AccountId? accountId = null, - RefreshToken[]? refreshTokens = null - ) => User.Create( - id ?? ValidId, - role ?? ValidRole, - username ?? MinValidUsername, - email ?? new(ValidEmail, true), - accountId ?? ValidAccountId, - refreshTokens: refreshTokens ?? [] - ); -} diff --git a/tests/UnitTests/Identity/Data/Users/BaseUnitTests.cs b/tests/UnitTests/Identity/Data/Users/BaseUnitTests.cs new file mode 100644 index 000000000..848ce3151 --- /dev/null +++ b/tests/UnitTests/Identity/Data/Users/BaseUnitTests.cs @@ -0,0 +1,30 @@ +using CustomCADs.Modules.Identity.Domain.Users; +using CustomCADs.Modules.Identity.Domain.Users.Entities; +using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Identity; + +namespace CustomCADs.UnitTests.Identity.Data.Users; + +using static TestData; + +public class BaseUnitTests +{ + protected readonly CancellationToken ct = default; + + protected static User CreateUser( + string? role = null, + string? username = null, + string? email = null, + AccountId? accountId = null, + bool? isVerified = null, + UserId? id = null, + RefreshToken[]? refreshTokens = null + ) => User.Create( + id ?? ValidId, + role ?? ValidRole, + username ?? MinValidUsername, + new(email ?? ValidEmail, isVerified ?? true), + accountId ?? ValidAccountId, + refreshTokens ?? [] + ); +} diff --git a/tests/UnitTests/Identity/Data/UsersData.cs b/tests/UnitTests/Identity/Data/Users/TestData.cs similarity index 94% rename from tests/UnitTests/Identity/Data/UsersData.cs rename to tests/UnitTests/Identity/Data/Users/TestData.cs index 000e8ca91..e5d3cfd88 100644 --- a/tests/UnitTests/Identity/Data/UsersData.cs +++ b/tests/UnitTests/Identity/Data/Users/TestData.cs @@ -4,12 +4,12 @@ using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Identity; -namespace CustomCADs.UnitTests.Identity.Data; +namespace CustomCADs.UnitTests.Identity.Data.Users; using static DomainConstants; using static UserConstants; -public static class UsersData +public static class TestData { public const string ValidRole = Users.CustomerRole; public static readonly string InvalidRole = string.Empty; diff --git a/tests/UnitTests/Identity/Domain/GlobalUsings.cs b/tests/UnitTests/Identity/Domain/GlobalUsings.cs index 5dab6c407..9bc015c2b 100644 --- a/tests/UnitTests/Identity/Domain/GlobalUsings.cs +++ b/tests/UnitTests/Identity/Domain/GlobalUsings.cs @@ -1,4 +1,2 @@ global using CustomCADs.Modules.Identity.Domain.Users; -global using CustomCADs.Shared.Domain.TypedIds.Identity; -global using CustomCADs.UnitTests.Identity.Data; global using Xunit; diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/UserAddRefreshTokenUnitTests.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/Tests.cs similarity index 95% rename from tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/UserAddRefreshTokenUnitTests.cs rename to tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/Tests.cs index 1dff27f7a..2fc13476c 100644 --- a/tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/UserAddRefreshTokenUnitTests.cs +++ b/tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.AddRefreshToken; -public class UserAddRefreshTokenUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private const string Value = "refresh-token"; private static readonly User user = CreateUser(); diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/UserRemoveRefreshTokenUnitTests.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/Tests.cs similarity index 88% rename from tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/UserRemoveRefreshTokenUnitTests.cs rename to tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/Tests.cs index 62c8bfbe1..119f38254 100644 --- a/tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/UserRemoveRefreshTokenUnitTests.cs +++ b/tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/Tests.cs @@ -2,12 +2,12 @@ namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.RemoveRefreshToken; -public class UserRemoveRefreshTokenUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { private static readonly User user = CreateUser(); private readonly RefreshToken rt; - public UserRemoveRefreshTokenUnitTests() + public Tests() { rt = user.AddRefreshToken("refresh-token", new(), longerSession: false); } diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Data/UserUsernameInvalidData.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Data/UserUsernameInvalidData.cs deleted file mode 100644 index 038e8c2fa..000000000 --- a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Data/UserUsernameInvalidData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.SetUsername.Data; - -using static UsersData; - -public class UserUsernameInvalidData : UserUsernameData -{ - public UserUsernameInvalidData() - { - Add(InvalidUsername); - Add(MinInvalidUsername); - Add(MaxInvalidUsername); - } -} diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Data/UserUsernameValidData.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Data/UserUsernameValidData.cs deleted file mode 100644 index 8c1a687ff..000000000 --- a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Data/UserUsernameValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.SetUsername.Data; - -using static UsersData; - -public class UserUsernameValidData : UserUsernameData -{ - public UserUsernameValidData() - { - Add(MinValidUsername); - Add(MaxValidUsername); - } -} diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/InvalidData.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/InvalidData.cs new file mode 100644 index 000000000..0823d354f --- /dev/null +++ b/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/InvalidData.cs @@ -0,0 +1,13 @@ +namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.SetUsername; + +using static Data.Users.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(InvalidUsername); + Add(MinInvalidUsername); + Add(MaxInvalidUsername); + } +} diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/UserUsernameUnitTests.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Tests.cs similarity index 67% rename from tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/UserUsernameUnitTests.cs rename to tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Tests.cs index 792ceaf1b..7fe9bdc5e 100644 --- a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/UserUsernameUnitTests.cs +++ b/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/Tests.cs @@ -1,12 +1,12 @@ -namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.SetUsername; - + using CustomCADs.Shared.Domain.Exceptions; -using Data; -public class UserUsernameUnitTests : UsersBaseUnitTests +namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.SetUsername; + +public class Tests : Data.Users.BaseUnitTests { [Theory] - [ClassData(typeof(UserUsernameValidData))] + [ClassData(typeof(ValidData))] public void SetUsername_ShouldNotThrowException(string username) { var user = CreateUser(); @@ -15,7 +15,7 @@ public void SetUsername_ShouldNotThrowException(string username) } [Theory] - [ClassData(typeof(UserUsernameValidData))] + [ClassData(typeof(ValidData))] public void SetUsername_PopulatesProperty(string username) { var user = CreateUser(); @@ -26,7 +26,7 @@ public void SetUsername_PopulatesProperty(string username) } [Theory] - [ClassData(typeof(UserUsernameInvalidData))] + [ClassData(typeof(InvalidData))] public void SetUsername_ThrowsException_WhenUsernameIsInvalid(string username) { var user = CreateUser(); diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/UserUsernameData.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/UserUsernameData.cs deleted file mode 100644 index fc0556b09..000000000 --- a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/UserUsernameData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.SetUsername; - -public class UserUsernameData : TheoryData; diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/ValidData.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/ValidData.cs new file mode 100644 index 000000000..48c131574 --- /dev/null +++ b/tests/UnitTests/Identity/Domain/Users/Behaviors/SetUsername/ValidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.SetUsername; + +using static Data.Users.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(MinValidUsername); + Add(MaxValidUsername); + } +} diff --git a/tests/UnitTests/Identity/Domain/Users/Create/Data/UserCreateInvalidData.cs b/tests/UnitTests/Identity/Domain/Users/Create/InvalidData.cs similarity index 60% rename from tests/UnitTests/Identity/Domain/Users/Create/Data/UserCreateInvalidData.cs rename to tests/UnitTests/Identity/Domain/Users/Create/InvalidData.cs index cdc838fef..a69afca15 100644 --- a/tests/UnitTests/Identity/Domain/Users/Create/Data/UserCreateInvalidData.cs +++ b/tests/UnitTests/Identity/Domain/Users/Create/InvalidData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Identity.Domain.Users.Create.Data; +namespace CustomCADs.UnitTests.Identity.Domain.Users.Create; -using static UsersData; +using static Data.Users.TestData; -public class UserCreateInvalidData : TheoryData +public class InvalidData : TheoryData { - public UserCreateInvalidData() + public InvalidData() { // Role Add(InvalidRole, MaxValidUsername, ValidEmail); diff --git a/tests/UnitTests/Identity/Domain/Users/Create/Normal/Tests.cs b/tests/UnitTests/Identity/Domain/Users/Create/Normal/Tests.cs new file mode 100644 index 000000000..38a369b93 --- /dev/null +++ b/tests/UnitTests/Identity/Domain/Users/Create/Normal/Tests.cs @@ -0,0 +1,39 @@ +using CustomCADs.Modules.Identity.Domain.Users.ValueObjects; +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Identity.Domain.Users.Create.Normal; + +using static Data.Users.TestData; + +public class Tests : Data.Users.BaseUnitTests +{ + private static readonly Email Email = new(ValidEmail, true); + + [Fact] + public void Create_ShouldNotThrowException() + { + User.Create(ValidRole, MaxValidUsername, Email, ValidAccountId); + } + + [Fact] + public void Create_ShouldPopulateProperties() + { + User user = User.Create(ValidRole, MaxValidUsername, Email, ValidAccountId); + + Assert.Multiple( + () => Assert.Equal(ValidRole, user.Role), + () => Assert.Equal(MaxValidUsername, user.Username), + () => Assert.Equal(Email, user.Email), + () => Assert.Equal(ValidAccountId, user.AccountId) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenUserInvalid(string role, string username, string email) + { + Assert.Throws>( + () => User.Create(role, username, Email with { Value = email }, ValidAccountId) + ); + } +} diff --git a/tests/UnitTests/Identity/Domain/Users/Create/Normal/UserCreateUnitTests.cs b/tests/UnitTests/Identity/Domain/Users/Create/WithId/Tests.cs similarity index 65% rename from tests/UnitTests/Identity/Domain/Users/Create/Normal/UserCreateUnitTests.cs rename to tests/UnitTests/Identity/Domain/Users/Create/WithId/Tests.cs index 642c5504b..50292b7e9 100644 --- a/tests/UnitTests/Identity/Domain/Users/Create/Normal/UserCreateUnitTests.cs +++ b/tests/UnitTests/Identity/Domain/Users/Create/WithId/Tests.cs @@ -1,21 +1,21 @@ using CustomCADs.Shared.Domain.Exceptions; -namespace CustomCADs.UnitTests.Identity.Domain.Users.Create.Normal; +namespace CustomCADs.UnitTests.Identity.Domain.Users.Create.WithId; -using static UsersData; +using static Data.Users.TestData; -public class UserCreateUnitTests : UsersBaseUnitTests +public class Tests : Data.Users.BaseUnitTests { [Fact] public void Create_ShouldNotThrowException() { - CreateUser(ValidRole, MaxValidUsername, ValidEmail, ValidAccountId); + CreateUser(); } [Fact] public void Create_ShouldPopulateProperties() { - User user = CreateUser(ValidRole, MaxValidUsername, ValidEmail, ValidAccountId); + User user = CreateUser(ValidRole, MaxValidUsername, ValidEmail, ValidAccountId, id: ValidId); Assert.Multiple( () => Assert.Equal(ValidRole, user.Role), @@ -26,11 +26,11 @@ public void Create_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.UserCreateInvalidData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenUserInvalid(string role, string username, string email) { Assert.Throws>( - () => CreateUser(role, username, email, ValidAccountId) + () => CreateUser(role, username, email, ValidAccountId, id: ValidId) ); } } diff --git a/tests/UnitTests/Identity/Domain/Users/Create/WithId/UserCreateWithIdUnitTests.cs b/tests/UnitTests/Identity/Domain/Users/Create/WithId/UserCreateWithIdUnitTests.cs deleted file mode 100644 index 2e0c1934d..000000000 --- a/tests/UnitTests/Identity/Domain/Users/Create/WithId/UserCreateWithIdUnitTests.cs +++ /dev/null @@ -1,36 +0,0 @@ -using CustomCADs.Shared.Domain.Exceptions; - -namespace CustomCADs.UnitTests.Identity.Domain.Users.Create.WithId; - -using static UsersData; - -public class UserCreateWithIdUnitTests : UsersBaseUnitTests -{ - [Fact] - public void CreateWithId_ShouldNotThrowException() - { - CreateUserWithId(ValidId, ValidRole, MaxValidUsername, ValidEmail, ValidAccountId); - } - - [Fact] - public void CreateWithId_ShouldPopulateProperties() - { - User user = CreateUserWithId(ValidId, ValidRole, MaxValidUsername, ValidEmail, ValidAccountId); - - Assert.Multiple( - () => Assert.Equal(ValidRole, user.Role), - () => Assert.Equal(MaxValidUsername, user.Username), - () => Assert.Equal(ValidEmail, user.Email.Value), - () => Assert.Equal(ValidAccountId, user.AccountId) - ); - } - - [Theory] - [ClassData(typeof(Data.UserCreateInvalidData))] - public void CreateWithId_ShouldThrowException_WhenUserInvalid(string role, string username, string email) - { - Assert.Throws>( - () => CreateUserWithId(ValidId, role, username, email, ValidAccountId) - ); - } -} diff --git a/tests/UnitTests/Identity/Domain/Users/UsersBaseUnitTests.cs b/tests/UnitTests/Identity/Domain/Users/UsersBaseUnitTests.cs deleted file mode 100644 index 985ce6ddb..000000000 --- a/tests/UnitTests/Identity/Domain/Users/UsersBaseUnitTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CustomCADs.Modules.Identity.Domain.Users.Entities; -using CustomCADs.Shared.Domain.TypedIds.Accounts; - -namespace CustomCADs.UnitTests.Identity.Domain.Users; - -using static UsersData; - -public class UsersBaseUnitTests -{ - public static User CreateUser( - string? role = null, - string? username = null, - string? email = null, - AccountId? accountId = null - ) => User.Create( - role ?? ValidRole, - username ?? MinValidUsername, - new(email ?? ValidEmail, false), - accountId ?? ValidAccountId - ); - - public static User CreateUserWithId( - UserId? id = null, - string? role = null, - string? username = null, - string? email = null, - AccountId? accountId = null, - RefreshToken[]? refreshTokens = null - ) => User.Create( - id ?? ValidId, - role ?? ValidRole, - username ?? MinValidUsername, - new(email ?? ValidEmail, false), - accountId ?? ValidAccountId, - refreshTokens: refreshTokens ?? [] - ); -} diff --git a/tests/UnitTests/Notifications/Application/GlobalUsings.cs b/tests/UnitTests/Notifications/Application/GlobalUsings.cs index 21b46d307..281088828 100644 --- a/tests/UnitTests/Notifications/Application/GlobalUsings.cs +++ b/tests/UnitTests/Notifications/Application/GlobalUsings.cs @@ -1,5 +1,3 @@ global using CustomCADs.Modules.Notifications.Domain.Notifications; -global using CustomCADs.Shared.Domain.TypedIds.Notifications; -global using CustomCADs.UnitTests.Notifications.Data; global using Moq; global using Xunit; diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open copy/HideNotificationsHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs similarity index 93% rename from tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open copy/HideNotificationsHandlerUnitTests.cs rename to tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs index 42e613a11..ee61610ea 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open copy/HideNotificationsHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Commands.Internal.Hide; -using static NotificationsData; +using static Data.Notifications.TestData; -public class HideNotificationsHandlerUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private readonly HideNotificationHandler handler; private readonly Mock reads = new(); private readonly Mock uow = new(); - public HideNotificationsHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/OpenNotificationsHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs similarity index 93% rename from tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/OpenNotificationsHandlerUnitTests.cs rename to tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs index 9944b21a7..2d8aefed2 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/OpenNotificationsHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Commands.Internal.Open; -using static NotificationsData; +using static Data.Notifications.TestData; -public class OpenNotificationsHandlerUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private readonly OpenNotificationHandler handler; private readonly Mock reads = new(); private readonly Mock uow = new(); - public OpenNotificationsHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/ReadNotificationsHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs similarity index 93% rename from tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/ReadNotificationsHandlerUnitTests.cs rename to tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs index 9cfe3e488..dfacd6ba4 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/ReadNotificationsHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Commands.Internal.Read; -using static NotificationsData; +using static Data.Notifications.TestData; -public class ReadNotificationsHandlerUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private readonly ReadNotificationHandler handler; private readonly Mock reads = new(); private readonly Mock uow = new(); - public ReadNotificationsHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequestedHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/NotificationRequestedHandlerUnitTests.cs similarity index 95% rename from tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequestedHandlerUnitTests.cs rename to tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/NotificationRequestedHandlerUnitTests.cs index ad092ba62..ede39fef0 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequestedHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/NotificationRequestedHandlerUnitTests.cs @@ -7,11 +7,11 @@ using CustomCADs.Shared.Application.Events.Notifications; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Events; +namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Events.NotificationRequested; -using static NotificationsData; +using static Data.Notifications.TestData; -public class NotificationRequestedHandlerUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private readonly NotificationRequestedHandler handler; private readonly Mock> writes = new(); @@ -19,7 +19,7 @@ public class NotificationRequestedHandlerUnitTests : NotificationsBaseUnitTests private readonly Mock sender = new(); private readonly Mock notifier = new(); - public NotificationRequestedHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, sender.Object, notifier.Object); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/CountNotificationsHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs similarity index 91% rename from tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/CountNotificationsHandlerUnitTests.cs rename to tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs index 8a461e506..a1b9a57e6 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/CountNotificationsHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs @@ -4,9 +4,9 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Queries.Internal.Count; -using static NotificationsData; +using static Data.Notifications.TestData; -public class CountNotificationsHandlerUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private readonly CountNotificationsHandler handler; private readonly Mock reads = new(); @@ -19,7 +19,7 @@ public class CountNotificationsHandlerUnitTests : NotificationsBaseUnitTests [NotificationStatus.Hidden] = 4, }; - public CountNotificationsHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs similarity index 90% rename from tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationHandlerUnitTests.cs rename to tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs index a5aa05dd2..59d019402 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/GetAllNotificationHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs @@ -7,22 +7,22 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Queries.Internal.GetAll; -using static NotificationsData; +using static Data.Notifications.TestData; -public class GetAllNotificationHandlerUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private readonly GetAllNotificationsHandler handler; private readonly Mock reads = new(); private readonly Mock sender = new(); private readonly Notification[] notifications = [ - CreateNotification(ValidId, authorId: AccountId.New()), - CreateNotification(ValidId, authorId: AccountId.New()) + CreateNotification(id: ValidId, authorId: AccountId.New()), + CreateNotification(id: ValidId, authorId: AccountId.New()) ]; private readonly NotificationQuery query; private readonly Result result; - public GetAllNotificationHandlerUnitTests() + public Tests() { handler = new(reads.Object, sender.Object); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/GetNotificationSortingsHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/Tests.cs similarity index 88% rename from tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/GetNotificationSortingsHandlerUnitTests.cs rename to tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/Tests.cs index 8ad33152a..d23961047 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/GetNotificationSortingsHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Queries.Internal.GetSortings; -public class GetNotificationSortingsHandlerUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private readonly GetNotificationSortingsHandler handler = new(); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/GetNotificationStatusesHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/Tests.cs similarity index 88% rename from tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/GetNotificationStatusesHandlerUnitTests.cs rename to tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/Tests.cs index 6e0e5da3b..3b38f97c2 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/GetNotificationStatusesHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/Tests.cs @@ -3,7 +3,7 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Queries.Internal.GetStatuses; -public class GetNotificationStatusesHandlerUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private readonly GetNotificationStatusesHandler handler = new(); diff --git a/tests/UnitTests/Notifications/Application/Notifications/NotificationsBaseUnitTests.cs b/tests/UnitTests/Notifications/Data/Notifications/BaseUnitTests.cs similarity index 63% rename from tests/UnitTests/Notifications/Application/Notifications/NotificationsBaseUnitTests.cs rename to tests/UnitTests/Notifications/Data/Notifications/BaseUnitTests.cs index 749b76314..617a685f0 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/NotificationsBaseUnitTests.cs +++ b/tests/UnitTests/Notifications/Data/Notifications/BaseUnitTests.cs @@ -1,19 +1,22 @@ -namespace CustomCADs.UnitTests.Notifications.Application.Notifications; - +using CustomCADs.Modules.Notifications.Domain.Notifications; using CustomCADs.Shared.Domain.TypedIds.Accounts; -using static NotificationsData; +using CustomCADs.Shared.Domain.TypedIds.Notifications; + +namespace CustomCADs.UnitTests.Notifications.Data.Notifications; + +using static TestData; -public class NotificationsBaseUnitTests +public class BaseUnitTests { public static readonly CancellationToken ct = CancellationToken.None; public static Notification CreateNotification( - NotificationId? id = null, string? type = null, string? description = null, string? link = null, AccountId? authorId = null, - AccountId? receiverId = null + AccountId? receiverId = null, + NotificationId? id = null ) => Notification.Create( id: id ?? ValidId, type: type ?? MaxValidType, diff --git a/tests/UnitTests/Notifications/Data/NotificationsData.cs b/tests/UnitTests/Notifications/Data/Notifications/TestData.cs similarity index 93% rename from tests/UnitTests/Notifications/Data/NotificationsData.cs rename to tests/UnitTests/Notifications/Data/Notifications/TestData.cs index febda1e88..03275c50c 100644 --- a/tests/UnitTests/Notifications/Data/NotificationsData.cs +++ b/tests/UnitTests/Notifications/Data/Notifications/TestData.cs @@ -2,11 +2,11 @@ using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Notifications; -namespace CustomCADs.UnitTests.Notifications.Data; +namespace CustomCADs.UnitTests.Notifications.Data.Notifications; using static NotificationsConstants; -public static class NotificationsData +public static class TestData { public static readonly string MaxValidType = new('a', TypeMaxLength - 1); public static readonly string MinValidType = new('a', TypeMinLength + 1); diff --git a/tests/UnitTests/Notifications/Domain/GlobalUsings.cs b/tests/UnitTests/Notifications/Domain/GlobalUsings.cs index 520114326..e56c2898a 100644 --- a/tests/UnitTests/Notifications/Domain/GlobalUsings.cs +++ b/tests/UnitTests/Notifications/Domain/GlobalUsings.cs @@ -1,4 +1,3 @@ global using CustomCADs.Modules.Notifications.Domain.Notifications; global using CustomCADs.Shared.Domain.Exceptions; -global using CustomCADs.UnitTests.Notifications.Data; global using Xunit; diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Data/NotificationSetDescriptionInvalidData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Data/NotificationSetDescriptionInvalidData.cs deleted file mode 100644 index b07b41017..000000000 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Data/NotificationSetDescriptionInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.SetDescription.Data; - -using static NotificationsData; - -public class NotificationSetDescriptionInvalidData : NotificationSetDescriptionData -{ - public NotificationSetDescriptionInvalidData() - { - Add(MinInvalidDescription); - Add(MaxInvalidDescription); - } -} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Data/NotificationSetDescriptionValidData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Data/NotificationSetDescriptionValidData.cs deleted file mode 100644 index 2c6507f9f..000000000 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Data/NotificationSetDescriptionValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.SetDescription.Data; - -using static NotificationsData; - -public class NotificationSetDescriptionValidData : NotificationSetDescriptionData -{ - public NotificationSetDescriptionValidData() - { - Add(MinValidDescription); - Add(MaxValidDescription); - } -} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/InvalidTestData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/InvalidTestData.cs new file mode 100644 index 000000000..0b1f5b581 --- /dev/null +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/InvalidTestData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.SetDescription; + +using static Data.Notifications.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + Add(MinInvalidDescription); + Add(MaxInvalidDescription); + } +} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/NotificationSetDescriptionData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/NotificationSetDescriptionData.cs deleted file mode 100644 index b8fd13ed1..000000000 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/NotificationSetDescriptionData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.SetDescription; - -public class NotificationSetDescriptionData : TheoryData; diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/NotificationSetDescriptionUnitTests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Tests.cs similarity index 74% rename from tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/NotificationSetDescriptionUnitTests.cs rename to tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Tests.cs index c7e925613..af42d245d 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/NotificationSetDescriptionUnitTests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/Tests.cs @@ -1,12 +1,11 @@ namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.SetDescription; -using Data; -using static NotificationsData; +using static Data.Notifications.TestData; -public class NotificationSetDescriptionUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { [Theory] - [ClassData(typeof(NotificationSetDescriptionValidData))] + [ClassData(typeof(ValidTestData))] public void SetDescription_ShouldNotThrowException_WhenCustomValid(string description) { var notification = CreateNotification(); @@ -14,7 +13,7 @@ public void SetDescription_ShouldNotThrowException_WhenCustomValid(string descri } [Theory] - [ClassData(typeof(NotificationSetDescriptionValidData))] + [ClassData(typeof(ValidTestData))] public void SetDescription_ShouldPopulateProperties(string description) { var notification = CreateNotification(); @@ -23,7 +22,7 @@ public void SetDescription_ShouldPopulateProperties(string description) } [Theory] - [ClassData(typeof(NotificationSetDescriptionInvalidData))] + [ClassData(typeof(InvalidData))] public void SetDescription_ShouldThrowException_WhenDescriptionInvalid(string description) { Assert.Throws>( diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/ValidTestData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/ValidTestData.cs new file mode 100644 index 000000000..b61a7777f --- /dev/null +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/SetDescription/ValidTestData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.SetDescription; + +using static Data.Notifications.TestData; + +public class ValidTestData : TheoryData +{ + public ValidTestData() + { + Add(MinValidDescription); + Add(MaxValidDescription); + } +} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationHideUnitTests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Hide/Tests.cs similarity index 83% rename from tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationHideUnitTests.cs rename to tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Hide/Tests.cs index 5041f3182..b3ca8f1bc 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationHideUnitTests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Hide/Tests.cs @@ -1,8 +1,8 @@ using CustomCADs.Modules.Notifications.Domain.Notifications.Enums; -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Statuses.Hide; -public class NotificationHideUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private static readonly Func> expectValidationException = Assert.Throws>; @@ -43,13 +43,13 @@ public void Hide_ShouldSucceed_WhenOpened() [Fact] public void Hide_ShouldFail_WhenHidden() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Read(); notification.Hide(); notification.Hide(); - }); + })); } } diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationOpenUnitTests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Open/Tests.cs similarity index 64% rename from tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationOpenUnitTests.cs rename to tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Open/Tests.cs index 4acfe9805..2201ce474 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationOpenUnitTests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Open/Tests.cs @@ -1,8 +1,8 @@ using CustomCADs.Modules.Notifications.Domain.Notifications.Enums; -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Statuses.Open; -public class NotificationOpenUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private static readonly Func> expectValidationException = Assert.Throws>; @@ -21,37 +21,37 @@ public void Open_ShouldSucceed_WhenRead() [Fact] public void Open_ShouldFail_WhenUnread() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Open(); - }); + })); } [Fact] public void Open_ShouldFail_WhenOpened() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Read(); notification.Open(); notification.Open(); - }); + })); } [Fact] public void Open_ShouldFail_WhenHidden() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Read(); notification.Hide(); notification.Open(); - }); + })); } } diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationReadUnitTests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Read/Tests.cs similarity index 64% rename from tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationReadUnitTests.cs rename to tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Read/Tests.cs index 63a255fbb..f1b197e02 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationReadUnitTests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Read/Tests.cs @@ -1,8 +1,8 @@ using CustomCADs.Modules.Notifications.Domain.Notifications.Enums; -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Statuses.Read; -public class NotificationReadUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private static readonly Func> expectValidationException = Assert.Throws>; @@ -18,38 +18,38 @@ public void Read_ShouldSucceed_WhenUnread() [Fact] public void Read_ShouldFail_WhenRead() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Read(); notification.Read(); - }); + })); } [Fact] public void Read_ShouldFail_WhenOpened() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Read(); notification.Open(); notification.Read(); - }); + })); } [Fact] public void Read_ShouldFail_WhenHidden() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Read(); notification.Hide(); notification.Read(); - }); + })); } } diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationUnhideUnitTests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Unhide/Tests.cs similarity index 64% rename from tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationUnhideUnitTests.cs rename to tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Unhide/Tests.cs index d0d1ecbcd..06ebeddc4 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/NotificationUnhideUnitTests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Unhide/Tests.cs @@ -1,8 +1,8 @@ using CustomCADs.Modules.Notifications.Domain.Notifications.Enums; -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Statuses; +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Statuses.Unhide; -public class NotificationUnhideUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { private static readonly Func> expectValidationException = Assert.Throws>; @@ -22,36 +22,36 @@ public void Hide_ShouldSucceed_WhenHidden() [Fact] public void Hide_ShouldFail_WhenUnread() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Unhide(); - }); + })); } [Fact] public void Hide_ShouldFail_WhenRead() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Read(); notification.Unhide(); - }); + })); } [Fact] public void Hide_ShouldFail_WhenOpened() { - expectValidationException(() => + expectValidationException((Action)(() => { - Notification notification = CreateNotification(); + Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); notification.Read(); notification.Open(); notification.Unhide(); - }); + })); } } diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateInvalidDescriptionData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateInvalidDescriptionData.cs deleted file mode 100644 index 75a60b557..000000000 --- a/tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateInvalidDescriptionData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create.Data; - -using static NotificationsData; - -public class NotificationCreateInvalidDescriptionData : NotificationCreateData -{ - public NotificationCreateInvalidDescriptionData() - { - Add(MinValidType, MinInvalidDescription); - Add(MaxValidType, MaxInvalidDescription); - } -} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateInvalidNameData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateInvalidNameData.cs deleted file mode 100644 index 6295df74f..000000000 --- a/tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateInvalidNameData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create.Data; - -using static NotificationsData; - -public class NotificationCreateInvalidNameData : NotificationCreateData -{ - public NotificationCreateInvalidNameData() - { - Add(MinInvalidType, MinValidDescription); - Add(MaxInvalidType, MaxValidDescription); - } -} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateValidData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateValidData.cs deleted file mode 100644 index 07eeba39f..000000000 --- a/tests/UnitTests/Notifications/Domain/Notifications/Create/Data/NotificationCreateValidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create.Data; - -using static NotificationsData; - -public class NotificationCreateValidData : NotificationCreateData -{ - public NotificationCreateValidData() - { - Add(MinValidType, MinValidDescription); - Add(MaxValidType, MaxValidDescription); - } -} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Create/InvalidTestData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Create/InvalidTestData.cs new file mode 100644 index 000000000..89239d48e --- /dev/null +++ b/tests/UnitTests/Notifications/Domain/Notifications/Create/InvalidTestData.cs @@ -0,0 +1,17 @@ +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create; + +using static Data.Notifications.TestData; + +public class InvalidData : TheoryData +{ + public InvalidData() + { + // Name + Add(MinInvalidType, MinValidDescription); + Add(MaxInvalidType, MaxValidDescription); + + // Description + Add(MinValidType, MinInvalidDescription); + Add(MaxValidType, MaxInvalidDescription); + } +} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Create/Normal/Tests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Create/Normal/Tests.cs new file mode 100644 index 000000000..de571a3c3 --- /dev/null +++ b/tests/UnitTests/Notifications/Domain/Notifications/Create/Normal/Tests.cs @@ -0,0 +1,37 @@ +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create.Normal; + +using static Data.Notifications.TestData; + +public class Tests : Data.Notifications.BaseUnitTests +{ + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldNotThrowException_WhenNotificationIsValid(string name, string description) + { + Notification.Create(name, new(description, ValidLink), ValidAuthorId, ValidReceiverId); + } + + [Theory] + [ClassData(typeof(ValidData))] + public void Create_ShouldPopulateProperties(string type, string description) + { + var notification = Notification.Create(type, new(description, ValidLink), ValidAuthorId, ValidReceiverId); + + Assert.Multiple( + () => Assert.Equal(type, notification.Type), + () => Assert.Equal(description, notification.Content.Description), + () => Assert.Equal(ValidLink, notification.Content.Link), + () => Assert.Equal(ValidAuthorId, notification.AuthorId), + () => Assert.Equal(ValidReceiverId, notification.ReceiverId) + ); + } + + [Theory] + [ClassData(typeof(InvalidData))] + public void Create_ShouldThrowException_WhenNotificationIsInvalid(string type, string description) + { + Assert.Throws>( + () => Notification.Create(type, new(description, ValidLink), ValidAuthorId, ValidReceiverId) + ); + } +} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Create/NotificationCreateData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Create/NotificationCreateData.cs deleted file mode 100644 index fcc54e0ba..000000000 --- a/tests/UnitTests/Notifications/Domain/Notifications/Create/NotificationCreateData.cs +++ /dev/null @@ -1,3 +0,0 @@ -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create; - -public class NotificationCreateData : TheoryData; diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Create/ValidTestData.cs b/tests/UnitTests/Notifications/Domain/Notifications/Create/ValidTestData.cs new file mode 100644 index 000000000..6998e2793 --- /dev/null +++ b/tests/UnitTests/Notifications/Domain/Notifications/Create/ValidTestData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create; + +using static Data.Notifications.TestData; + +public class ValidData : TheoryData +{ + public ValidData() + { + Add(MinValidType, MinValidDescription); + Add(MaxValidType, MaxValidDescription); + } +} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Create/WithId/NotificationCreateWithIdUnitTests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Create/WithId/NotificationCreateWithIdUnitTests.cs deleted file mode 100644 index 04176aa72..000000000 --- a/tests/UnitTests/Notifications/Domain/Notifications/Create/WithId/NotificationCreateWithIdUnitTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create.WithId; - -using Data; -using static NotificationsData; - -public class NotificationCreateWithIdWithIdUnitTests : NotificationsBaseUnitTests -{ - [Theory] - [ClassData(typeof(NotificationCreateValidData))] - public void CreateWithId_ShouldNotThrowException_WhenNotificationIsValid(string name, string description) - { - CreateNotificationWithId(ValidId, name, description, ValidLink, ValidAuthorId, ValidReceiverId); - } - - [Theory] - [ClassData(typeof(NotificationCreateValidData))] - public void CreateWithId_ShouldPopulateProperties(string type, string description) - { - var notification = CreateNotificationWithId(ValidId, type, description, ValidLink, ValidAuthorId, ValidReceiverId); - - Assert.Multiple( - () => Assert.Equal(type, notification.Type), - () => Assert.Equal(description, notification.Content.Description), - () => Assert.Equal(ValidLink, notification.Content.Link), - () => Assert.Equal(ValidAuthorId, notification.AuthorId), - () => Assert.Equal(ValidReceiverId, notification.ReceiverId) - ); - } - - [Theory] - [ClassData(typeof(NotificationCreateInvalidNameData))] - [ClassData(typeof(NotificationCreateInvalidDescriptionData))] - public void CreateWithId_ShouldThrowException_WhenNotificationIsInvalid(string type, string description) - { - Assert.Throws>( - () => CreateNotificationWithId(ValidId, type, description, ValidLink, ValidAuthorId, ValidReceiverId) - ); - } -} diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Create/Normal/NotificationCreateUnitTests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Create/WithId/Tests.cs similarity index 60% rename from tests/UnitTests/Notifications/Domain/Notifications/Create/Normal/NotificationCreateUnitTests.cs rename to tests/UnitTests/Notifications/Domain/Notifications/Create/WithId/Tests.cs index 73c066713..7af81d33c 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Create/Normal/NotificationCreateUnitTests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Create/WithId/Tests.cs @@ -1,22 +1,21 @@ -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create.Normal; +namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Create.WithId; -using Data; -using static NotificationsData; +using static Data.Notifications.TestData; -public class NotificationCreateUnitTests : NotificationsBaseUnitTests +public class Tests : Data.Notifications.BaseUnitTests { [Theory] - [ClassData(typeof(NotificationCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldNotThrowException_WhenNotificationIsValid(string name, string description) { - CreateNotification(name, description, ValidLink, ValidAuthorId, ValidReceiverId); + CreateNotification(name, description); } [Theory] - [ClassData(typeof(NotificationCreateValidData))] + [ClassData(typeof(ValidData))] public void Create_ShouldPopulateProperties(string type, string description) { - var notification = CreateNotification(type, description, ValidLink, ValidAuthorId, ValidReceiverId); + var notification = CreateNotification(type, description, ValidLink, ValidAuthorId, ValidReceiverId, ValidId); Assert.Multiple( () => Assert.Equal(type, notification.Type), @@ -28,12 +27,11 @@ public void Create_ShouldPopulateProperties(string type, string description) } [Theory] - [ClassData(typeof(NotificationCreateInvalidNameData))] - [ClassData(typeof(NotificationCreateInvalidDescriptionData))] + [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenNotificationIsInvalid(string type, string description) { Assert.Throws>( - () => CreateNotification(type, description, ValidLink, ValidAuthorId, ValidReceiverId) + () => CreateNotification(type, description) ); } } diff --git a/tests/UnitTests/Notifications/Domain/Notifications/NotificationsBaseUnitTests.cs b/tests/UnitTests/Notifications/Domain/Notifications/NotificationsBaseUnitTests.cs deleted file mode 100644 index 24ca8a1a1..000000000 --- a/tests/UnitTests/Notifications/Domain/Notifications/NotificationsBaseUnitTests.cs +++ /dev/null @@ -1,37 +0,0 @@ -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Notifications; - -namespace CustomCADs.UnitTests.Notifications.Domain.Notifications; - -using static NotificationsData; - -public class NotificationsBaseUnitTests -{ - public static Notification CreateNotification( - string? type = null, - string? description = null, - string? link = null, - AccountId? authorId = null, - AccountId? receiverId = null - ) => Notification.Create( - type: type ?? MaxValidType, - content: new(description ?? MaxValidDescription, link), - authorId: authorId ?? ValidAuthorId, - receiverId: receiverId ?? ValidReceiverId - ); - - public static Notification CreateNotificationWithId( - NotificationId? id = null, - string? type = null, - string? description = null, - string? link = null, - AccountId? authorId = null, - AccountId? receiverId = null - ) => Notification.Create( - id: id ?? ValidId, - type: type ?? MaxValidType, - content: new(description ?? MaxValidDescription, link), - authorId: authorId ?? ValidAuthorId, - receiverId: receiverId ?? ValidReceiverId - ); -} diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/CreateCustomizationHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs similarity index 89% rename from tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/CreateCustomizationHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs index 2abeaf6cf..424be781c 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/CreateCustomizationHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs @@ -4,15 +4,15 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Commands.Internal.Create; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class CreateCustomizationHandlerUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { private readonly CreateCustomizationHandler handler; private readonly Mock> writes = new(); private readonly Mock uow = new(); - public CreateCustomizationHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object); @@ -25,7 +25,7 @@ public CreateCustomizationHandlerUnitTests() && x.MaterialId == ValidMaterialId ), ct - )).ReturnsAsync(CreateCustomizationWithId(id: ValidId)); + )).ReturnsAsync(CreateCustomization(id: ValidId)); } [Fact] diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/DeleteCustomizationHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs similarity index 92% rename from tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/DeleteCustomizationHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs index 9374f3c40..bec0344c7 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/DeleteCustomizationHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Commands.Internal.Delete; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class DeleteCustomizationHandlerUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { private readonly DeleteCustomizationHandler handler; private readonly Mock reads = new(); @@ -18,7 +18,7 @@ public class DeleteCustomizationHandlerUnitTests : CustomizationsBaseUnitTests private readonly Customization customization = CreateCustomization(); - public DeleteCustomizationHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object); diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/EditCustomizationHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs similarity index 93% rename from tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/EditCustomizationHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs index 771e1ecf7..9fe84ffc9 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/EditCustomizationHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Commands.Internal.Edit; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class EditCustomizationHandlerUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { private readonly EditCustomizationHandler handler; private readonly Mock reads = new(); @@ -16,7 +16,7 @@ public class EditCustomizationHandlerUnitTests : CustomizationsBaseUnitTests private readonly Customization customization = CreateCustomization(); - public EditCustomizationHandlerUnitTests() + public Tests() { handler = new(reads.Object, uow.Object); diff --git a/tests/UnitTests/Printing/Application/Customizations/CustomizationsBaseUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/CustomizationsBaseUnitTests.cs deleted file mode 100644 index 1f8464d6e..000000000 --- a/tests/UnitTests/Printing/Application/Customizations/CustomizationsBaseUnitTests.cs +++ /dev/null @@ -1,54 +0,0 @@ -using CustomCADs.Modules.Printing.Domain.Customizations; -using CustomCADs.Modules.Printing.Domain.Materials; -using CustomCADs.Shared.Domain.TypedIds.Files; - -namespace CustomCADs.UnitTests.Printing.Application.Customizations; - -using static CustomizationsData; - -public class CustomizationsBaseUnitTests -{ - protected static readonly CancellationToken ct = default; - - protected static Customization CreateCustomization( - decimal? scale = null, - decimal? infill = null, - decimal? volume = null, - string? color = null, - MaterialId? materialId = null - ) => Customization.Create( - scale: scale ?? MinValidScale, - infill: infill ?? MinValidInfill, - volume: volume ?? MinValidVolume, - color: color ?? ValidColor, - materialId: materialId ?? ValidMaterialId - ); - - protected static Customization CreateCustomizationWithId( - CustomizationId? id = null, - decimal? scale = null, - decimal? infill = null, - decimal? volume = null, - string? color = null, - MaterialId? materialId = null - ) => Customization.CreateWithId( - id: id ?? ValidId, - scale: scale ?? MinValidScale, - infill: infill ?? MinValidInfill, - volume: volume ?? MinValidVolume, - color: color ?? ValidColor, - materialId: materialId ?? ValidMaterialId - ); - - protected static Material CreateMaterial( - string? name = null, - decimal? density = null, - decimal? cost = null, - ImageId? textureId = null - ) => Material.Create( - name: name ?? MaterialsData.MinValidName, - density: density ?? MaterialsData.MinValidDensity, - cost: cost ?? MaterialsData.MinValidCost, - textureId: textureId ?? MaterialsData.ValidTextureId - ); -} diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/GetCustomizationByIdHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs similarity index 94% rename from tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/GetCustomizationByIdHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs index e48c64fe3..34ee5c594 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/GetCustomizationByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs @@ -7,19 +7,19 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Internal.GetById; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class GetCustomizationByIdHandlerUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { private readonly GetCustomizationByIdHandler handler; private readonly Mock reads = new(); private readonly Mock materialReads = new(); private readonly Mock calculator = new(); - private readonly Customization customization = CreateCustomizationWithId(ValidId); + private readonly Customization customization = CreateCustomization(id: ValidId); private readonly Material material = CreateMaterial(); - public GetCustomizationByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/BatchGetCustomizationCostByIdHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs similarity index 92% rename from tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/BatchGetCustomizationCostByIdHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs index ced6d6c98..041b5dd2c 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/BatchGetCustomizationCostByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs @@ -5,11 +5,11 @@ using CustomCADs.Modules.Printing.Domain.Services; using CustomCADs.Shared.Application.UseCases.Customizations.Queries; -namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Shared.Cost; +namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Shared.Cost.Batch; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class BatchGetCustomizationCostByIdHandlerUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { private readonly BatchGetCustomizationCostByIdHandler handler; private readonly Mock reads = new(); @@ -25,7 +25,7 @@ public class BatchGetCustomizationCostByIdHandlerUnitTests : CustomizationsBaseU [ValidMaterialId] = CreateMaterial(), }; - public BatchGetCustomizationCostByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/GetCustomizationCostByIdHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs similarity index 93% rename from tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/GetCustomizationCostByIdHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs index 452d46057..99c4711e5 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/GetCustomizationCostByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs @@ -6,11 +6,11 @@ using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.Customizations.Queries; -namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Shared.Cost; +namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Shared.Cost.Single; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class GetCustomizationCostByIdHandlerUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { private readonly GetCustomizationCostByIdHandler handler; private readonly Mock reads = new(); @@ -21,7 +21,7 @@ public class GetCustomizationCostByIdHandlerUnitTests : CustomizationsBaseUnitTe private readonly Customization customization = CreateCustomization(); private readonly Material material = CreateMaterial(); - public GetCustomizationCostByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/GetCustomizationExistsByIdHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs similarity index 87% rename from tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/GetCustomizationExistsByIdHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs index 08f945799..cb6555f60 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/GetCustomizationExistsByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs @@ -4,14 +4,14 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Shared.Exists; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class GetCustomizationExistsByIdHandlerUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { private readonly GetCustomizationExistsByIdHandler handler; private readonly Mock reads = new(); - public GetCustomizationExistsByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object); diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/BatchGetCustomizationWeightByIdHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs similarity index 92% rename from tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/BatchGetCustomizationWeightByIdHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs index 11a287188..c6911d039 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/BatchGetCustomizationWeightByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs @@ -5,11 +5,11 @@ using CustomCADs.Modules.Printing.Domain.Services; using CustomCADs.Shared.Application.UseCases.Customizations.Queries; -namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Shared.Weight; +namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Shared.Weight.Batch; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class BatchGetCustomizationWeightByIdHandlerUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { private readonly BatchGetCustomizationWeightByIdHandler handler; private readonly Mock reads = new(); @@ -25,7 +25,7 @@ public class BatchGetCustomizationWeightByIdHandlerUnitTests : CustomizationsBas [ValidMaterialId] = CreateMaterial(), }; - public BatchGetCustomizationWeightByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/GetCustomizationWeightByIdHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs similarity index 93% rename from tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/GetCustomizationWeightByIdHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs index 22c8a60ae..a35a0263f 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/GetCustomizationWeightByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs @@ -6,11 +6,11 @@ using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.Customizations.Queries; -namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Shared.Weight; +namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Shared.Weight.Single; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class GetCustomizationWeightByIdHandlerUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { private readonly GetCustomizationWeightByIdHandler handler; private readonly Mock reads = new(); @@ -21,7 +21,7 @@ public class GetCustomizationWeightByIdHandlerUnitTests : CustomizationsBaseUnit private readonly Customization customization = CreateCustomization(); private readonly Material material = CreateMaterial(); - public GetCustomizationWeightByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); diff --git a/tests/UnitTests/Printing/Application/GlobalUsings.cs b/tests/UnitTests/Printing/Application/GlobalUsings.cs index 51579a8e6..32f461ee9 100644 --- a/tests/UnitTests/Printing/Application/GlobalUsings.cs +++ b/tests/UnitTests/Printing/Application/GlobalUsings.cs @@ -1,4 +1,3 @@ global using CustomCADs.Shared.Domain.TypedIds.Printing; -global using CustomCADs.UnitTests.Printing.Data; global using Moq; global using Xunit; diff --git a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/CreateMaterialHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs similarity index 91% rename from tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/CreateMaterialHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs index 0ad33f6e4..3463fd701 100644 --- a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/CreateMaterialHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs @@ -7,9 +7,9 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Commands.Internal.Create; -using static MaterialsData; +using static Data.Materials.TestData; -public class CreateMaterialHandlerUnitTests : MaterialsBaseUnitTests +public class Tests : Data.Materials.BaseUnitTests { private readonly CreateMaterialHandler handler; private readonly Mock> writes = new(); @@ -17,14 +17,14 @@ public class CreateMaterialHandlerUnitTests : MaterialsBaseUnitTests private readonly Mock> cache = new(); private readonly Mock sender = new(); - private readonly Material material = CreateMaterialWithId(); + private readonly Material material = CreateMaterial(); - public CreateMaterialHandlerUnitTests() + public Tests() { handler = new(writes.Object, uow.Object, cache.Object, sender.Object); writes.Setup(x => x.AddAsync(It.Is(x => x.Id == material.Id), ct)) - .ReturnsAsync(CreateMaterialWithId(id: ValidId)); + .ReturnsAsync(CreateMaterial(id: ValidId)); sender.Setup(x => x.SendQueryAsync( It.Is(x => x.Id == ValidTextureId), diff --git a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/DeleteMaterialHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs similarity index 92% rename from tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/DeleteMaterialHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs index 0b910c9ba..63e2df53e 100644 --- a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/DeleteMaterialHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Commands.Internal.Delete; -using static MaterialsData; +using static Data.Materials.TestData; -public class DeleteMaterialHandlerUnitTests : MaterialsBaseUnitTests +public class Tests : Data.Materials.BaseUnitTests { private readonly DeleteMaterialHandler handler; private readonly Mock reads = new(); @@ -18,7 +18,7 @@ public class DeleteMaterialHandlerUnitTests : MaterialsBaseUnitTests private readonly Material material = CreateMaterial(); - public DeleteMaterialHandlerUnitTests() + public Tests() { handler = new(reads.Object, writes.Object, uow.Object, cache.Object); diff --git a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/EditMaterialHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs similarity index 93% rename from tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/EditMaterialHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs index 0830a1bdf..ffbb34520 100644 --- a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/EditMaterialHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs @@ -6,9 +6,9 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Commands.Internal.Edit; -using static MaterialsData; +using static Data.Materials.TestData; -public class EditMaterialHandlerUnitTests : MaterialsBaseUnitTests +public class Tests : Data.Materials.BaseUnitTests { private readonly EditMaterialHandler handler; private readonly Mock reads = new(); @@ -17,7 +17,7 @@ public class EditMaterialHandlerUnitTests : MaterialsBaseUnitTests private readonly Material material = CreateMaterial(); - public EditMaterialHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object, uow.Object); diff --git a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/GetAllMaterialHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs similarity index 92% rename from tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/GetAllMaterialHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs index 75490ce00..f5409882a 100644 --- a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/GetAllMaterialHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs @@ -6,7 +6,7 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Queries.Internal.GetAll; -public class GetAllMaterialHandlerUnitTests : MaterialsBaseUnitTests +public class Tests : Data.Materials.BaseUnitTests { private readonly GetAllMaterialsHandler handler; private readonly Mock reads = new(); @@ -18,7 +18,7 @@ public class GetAllMaterialHandlerUnitTests : MaterialsBaseUnitTests CreateMaterial(), ]; - public GetAllMaterialHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); diff --git a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/GetMaterialByIdHandlerUnitTests.cs b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs similarity index 85% rename from tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/GetMaterialByIdHandlerUnitTests.cs rename to tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs index d22ae21ee..4aaca629f 100644 --- a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/GetMaterialByIdHandlerUnitTests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs @@ -6,17 +6,17 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Queries.Internal.GetById; -using static MaterialsData; +using static Data.Materials.TestData; -public class GetMaterialByIdHandlerUnitTests : MaterialsBaseUnitTests +public class Tests : Data.Materials.BaseUnitTests { private readonly GetMaterialByIdHandler handler; private readonly Mock reads = new(); private readonly Mock> cache = new(); - private static readonly Material material = CreateMaterialWithId(); + private static readonly Material material = CreateMaterial(); - public GetMaterialByIdHandlerUnitTests() + public Tests() { handler = new(reads.Object, cache.Object); diff --git a/tests/UnitTests/Printing/Data/Customizations/BaseUnitTests.cs b/tests/UnitTests/Printing/Data/Customizations/BaseUnitTests.cs new file mode 100644 index 000000000..dd797feea --- /dev/null +++ b/tests/UnitTests/Printing/Data/Customizations/BaseUnitTests.cs @@ -0,0 +1,37 @@ +using CustomCADs.Modules.Printing.Domain.Customizations; +using CustomCADs.Modules.Printing.Domain.Materials; +using CustomCADs.Shared.Domain.TypedIds.Files; +using CustomCADs.Shared.Domain.TypedIds.Printing; + +namespace CustomCADs.UnitTests.Printing.Data.Customizations; + +using static TestData; + +public class BaseUnitTests +{ + protected static readonly CancellationToken ct = default; + + protected static Customization CreateCustomization( + decimal? scale = null, + decimal? infill = null, + decimal? volume = null, + string? color = null, + MaterialId? materialId = null, + CustomizationId? id = null + ) => Customization.Create( + id: id ?? ValidId, + scale: scale ?? MinValidScale, + infill: infill ?? MinValidInfill, + volume: volume ?? MinValidVolume, + color: color ?? ValidColor, + materialId: materialId ?? ValidMaterialId + ); + + protected static Material CreateMaterial( + string? name = null, + decimal? density = null, + decimal? cost = null, + ImageId? textureId = null, + MaterialId? id = null + ) => Data.Materials.BaseUnitTests.CreateMaterial(id, name, density, cost, textureId); +} diff --git a/tests/UnitTests/Printing/Data/CustomizationsData.cs b/tests/UnitTests/Printing/Data/Customizations/TestData.cs similarity index 92% rename from tests/UnitTests/Printing/Data/CustomizationsData.cs rename to tests/UnitTests/Printing/Data/Customizations/TestData.cs index e8031a795..262860a10 100644 --- a/tests/UnitTests/Printing/Data/CustomizationsData.cs +++ b/tests/UnitTests/Printing/Data/Customizations/TestData.cs @@ -1,11 +1,11 @@ using CustomCADs.Modules.Printing.Domain.Customizations; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.UnitTests.Printing.Data; +namespace CustomCADs.UnitTests.Printing.Data.Customizations; using static CustomizationConstants; -public static class CustomizationsData +public static class TestData { public const string ValidColor = "#ffffff"; public const string InvalidColor = ""; diff --git a/tests/UnitTests/Printing/Application/Materials/MaterialsBaseUnitTests.cs b/tests/UnitTests/Printing/Data/Materials/BaseUnitTests.cs similarity index 56% rename from tests/UnitTests/Printing/Application/Materials/MaterialsBaseUnitTests.cs rename to tests/UnitTests/Printing/Data/Materials/BaseUnitTests.cs index 7e708004b..7f9f27bb0 100644 --- a/tests/UnitTests/Printing/Application/Materials/MaterialsBaseUnitTests.cs +++ b/tests/UnitTests/Printing/Data/Materials/BaseUnitTests.cs @@ -1,33 +1,38 @@ using CustomCADs.Modules.Printing.Domain.Materials; using CustomCADs.Shared.Domain.TypedIds.Files; +using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.UnitTests.Printing.Application.Materials; +namespace CustomCADs.UnitTests.Printing.Data.Materials; -using static MaterialsData; +using static TestData; -public class MaterialsBaseUnitTests +public class BaseUnitTests { protected static readonly CancellationToken ct = default; protected static Material CreateMaterial( + string? name = null, + decimal? density = null, + decimal? cost = null, + ImageId? textureId = null, + MaterialId? id = null + ) => Create(id, name, density, cost, textureId); + + internal static Material CreateMaterial( + MaterialId? id = null, string? name = null, decimal? density = null, decimal? cost = null, ImageId? textureId = null - ) => Material.Create( - name: name ?? MinValidName, - density: density ?? MinValidDensity, - cost: cost ?? MinValidCost, - textureId: textureId ?? ValidTextureId - ); + ) => Create(id, name, density, cost, textureId); - protected static Material CreateMaterialWithId( + private static Material Create( MaterialId? id = null, string? name = null, decimal? density = null, decimal? cost = null, ImageId? textureId = null - ) => Material.CreateWithId( + ) => Material.Create( id: id ?? ValidId, name: name ?? MinValidName, density: density ?? MinValidDensity, diff --git a/tests/UnitTests/Printing/Data/MaterialsData.cs b/tests/UnitTests/Printing/Data/Materials/TestData.cs similarity index 92% rename from tests/UnitTests/Printing/Data/MaterialsData.cs rename to tests/UnitTests/Printing/Data/Materials/TestData.cs index f6dbdcf52..aaa55db65 100644 --- a/tests/UnitTests/Printing/Data/MaterialsData.cs +++ b/tests/UnitTests/Printing/Data/Materials/TestData.cs @@ -2,11 +2,11 @@ using CustomCADs.Shared.Domain.TypedIds.Files; using CustomCADs.Shared.Domain.TypedIds.Printing; -namespace CustomCADs.UnitTests.Printing.Data; +namespace CustomCADs.UnitTests.Printing.Data.Materials; using static MaterialConstants; -public static class MaterialsData +public static class TestData { public static readonly string MaxValidName = new('a', NameMaxLength - 1); public static readonly string MinValidName = new('a', NameMinLength + 1); diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/Data/CustomizationSetColorInvalidData.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/Data/CustomizationSetColorInvalidData.cs deleted file mode 100644 index 69ab3902e..000000000 --- a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/Data/CustomizationSetColorInvalidData.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Color.Data; - -using static CustomizationsData; - -public class CustomizationSetColorInvalidData : TheoryData -{ - public CustomizationSetColorInvalidData() - { - Add(InvalidColor); - Add(MinInvalidColor); - Add(MaxInvalidColor); - } -} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/TestData.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/TestData.cs new file mode 100644 index 000000000..ae57580f1 --- /dev/null +++ b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/TestData.cs @@ -0,0 +1,13 @@ +namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Color; + +using static Data.Customizations.TestData; + +public class TestData : TheoryData +{ + public TestData() + { + Add(InvalidColor); + Add(MinInvalidColor); + Add(MaxInvalidColor); + } +} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/CustomizationSetColorUnitTests.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/Tests.cs similarity index 81% rename from tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/CustomizationSetColorUnitTests.cs rename to tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/Tests.cs index 4c0a62c94..4bf9075aa 100644 --- a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/CustomizationSetColorUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Color/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Color; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class CustomizationSetColorUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { [Fact] public void SetColor_ShouldNotThrowException() @@ -24,7 +24,7 @@ public void SetColor_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.CustomizationSetColorInvalidData))] + [ClassData(typeof(TestData))] public void SetColor_ShouldThrowException_WhenColorInvalid(string color) { Customization material = CreateCustomization(); diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/Data/CustomizationSetInfillInvalidData.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/Data/CustomizationSetInfillInvalidData.cs deleted file mode 100644 index 7357b60a4..000000000 --- a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/Data/CustomizationSetInfillInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Infill.Data; - -using static CustomizationsData; - -public class CustomizationSetInfillInvalidData : TheoryData -{ - public CustomizationSetInfillInvalidData() - { - Add(MinInvalidInfill); - Add(MaxInvalidInfill); - } -} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/TestData.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/TestData.cs new file mode 100644 index 000000000..702de6ce8 --- /dev/null +++ b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/TestData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Infill; + +using static Data.Customizations.TestData; + +public class TestData : TheoryData +{ + public TestData() + { + Add(MinInvalidInfill); + Add(MaxInvalidInfill); + } +} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/CustomizationSetInfillUnitTests.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/Tests.cs similarity index 81% rename from tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/CustomizationSetInfillUnitTests.cs rename to tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/Tests.cs index 70824ed40..c33d7bdb7 100644 --- a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/CustomizationSetInfillUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Infill/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Infill; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class CustomizationSetInfillUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { [Fact] public void SetInfill_ShouldNotThrowException() @@ -24,7 +24,7 @@ public void SetInfill_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.CustomizationSetInfillInvalidData))] + [ClassData(typeof(TestData))] public void SetInfill_ShouldThrowException_WhenInfillInvalid(decimal infill) { Customization material = CreateCustomization(); diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/MaterialId/CustomizationSetMaterialIdUnitTests.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/MaterialId/Tests.cs similarity index 81% rename from tests/UnitTests/Printing/Domain/Customizations/Behaviors/MaterialId/CustomizationSetMaterialIdUnitTests.cs rename to tests/UnitTests/Printing/Domain/Customizations/Behaviors/MaterialId/Tests.cs index baf405441..93f28b4fd 100644 --- a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/MaterialId/CustomizationSetMaterialIdUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/MaterialId/Tests.cs @@ -2,9 +2,9 @@ namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.MaterialId; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class CustomizationSetMaterialIdUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { [Fact] public void SetMaterialId_ShouldNotThrowException() diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/Data/CustomizationSetScaleInvalidData.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/Data/CustomizationSetScaleInvalidData.cs deleted file mode 100644 index c355944e9..000000000 --- a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/Data/CustomizationSetScaleInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Scale.Data; - -using static CustomizationsData; - -public class CustomizationSetScaleInvalidData : TheoryData -{ - public CustomizationSetScaleInvalidData() - { - Add(MinInvalidScale); - Add(MaxInvalidScale); - } -} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/TestData.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/TestData.cs new file mode 100644 index 000000000..499f42082 --- /dev/null +++ b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/TestData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Scale; + +using static Data.Customizations.TestData; + +public class TestData : TheoryData +{ + public TestData() + { + Add(MinInvalidScale); + Add(MaxInvalidScale); + } +} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/CustomizationSetScaleUnitTests.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/Tests.cs similarity index 81% rename from tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/CustomizationSetScaleUnitTests.cs rename to tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/Tests.cs index 4c11d0916..819ef2ae0 100644 --- a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/CustomizationSetScaleUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Scale/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Scale; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class CustomizationSetScaleUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { [Fact] public void SetScale_ShouldNotThrowException() @@ -24,7 +24,7 @@ public void SetScale_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.CustomizationSetScaleInvalidData))] + [ClassData(typeof(TestData))] public void SetScale_ShouldThrowException_WhenScaleInvalid(decimal scale) { Customization material = CreateCustomization(); diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/CustomizationSetVolumeInvalidData.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/CustomizationSetVolumeInvalidData.cs new file mode 100644 index 000000000..e05dfa1e7 --- /dev/null +++ b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/CustomizationSetVolumeInvalidData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Volume; + +using static Data.Customizations.TestData; + +public class TestData : TheoryData +{ + public TestData() + { + Add(MinInvalidVolume); + Add(MaxInvalidVolume); + } +} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/Data/CustomizationSetVolumeInvalidData.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/Data/CustomizationSetVolumeInvalidData.cs deleted file mode 100644 index f6dcf8e23..000000000 --- a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/Data/CustomizationSetVolumeInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Volume.Data; - -using static CustomizationsData; - -public class CustomizationSetVolumeInvalidData : TheoryData -{ - public CustomizationSetVolumeInvalidData() - { - Add(MinInvalidVolume); - Add(MaxInvalidVolume); - } -} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/CustomizationSetVolumeUnitTests.cs b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/Tests.cs similarity index 81% rename from tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/CustomizationSetVolumeUnitTests.cs rename to tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/Tests.cs index e60d266ce..3b257f26a 100644 --- a/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/CustomizationSetVolumeUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Customizations/Behaviors/Volume/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Behaviors.Volume; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class CustomizationSetVolumeUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { [Fact] public void SetVolume_ShouldNotThrowException() @@ -24,7 +24,7 @@ public void SetVolume_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.CustomizationSetVolumeInvalidData))] + [ClassData(typeof(TestData))] public void SetVolume_ShouldThrowException_WhenVolumeInvalid(decimal volume) { Customization material = CreateCustomization(); diff --git a/tests/UnitTests/Printing/Domain/Customizations/Create/Normal/Tests.cs b/tests/UnitTests/Printing/Domain/Customizations/Create/Normal/Tests.cs new file mode 100644 index 000000000..7197a2f89 --- /dev/null +++ b/tests/UnitTests/Printing/Domain/Customizations/Create/Normal/Tests.cs @@ -0,0 +1,38 @@ +using CustomCADs.Modules.Printing.Domain.Customizations; +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Create.Normal; + +using static Data.Customizations.TestData; + +public class Tests : Data.Customizations.BaseUnitTests +{ + [Fact] + public void Create_ShouldNotThrowException() + { + Customization.Create(MaxValidScale, MaxValidInfill, MaxValidVolume, ValidColor, ValidMaterialId); + } + + [Fact] + public void Create_ShouldPopulateProperties() + { + Customization customization = Customization.Create(MaxValidScale, MaxValidInfill, MaxValidVolume, ValidColor, ValidMaterialId); + + Assert.Multiple( + () => Assert.Equal(MaxValidScale, customization.Scale), + () => Assert.Equal(MaxValidInfill, customization.Infill), + () => Assert.Equal(MaxValidVolume, customization.Volume), + () => Assert.Equal(ValidColor, customization.Color), + () => Assert.Equal(ValidMaterialId, customization.MaterialId) + ); + } + + [Theory] + [ClassData(typeof(TestData))] + public void Create_ShouldThrowException_WhenInvalid(decimal scale, decimal infill, decimal volume, string color) + { + Assert.Throws>( + () => Customization.Create(scale, infill, volume, color, ValidMaterialId) + ); + } +} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Create/Data/CustomizationCreateInvalidData.cs b/tests/UnitTests/Printing/Domain/Customizations/Create/TestData.cs similarity index 80% rename from tests/UnitTests/Printing/Domain/Customizations/Create/Data/CustomizationCreateInvalidData.cs rename to tests/UnitTests/Printing/Domain/Customizations/Create/TestData.cs index 36e3df8ec..b3bfb98cb 100644 --- a/tests/UnitTests/Printing/Domain/Customizations/Create/Data/CustomizationCreateInvalidData.cs +++ b/tests/UnitTests/Printing/Domain/Customizations/Create/TestData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Create.Data; +namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Create; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class CustomizationCreateInvalidData : TheoryData +public class TestData : TheoryData { - public CustomizationCreateInvalidData() + public TestData() { // Scale Add(MaxInvalidScale, MaxValidInfill, MaxValidVolume, ValidColor); diff --git a/tests/UnitTests/Printing/Domain/Customizations/Create/WithId/CustomizationCreateWithIdUnitTests.cs b/tests/UnitTests/Printing/Domain/Customizations/Create/WithId/CustomizationCreateWithIdUnitTests.cs deleted file mode 100644 index 82d9d8c03..000000000 --- a/tests/UnitTests/Printing/Domain/Customizations/Create/WithId/CustomizationCreateWithIdUnitTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CustomCADs.Modules.Printing.Domain.Customizations; -using CustomCADs.Shared.Domain.Exceptions; - -namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Create.WithId; - -using static CustomizationsData; - -public class CustomizationCreateWithIdUnitTests : CustomizationsBaseUnitTests -{ - [Fact] - public void CreateWithId_ShouldNotThrowException() - { - CreateCustomizationWithId(ValidId, MaxValidScale, MaxValidInfill, MaxValidVolume, ValidColor, ValidMaterialId); - } - - [Fact] - public void CreateWithId_ShouldPopulateProperties() - { - Customization customization = CreateCustomizationWithId(ValidId, MaxValidScale, MaxValidInfill, MaxValidVolume, ValidColor, ValidMaterialId); - - Assert.Multiple( - () => Assert.Equal(ValidId, customization.Id), - () => Assert.Equal(MaxValidScale, customization.Scale), - () => Assert.Equal(MaxValidInfill, customization.Infill), - () => Assert.Equal(MaxValidVolume, customization.Volume), - () => Assert.Equal(ValidColor, customization.Color), - () => Assert.Equal(ValidMaterialId, customization.MaterialId) - ); - } - - [Theory] - [ClassData(typeof(Data.CustomizationCreateInvalidData))] - public void CreateWithId_ShouldThrowException_WhenInvalid(decimal scale, decimal infill, decimal volume, string color) - { - Assert.Throws>( - () => CreateCustomizationWithId(ValidId, scale, infill, volume, color, ValidMaterialId) - ); - } -} diff --git a/tests/UnitTests/Printing/Domain/Customizations/Create/Normal/CustomizationCreateUnitTests.cs b/tests/UnitTests/Printing/Domain/Customizations/Create/WithId/Tests.cs similarity index 67% rename from tests/UnitTests/Printing/Domain/Customizations/Create/Normal/CustomizationCreateUnitTests.cs rename to tests/UnitTests/Printing/Domain/Customizations/Create/WithId/Tests.cs index 2fde955f1..d0b3a5621 100644 --- a/tests/UnitTests/Printing/Domain/Customizations/Create/Normal/CustomizationCreateUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Customizations/Create/WithId/Tests.cs @@ -1,24 +1,25 @@ using CustomCADs.Modules.Printing.Domain.Customizations; using CustomCADs.Shared.Domain.Exceptions; -namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Create.Normal; +namespace CustomCADs.UnitTests.Printing.Domain.Customizations.Create.WithId; -using static CustomizationsData; +using static Data.Customizations.TestData; -public class CustomizationCreateUnitTests : CustomizationsBaseUnitTests +public class Tests : Data.Customizations.BaseUnitTests { [Fact] public void Create_ShouldNotThrowException() { - CreateCustomization(MaxValidScale, MaxValidInfill, MaxValidVolume, ValidColor, ValidMaterialId); + CreateCustomization(); } [Fact] public void Create_ShouldPopulateProperties() { - Customization customization = CreateCustomization(MaxValidScale, MaxValidInfill, MaxValidVolume, ValidColor, ValidMaterialId); + Customization customization = CreateCustomization(MaxValidScale, MaxValidInfill, MaxValidVolume, ValidColor, ValidMaterialId, ValidId); Assert.Multiple( + () => Assert.Equal(ValidId, customization.Id), () => Assert.Equal(MaxValidScale, customization.Scale), () => Assert.Equal(MaxValidInfill, customization.Infill), () => Assert.Equal(MaxValidVolume, customization.Volume), @@ -28,11 +29,11 @@ public void Create_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.CustomizationCreateInvalidData))] + [ClassData(typeof(TestData))] public void Create_ShouldThrowException_WhenInvalid(decimal scale, decimal infill, decimal volume, string color) { Assert.Throws>( - () => CreateCustomization(scale, infill, volume, color, ValidMaterialId) + () => CreateCustomization(scale, infill, volume, color) ); } } diff --git a/tests/UnitTests/Printing/Domain/Customizations/CustomizationsBaseUnitTests.cs b/tests/UnitTests/Printing/Domain/Customizations/CustomizationsBaseUnitTests.cs deleted file mode 100644 index 0630d62d4..000000000 --- a/tests/UnitTests/Printing/Domain/Customizations/CustomizationsBaseUnitTests.cs +++ /dev/null @@ -1,38 +0,0 @@ -using CustomCADs.Modules.Printing.Domain.Customizations; - -namespace CustomCADs.UnitTests.Printing.Domain.Customizations; - -using static CustomizationsData; - -public class CustomizationsBaseUnitTests -{ - protected static Customization CreateCustomization( - decimal? scale = null, - decimal? infill = null, - decimal? volume = null, - string? color = null, - MaterialId? materialId = null - ) => Customization.Create( - scale: scale ?? MinValidScale, - infill: infill ?? MinValidInfill, - volume: volume ?? MinValidVolume, - color: color ?? ValidColor, - materialId: materialId ?? ValidMaterialId - ); - - protected static Customization CreateCustomizationWithId( - CustomizationId? id = null, - decimal? scale = null, - decimal? infill = null, - decimal? volume = null, - string? color = null, - MaterialId? materialId = null - ) => Customization.CreateWithId( - id: id ?? ValidId, - scale: scale ?? MinValidScale, - infill: infill ?? MinValidInfill, - volume: volume ?? MinValidVolume, - color: color ?? ValidColor, - materialId: materialId ?? ValidMaterialId - ); -} diff --git a/tests/UnitTests/Printing/Domain/GlobalUsings.cs b/tests/UnitTests/Printing/Domain/GlobalUsings.cs index 0d9fb3d17..013d595b4 100644 --- a/tests/UnitTests/Printing/Domain/GlobalUsings.cs +++ b/tests/UnitTests/Printing/Domain/GlobalUsings.cs @@ -1,3 +1,2 @@ global using CustomCADs.Shared.Domain.TypedIds.Printing; -global using CustomCADs.UnitTests.Printing.Data; global using Xunit; diff --git a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/Data/MaterialSetCostInvalidData.cs b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/Data/MaterialSetCostInvalidData.cs deleted file mode 100644 index 2375a2c9c..000000000 --- a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/Data/MaterialSetCostInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Printing.Domain.Materials.Behaviors.Cost.Data; - -using static MaterialsData; - -public class MaterialSetCostInvalidData : TheoryData -{ - public MaterialSetCostInvalidData() - { - Add(MinInvalidCost); - Add(MaxInvalidCost); - } -} diff --git a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/TestData.cs b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/TestData.cs new file mode 100644 index 000000000..297b94670 --- /dev/null +++ b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/TestData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Printing.Domain.Materials.Behaviors.Cost; + +using static Data.Materials.TestData; + +public class TestData : TheoryData +{ + public TestData() + { + Add(MinInvalidCost); + Add(MaxInvalidCost); + } +} diff --git a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/MaterialSetCostUnitTests.cs b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/Tests.cs similarity index 82% rename from tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/MaterialSetCostUnitTests.cs rename to tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/Tests.cs index 4f0be8cfd..7d3416833 100644 --- a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/MaterialSetCostUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Cost/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Printing.Domain.Materials.Behaviors.Cost; -using static MaterialsData; +using static Data.Materials.TestData; -public class MaterialSetCostUnitTests : MaterialsBaseUnitTests +public class Tests : Data.Materials.BaseUnitTests { [Fact] public void SetCost_ShouldNotThrowException() @@ -24,7 +24,7 @@ public void SetCost_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.MaterialSetCostInvalidData))] + [ClassData(typeof(TestData))] public void SetCost_ShouldThrowException_WhenCostInvalid(decimal cost) { Material material = CreateMaterial(); diff --git a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/Data/MaterialSetDensityInvalidData.cs b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/Data/MaterialSetDensityInvalidData.cs deleted file mode 100644 index a440038bb..000000000 --- a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/Data/MaterialSetDensityInvalidData.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CustomCADs.UnitTests.Printing.Domain.Materials.Behaviors.Density.Data; - -using static MaterialsData; - -public class MaterialSetDensityInvalidData : TheoryData -{ - public MaterialSetDensityInvalidData() - { - Add(MinInvalidDensity); - Add(MaxInvalidDensity); - } -} diff --git a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/TestData.cs b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/TestData.cs new file mode 100644 index 000000000..e6a37be64 --- /dev/null +++ b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/TestData.cs @@ -0,0 +1,12 @@ +namespace CustomCADs.UnitTests.Printing.Domain.Materials.Behaviors.Density; + +using static Data.Materials.TestData; + +public class TestData : TheoryData +{ + public TestData() + { + Add(MinInvalidDensity); + Add(MaxInvalidDensity); + } +} diff --git a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/MaterialSetDensityUnitTests.cs b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/Tests.cs similarity index 82% rename from tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/MaterialSetDensityUnitTests.cs rename to tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/Tests.cs index 358e8ae2a..116a9485f 100644 --- a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/MaterialSetDensityUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Density/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Printing.Domain.Materials.Behaviors.Density; -using static MaterialsData; +using static Data.Materials.TestData; -public class MaterialSetDensityUnitTests : MaterialsBaseUnitTests +public class Tests : Data.Materials.BaseUnitTests { [Fact] public void SetDensity_ShouldNotThrowException() @@ -24,7 +24,7 @@ public void SetDensity_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.MaterialSetDensityInvalidData))] + [ClassData(typeof(TestData))] public void SetDensity_ShouldThrowException_WhenDensityInvalid(decimal density) { Material material = CreateMaterial(); diff --git a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/Data/MaterialSetNameInvalidData.cs b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/TestData.cs similarity index 50% rename from tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/Data/MaterialSetNameInvalidData.cs rename to tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/TestData.cs index a6eeef3de..ed867d299 100644 --- a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/Data/MaterialSetNameInvalidData.cs +++ b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/TestData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Printing.Domain.Materials.Behaviors.Name.Data; +namespace CustomCADs.UnitTests.Printing.Domain.Materials.Behaviors.Name; -using static MaterialsData; +using static Data.Materials.TestData; -public class MaterialSetNameInvalidData : TheoryData +public class TestData : TheoryData { - public MaterialSetNameInvalidData() + public TestData() { Add(InvalidName); Add(MinInvalidName); diff --git a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/MaterialSetNameUnitTests.cs b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/Tests.cs similarity index 82% rename from tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/MaterialSetNameUnitTests.cs rename to tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/Tests.cs index 0e3e8150a..705a588ed 100644 --- a/tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/MaterialSetNameUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Materials/Behaviors/Name/Tests.cs @@ -3,9 +3,9 @@ namespace CustomCADs.UnitTests.Printing.Domain.Materials.Behaviors.Name; -using static MaterialsData; +using static Data.Materials.TestData; -public class MaterialSetNameUnitTests : MaterialsBaseUnitTests +public class Tests : Data.Materials.BaseUnitTests { [Fact] public void SetName_ShouldNotThrowException() @@ -24,7 +24,7 @@ public void SetName_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.MaterialSetNameInvalidData))] + [ClassData(typeof(TestData))] public void SetName_ShouldThrowException_WhenNameInvalid(string name) { Material material = CreateMaterial(); diff --git a/tests/UnitTests/Printing/Domain/Materials/Create/Normal/Tests.cs b/tests/UnitTests/Printing/Domain/Materials/Create/Normal/Tests.cs new file mode 100644 index 000000000..fc82dd633 --- /dev/null +++ b/tests/UnitTests/Printing/Domain/Materials/Create/Normal/Tests.cs @@ -0,0 +1,37 @@ +using CustomCADs.Modules.Printing.Domain.Materials; +using CustomCADs.Shared.Domain.Exceptions; + +namespace CustomCADs.UnitTests.Printing.Domain.Materials.Create.Normal; + +using static Data.Materials.TestData; + +public class Tests : Data.Materials.BaseUnitTests +{ + [Fact] + public void Create_ShouldNotThrowException() + { + Material.Create(MaxValidName, MaxValidDensity, MaxValidCost, ValidTextureId); + } + + [Fact] + public void Create_ShouldPopulateProperties() + { + Material material = Material.Create(MaxValidName, MaxValidDensity, MaxValidCost, ValidTextureId); + + Assert.Multiple( + () => Assert.Equal(MaxValidName, material.Name), + () => Assert.Equal(MaxValidDensity, material.Density), + () => Assert.Equal(MaxValidCost, material.Cost), + () => Assert.Equal(ValidTextureId, material.TextureId) + ); + } + + [Theory] + [ClassData(typeof(TestData))] + public void Create_ShouldThrowExcetion_WhenInvalid(string name, decimal density, decimal cost) + { + Assert.Throws>( + () => Material.Create(name, density, cost, ValidTextureId) + ); + } +} diff --git a/tests/UnitTests/Printing/Domain/Materials/Create/Data/MaterialCreateInvalidData.cs b/tests/UnitTests/Printing/Domain/Materials/Create/TestData.cs similarity index 66% rename from tests/UnitTests/Printing/Domain/Materials/Create/Data/MaterialCreateInvalidData.cs rename to tests/UnitTests/Printing/Domain/Materials/Create/TestData.cs index 4d5e6860e..22102c4ff 100644 --- a/tests/UnitTests/Printing/Domain/Materials/Create/Data/MaterialCreateInvalidData.cs +++ b/tests/UnitTests/Printing/Domain/Materials/Create/TestData.cs @@ -1,10 +1,10 @@ -namespace CustomCADs.UnitTests.Printing.Domain.Materials.Create.Data; +namespace CustomCADs.UnitTests.Printing.Domain.Materials.Create; -using static MaterialsData; +using static Data.Materials.TestData; -public class MaterialCreateInvalidData : TheoryData +public class TestData : TheoryData { - public MaterialCreateInvalidData() + public TestData() { // Name Add(InvalidName, MaxValidDensity, MaxValidCost); diff --git a/tests/UnitTests/Printing/Domain/Materials/Create/WithId/MaterialCreateUnitTests.cs b/tests/UnitTests/Printing/Domain/Materials/Create/WithId/MaterialCreateUnitTests.cs deleted file mode 100644 index 61e45d423..000000000 --- a/tests/UnitTests/Printing/Domain/Materials/Create/WithId/MaterialCreateUnitTests.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CustomCADs.Modules.Printing.Domain.Materials; -using CustomCADs.Shared.Domain.Exceptions; - - -namespace CustomCADs.UnitTests.Printing.Domain.Materials.Create.WithId; - -using static MaterialsData; - -public class MaterialCreateUnitTests : MaterialsBaseUnitTests -{ - [Fact] - public void CreateWithId_ShouldNotThrowException() - { - CreateMaterialWithId(ValidId, MaxValidName, MaxValidDensity, MaxValidCost, ValidTextureId); - } - - [Fact] - public void CreateWithId_ShouldPopulateProperties() - { - Material material = CreateMaterialWithId(ValidId, MaxValidName, MaxValidDensity, MaxValidCost, ValidTextureId); - - Assert.Multiple( - () => Assert.Equal(ValidId, material.Id), - () => Assert.Equal(MaxValidName, material.Name), - () => Assert.Equal(MaxValidDensity, material.Density), - () => Assert.Equal(MaxValidCost, material.Cost), - () => Assert.Equal(ValidTextureId, material.TextureId) - ); - } - - [Theory] - [ClassData(typeof(Data.MaterialCreateInvalidData))] - public void CreateWithId_ShouldThrowExcetion_WhenInvalid(string name, decimal density, decimal cost) - { - Assert.Throws>( - () => CreateMaterialWithId(ValidId, name, density, cost, ValidTextureId) - ); - } -} diff --git a/tests/UnitTests/Printing/Domain/Materials/Create/Normal/MaterialCreateUnitTests.cs b/tests/UnitTests/Printing/Domain/Materials/Create/WithId/Tests.cs similarity index 70% rename from tests/UnitTests/Printing/Domain/Materials/Create/Normal/MaterialCreateUnitTests.cs rename to tests/UnitTests/Printing/Domain/Materials/Create/WithId/Tests.cs index 8554d05cd..e9117b489 100644 --- a/tests/UnitTests/Printing/Domain/Materials/Create/Normal/MaterialCreateUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Materials/Create/WithId/Tests.cs @@ -1,24 +1,25 @@ using CustomCADs.Modules.Printing.Domain.Materials; using CustomCADs.Shared.Domain.Exceptions; -namespace CustomCADs.UnitTests.Printing.Domain.Materials.Create.Normal; +namespace CustomCADs.UnitTests.Printing.Domain.Materials.Create.WithId; -using static MaterialsData; +using static Data.Materials.TestData; -public class MaterialCreateUnitTests : MaterialsBaseUnitTests +public class Tests : Data.Materials.BaseUnitTests { [Fact] public void Create_ShouldNotThrowException() { - CreateMaterial(MaxValidName, MaxValidDensity, MaxValidCost, ValidTextureId); + CreateMaterial(); } [Fact] public void Create_ShouldPopulateProperties() { - Material material = CreateMaterial(MaxValidName, MaxValidDensity, MaxValidCost, ValidTextureId); + Material material = CreateMaterial(MaxValidName, MaxValidDensity, MaxValidCost, ValidTextureId, ValidId); Assert.Multiple( + () => Assert.Equal(ValidId, material.Id), () => Assert.Equal(MaxValidName, material.Name), () => Assert.Equal(MaxValidDensity, material.Density), () => Assert.Equal(MaxValidCost, material.Cost), @@ -27,11 +28,11 @@ public void Create_ShouldPopulateProperties() } [Theory] - [ClassData(typeof(Data.MaterialCreateInvalidData))] + [ClassData(typeof(TestData))] public void Create_ShouldThrowExcetion_WhenInvalid(string name, decimal density, decimal cost) { Assert.Throws>( - () => CreateMaterial(name, density, cost, ValidTextureId) + () => CreateMaterial(name, density, cost) ); } } diff --git a/tests/UnitTests/Printing/Domain/Materials/MaterialsBaseUnitTests.cs b/tests/UnitTests/Printing/Domain/Materials/MaterialsBaseUnitTests.cs deleted file mode 100644 index fb5a3994a..000000000 --- a/tests/UnitTests/Printing/Domain/Materials/MaterialsBaseUnitTests.cs +++ /dev/null @@ -1,35 +0,0 @@ -using CustomCADs.Modules.Printing.Domain.Materials; -using CustomCADs.Shared.Domain.TypedIds.Files; - -namespace CustomCADs.UnitTests.Printing.Domain.Materials; - -using static MaterialsData; - -public class MaterialsBaseUnitTests -{ - protected static Material CreateMaterial( - string? name = null, - decimal? density = null, - decimal? cost = null, - ImageId? textureId = null - ) => Material.Create( - name: name ?? MinValidName, - density: density ?? MinValidDensity, - cost: cost ?? MinValidCost, - textureId: textureId ?? ValidTextureId - ); - - protected static Material CreateMaterialWithId( - MaterialId? id = null, - string? name = null, - decimal? density = null, - decimal? cost = null, - ImageId? textureId = null - ) => Material.CreateWithId( - id: id ?? ValidId, - name: name ?? MinValidName, - density: density ?? MinValidDensity, - cost: cost ?? MinValidCost, - textureId: textureId ?? ValidTextureId - ); -} diff --git a/tests/UnitTests/Printing/Domain/Services/ServicesBaseUnitTests.cs b/tests/UnitTests/Printing/Domain/Services/ServicesBaseUnitTests.cs index 58bf3e943..7afe22af9 100644 --- a/tests/UnitTests/Printing/Domain/Services/ServicesBaseUnitTests.cs +++ b/tests/UnitTests/Printing/Domain/Services/ServicesBaseUnitTests.cs @@ -4,6 +4,9 @@ namespace CustomCADs.UnitTests.Printing.Domain.Services; +using CustomizationsData = Data.Customizations.TestData; +using MaterialsData = Data.Materials.TestData; + public class ServicesBaseUnitTests { protected static Customization CreateCustomization( From 0ca16178d30d5020a8f256f2f8e0776bb109287a Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Wed, 20 May 2026 22:07:01 +0300 Subject: [PATCH 06/15] Reinforced usage of `TestData` members and constants --- .../Events/Application/Viewed/Tests.cs | 9 ++-- .../Shared/ViewedProducts/ById/Tests.cs | 8 ++- .../Accounts/Data/Accounts/TestData.cs | 2 + .../Queries/Internal/GetSingle/Tests.cs | 15 +++--- .../Commands/Internal/Create/Tests.cs | 19 ++++--- .../Commands/Internal/Admin/Remove/Tests.cs | 21 ++++---- .../Internal/Designer/AddTag/Tests.cs | 21 +++----- .../Internal/Designer/RemoveTag/Tests.cs | 21 +++----- .../Queries/Shared/GetExists/Tests.cs | 14 +++--- .../Tags/Queries/Internal/GetById/Tests.cs | 12 ++--- .../Catalog/Data/Products/TestData.cs | 2 + .../Commands/Internal/Admin/Remove/Tests.cs | 12 ++--- .../Internal/Customer/Delete/Tests.cs | 22 ++++---- .../Commands/Internal/Customer/Edit/Tests.cs | 20 ++++---- .../Customer/Purchase/Normal/Tests.cs | 3 +- .../Customer/Purchase/WithDelivery/Tests.cs | 3 +- .../Purchase/WithDelivery/Validator.cs | 50 +++++++++---------- .../Internal/Customer/SetDelivery/Tests.cs | 45 ++++++++--------- .../Commands/Internal/Designer/Begin/Tests.cs | 3 +- .../Internal/Designer/Cancel/Tests.cs | 3 +- .../Internal/Designer/Finish/Tests.cs | 3 +- .../Internal/Designer/Report/Tests.cs | 5 +- .../Customs/Data/Customs/TestData.cs | 1 + 23 files changed, 139 insertions(+), 175 deletions(-) diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs index 8da640e37..e0a624480 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs @@ -2,19 +2,18 @@ using CustomCADs.Modules.Accounts.Domain.Repositories; using CustomCADs.Modules.Accounts.Domain.Repositories.Writes; using CustomCADs.Shared.Application.Events.Catalog; -using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Catalog; namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application.Viewed; +using static Data.Accounts.TestData; + public class Tests : Data.Accounts.BaseUnitTests { private readonly UserViewedProductHandler handler; private readonly Mock writes = new(); private readonly Mock uow = new(); - private static readonly AccountId id = AccountId.New(); - private static readonly ProductId productId = ProductId.New(); private static readonly DateTimeOffset viewedAt = DateTimeOffset.UtcNow; public Tests() @@ -26,13 +25,13 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductViewedApplicationEvent @event = new(productId, id, viewedAt); + ProductViewedApplicationEvent @event = new(ValidProductId, ValidId, viewedAt); // Act await handler.HandleAsync(@event); // Assert - writes.Verify(x => x.ViewProductAsync(id, productId, viewedAt, ct), Times.Once()); + writes.Verify(x => x.ViewProductAsync(ValidId, ValidProductId, viewedAt, ct), Times.Once()); uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs index 2a6ad1c43..d6655664c 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs @@ -12,8 +12,6 @@ public class Tests : Data.Accounts.BaseUnitTests private readonly GetAccountViewedProductHandler handler; private readonly Mock reads = new(); - private static readonly ProductId productId = ProductId.New(); - public Tests() { handler = new(reads.Object); @@ -25,7 +23,7 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAccountViewedProductQuery query = new(ValidId, productId); + GetAccountViewedProductQuery query = new(ValidId, ValidProductId); // Act await handler.Handle(query, ct); @@ -43,9 +41,9 @@ public async Task Handle_ShouldReturnResult(bool expected) if (expected) { reads.Setup(x => x.ViewedProductsByIdAsync(ValidId, ct)) - .ReturnsAsync([productId]); + .ReturnsAsync([ValidProductId]); } - GetAccountViewedProductQuery query = new(ValidId, productId); + GetAccountViewedProductQuery query = new(ValidId, ValidProductId); // Act bool actual = await handler.Handle(query, ct); diff --git a/tests/UnitTests/Accounts/Data/Accounts/TestData.cs b/tests/UnitTests/Accounts/Data/Accounts/TestData.cs index bc231f3c6..11c0d3aff 100644 --- a/tests/UnitTests/Accounts/Data/Accounts/TestData.cs +++ b/tests/UnitTests/Accounts/Data/Accounts/TestData.cs @@ -1,6 +1,7 @@ using CustomCADs.Modules.Accounts.Domain.Accounts; using CustomCADs.Shared.Domain; using CustomCADs.Shared.Domain.TypedIds.Accounts; +using CustomCADs.Shared.Domain.TypedIds.Catalog; namespace CustomCADs.UnitTests.Accounts.Data.Accounts; @@ -38,4 +39,5 @@ public static class TestData public const string ValidRole = "role123"; public const string ValidPassword = "password123"; public static readonly AccountId ValidId = AccountId.New(); + public static readonly ProductId ValidProductId = ProductId.New(); } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs index b498e45df..03c5612dc 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs @@ -2,7 +2,6 @@ using CustomCADs.Modules.Carts.Domain.Repositories.Reads; using CustomCADs.Shared.Application.Abstractions.Requests.Sender; using CustomCADs.Shared.Application.Exceptions; -using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Catalog; namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.GetSingle; @@ -15,13 +14,11 @@ public class Tests : Data.ActiveCarts.BaseUnitTests private readonly Mock reads = new(); private readonly Mock sender = new(); - private static readonly AccountId newBuyerId = AccountId.New(); - public Tests() { handler = new(reads.Object, sender.Object); - reads.Setup(x => x.SingleAsync(newBuyerId, ValidProductId, false, ct)) + reads.Setup(x => x.SingleAsync(ValidBuyerId, ValidProductId, false, ct)) .ReturnsAsync(CreateItem()); } @@ -29,20 +26,20 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetActiveCartItemQuery query = new(newBuyerId, ValidProductId); + GetActiveCartItemQuery query = new(ValidBuyerId, ValidProductId); // Act await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleAsync(newBuyerId, ValidProductId, false, ct), Times.Once()); + reads.Verify(x => x.SingleAsync(ValidBuyerId, ValidProductId, false, ct), Times.Once()); } [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetActiveCartItemQuery query = new(newBuyerId, ValidProductId); + GetActiveCartItemQuery query = new(ValidBuyerId, ValidProductId); // Act var result = await handler.Handle(query, ct); @@ -55,7 +52,7 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenCartItemNotFound() { // Arrange - GetActiveCartItemQuery query = new(newBuyerId, ProductId.New()); + GetActiveCartItemQuery query = new(ValidBuyerId, ProductId.New()); // Assert await Assert.ThrowsAsync>( @@ -68,7 +65,7 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenCartNotFound() { // Arrange - GetActiveCartItemQuery query = new(newBuyerId, ProductId.New()); + GetActiveCartItemQuery query = new(ValidBuyerId, ProductId.New()); // Assert await Assert.ThrowsAsync>( diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs index a13200193..60f6a9148 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs @@ -25,7 +25,6 @@ public class Tests : Data.PurchasedCarts.BaseUnitTests private readonly Mock sender = new(); private readonly Mock raiser = new(); - private static readonly AccountId buyerId = AccountId.New(); private static readonly Dictionary items = []; private static readonly ProductId[] productIds = [.. items.Keys.Select(x => x.ProductId)]; private static readonly Dictionary cads = []; @@ -36,12 +35,12 @@ public Tests() handler = new(writes.Object, uow.Object, sender.Object, raiser.Object); writes.Setup(x => x.AddAsync( - It.Is(x => x.BuyerId == buyerId), + It.Is(x => x.BuyerId == ValidBuyerId), ct )).ReturnsAsync(CreateCart(id: ValidId)); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Id == buyerId), + It.Is(x => x.Id == ValidBuyerId), ct )).ReturnsAsync(true); @@ -61,7 +60,7 @@ public async Task Handle_ShouldPersistToDatabase() { // Arrange CreatePurchasedCartCommand command = new( - BuyerId: buyerId, + BuyerId: ValidBuyerId, Items: items ); @@ -70,7 +69,7 @@ public async Task Handle_ShouldPersistToDatabase() // Assert writes.Verify(x => x.AddAsync( - It.Is(x => x.BuyerId == buyerId), + It.Is(x => x.BuyerId == ValidBuyerId), ct ), Times.Once()); uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); @@ -81,7 +80,7 @@ public async Task Handle_ShouldSendRequests() { // Arrange CreatePurchasedCartCommand command = new( - BuyerId: buyerId, + BuyerId: ValidBuyerId, Items: items ); @@ -90,7 +89,7 @@ public async Task Handle_ShouldSendRequests() // Assert sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == buyerId), + It.Is(x => x.Id == ValidBuyerId), ct ), Times.Once()); sender.Verify(x => x.SendQueryAsync( @@ -108,7 +107,7 @@ public async Task Handle_ShouldRaiseEvents() { // Arrange CreatePurchasedCartCommand command = new( - BuyerId: buyerId, + BuyerId: ValidBuyerId, Items: items ); @@ -126,7 +125,7 @@ public async Task Handle_ShouldReturnResult() { // Arrange CreatePurchasedCartCommand command = new( - BuyerId: buyerId, + BuyerId: ValidBuyerId, Items: items ); @@ -147,7 +146,7 @@ public async Task Handle_ShouldThrowException_WhenPurchasedCartNotFound() )).ReturnsAsync(false); CreatePurchasedCartCommand command = new( - BuyerId: buyerId, + BuyerId: ValidBuyerId, Items: items ); diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs index 2be438cb7..c57b0abf4 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs @@ -7,7 +7,6 @@ using CustomCADs.Shared.Application.Events.Notifications; using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -using CustomCADs.Shared.Domain.TypedIds.Accounts; namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Admin.Remove; @@ -21,8 +20,6 @@ public class Tests : Data.Products.BaseUnitTests private readonly Mock sender = new(); private readonly Mock raiser = new(); - private readonly AccountId AdminId = AccountId.New(); - public Tests() { handler = new(reads.Object, uow.Object, sender.Object, raiser.Object); @@ -31,7 +28,7 @@ public Tests() .ReturnsAsync(CreateProduct().Report(ValidDesignerId)); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Id == AdminId), + It.Is(x => x.Id == ValidAdminId), ct )).ReturnsAsync(true); } @@ -40,7 +37,7 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - RemoveProductCommand command = new(ValidId, AdminId); + RemoveProductCommand command = new(ValidId, ValidAdminId); // Act await handler.Handle(command, ct); @@ -53,7 +50,7 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - RemoveProductCommand command = new(ValidId, AdminId); + RemoveProductCommand command = new(ValidId, ValidAdminId); // Act await handler.Handle(command, ct); @@ -66,14 +63,14 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - RemoveProductCommand command = new(ValidId, AdminId); + RemoveProductCommand command = new(ValidId, ValidAdminId); // Act await handler.Handle(command, ct); // Assert sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == AdminId), + It.Is(x => x.Id == ValidAdminId), ct ), Times.Once()); } @@ -82,7 +79,7 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - RemoveProductCommand command = new(ValidId, AdminId); + RemoveProductCommand command = new(ValidId, ValidAdminId); // Act await handler.Handle(command, ct); @@ -100,10 +97,10 @@ public async Task Handle_ShouldThrowException_WhenAdminNotFound() { // Arrange sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Id == AdminId), + It.Is(x => x.Id == ValidAdminId), ct )).ReturnsAsync(false); - RemoveProductCommand command = new(ValidId, AdminId); + RemoveProductCommand command = new(ValidId, ValidAdminId); // Assert await Assert.ThrowsAsync>( @@ -118,7 +115,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Product); - RemoveProductCommand command = new(ValidId, AdminId); + RemoveProductCommand command = new(ValidId, ValidAdminId); // Assert await Assert.ThrowsAsync>( diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs index d53bd4987..7dd6f0494 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs @@ -6,7 +6,6 @@ using CustomCADs.Shared.Application.Dtos.Notifications; using CustomCADs.Shared.Application.Events.Notifications; using CustomCADs.Shared.Application.Exceptions; -using CustomCADs.Shared.Domain.TypedIds.Accounts; namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Designer.AddTag; @@ -20,41 +19,37 @@ public class Tests : Data.Products.BaseUnitTests private readonly Mock uow = new(); private readonly Mock raiser = new(); - private readonly static ProductId id = ValidId; - private readonly static TagId tagId = TagId.New(); - private readonly static AccountId callerId = AccountId.New(); - public Tests() { handler = new(reads.Object, writes.Object, uow.Object, raiser.Object); - reads.Setup(x => x.SingleByIdAsync(id, false, ct)).ReturnsAsync(CreateProduct()); + reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(CreateProduct()); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - AddProductTagCommand command = new(id, tagId, callerId); + AddProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(id, false, ct), Times.Once()); + reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); } [Fact] public async Task Handle_ShouldPersistToDatabase() { // Arrange - AddProductTagCommand command = new(id, tagId, callerId); + AddProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddTagAsync(id, tagId, ct), Times.Once()); + writes.Verify(x => x.AddTagAsync(ValidId, ValidTagId, ct), Times.Once()); uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); } @@ -62,7 +57,7 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - AddProductTagCommand command = new(id, tagId, callerId); + AddProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act await handler.Handle(command, ct); @@ -77,8 +72,8 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldThrow_WhenProductNotFound() { // Arrange - reads.Setup(x => x.SingleByIdAsync(id, false, ct)).ReturnsAsync(null as Product); - AddProductTagCommand command = new(id, tagId, callerId); + reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Product); + AddProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Assert await Assert.ThrowsAsync>( diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs index 41bb320f3..7acd16812 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs @@ -6,7 +6,6 @@ using CustomCADs.Shared.Application.Dtos.Notifications; using CustomCADs.Shared.Application.Events.Notifications; using CustomCADs.Shared.Application.Exceptions; -using CustomCADs.Shared.Domain.TypedIds.Accounts; namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Designer.RemoveTag; @@ -20,41 +19,37 @@ public class Tests : Data.Products.BaseUnitTests private readonly Mock uow = new(); private readonly Mock raiser = new(); - private readonly static ProductId id = ValidId; - private readonly static TagId tagId = TagId.New(); - private readonly static AccountId callerId = AccountId.New(); - public Tests() { handler = new(reads.Object, writes.Object, uow.Object, raiser.Object); - reads.Setup(x => x.SingleByIdAsync(id, false, ct)).ReturnsAsync(CreateProduct()); + reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(CreateProduct()); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - RemoveProductTagCommand command = new(id, tagId, callerId); + RemoveProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(id, false, ct), Times.Once()); + reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); } [Fact] public async Task Handle_ShouldPersistToDatabase() { // Arrange - RemoveProductTagCommand command = new(id, tagId, callerId); + RemoveProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act await handler.Handle(command, ct); // Assert - writes.Verify(x => x.RemoveTagAsync(id, tagId), Times.Once()); + writes.Verify(x => x.RemoveTagAsync(ValidId, ValidTagId), Times.Once()); uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); } @@ -62,7 +57,7 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - RemoveProductTagCommand command = new(id, tagId, callerId); + RemoveProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act await handler.Handle(command, ct); @@ -77,8 +72,8 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldThrow_WhenProductNotFound() { // Arrange - reads.Setup(x => x.SingleByIdAsync(id, false, ct)).ReturnsAsync(null as Product); - RemoveProductTagCommand command = new(id, tagId, callerId); + reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Product); + RemoveProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Assert await Assert.ThrowsAsync>( diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs index 59c84fe3c..8c7bfdd8c 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs @@ -4,13 +4,13 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.GetExists; +using static Data.Products.TestData; + public class Tests : Data.Products.BaseUnitTests { private readonly GetProductExistsByIdHandler handler; private readonly Mock reads = new(); - private static readonly ProductId id = new(); - public Tests() { handler = new(reads.Object); @@ -20,14 +20,14 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - reads.Setup(x => x.ExistsByIdAsync(id, ct)).ReturnsAsync(true); - GetProductExistsByIdQuery query = new(id); + reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)).ReturnsAsync(true); + GetProductExistsByIdQuery query = new(ValidId); // Act await handler.Handle(query, ct); // Assert - reads.Verify(x => x.ExistsByIdAsync(id, ct), Times.Once()); + reads.Verify(x => x.ExistsByIdAsync(ValidId, ct), Times.Once()); } [Theory] @@ -36,8 +36,8 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult(bool exists) { // Arrange - reads.Setup(x => x.ExistsByIdAsync(id, ct)).ReturnsAsync(exists); - GetProductExistsByIdQuery query = new(id); + reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)).ReturnsAsync(exists); + GetProductExistsByIdQuery query = new(ValidId); // Act bool result = await handler.Handle(query, ct); diff --git a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs index 24af1973b..79d0a8205 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs @@ -11,14 +11,12 @@ public class Tests : Data.Tags.BaseUnitTests private readonly Mock reads = new(); private readonly Mock> cache = new(); - private readonly static TagId id = ValidId; - public Tests() { handler = new(reads.Object, cache.Object); cache.Setup(x => x.GetOrCreateAsync( - id, + ValidId, It.IsAny>>() )).ReturnsAsync(CreateTag()); } @@ -27,14 +25,14 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - GetTagByIdQuery query = new(id); + GetTagByIdQuery query = new(ValidId); // Act await handler.Handle(query, ct); // Assert cache.Verify( - x => x.GetOrCreateAsync(id, It.IsAny>>()), + x => x.GetOrCreateAsync(ValidId, It.IsAny>>()), Times.Once() ); } @@ -43,12 +41,12 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - GetTagByIdQuery query = new(id); + GetTagByIdQuery query = new(ValidId); // Act var result = await handler.Handle(query, ct); // Assert - Assert.Equal(ValidId, result.Id); + Assert.Equal(Data.Tags.TestData.ValidId, result.Id); } } diff --git a/tests/UnitTests/Catalog/Data/Products/TestData.cs b/tests/UnitTests/Catalog/Data/Products/TestData.cs index ce606474c..4e4fa1e55 100644 --- a/tests/UnitTests/Catalog/Data/Products/TestData.cs +++ b/tests/UnitTests/Catalog/Data/Products/TestData.cs @@ -27,7 +27,9 @@ public static class TestData public static readonly ProductId ValidId = ProductId.New(); public static readonly AccountId ValidCreatorId = AccountId.New(); public static readonly AccountId ValidDesignerId = AccountId.New(); + public static readonly AccountId ValidAdminId = AccountId.New(); public static readonly CategoryId ValidCategoryId = CategoryId.New(); public static readonly ImageId ValidImageId = ImageId.New(); public static readonly CadId ValidCadId = CadId.New(); + public static readonly TagId ValidTagId = TagId.New(); } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs index ee100634e..26781e493 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs @@ -6,7 +6,6 @@ using CustomCADs.Shared.Application.Dtos.Notifications; using CustomCADs.Shared.Application.Events.Notifications; using CustomCADs.Shared.Application.Exceptions; -using CustomCADs.Shared.Domain.TypedIds.Accounts; namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Admin.Remove; @@ -19,7 +18,6 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock uow = new(); private readonly Mock raiser = new(); - private static readonly AccountId adminId = AccountId.New(); private readonly Custom custom = CreateCustom(); public Tests() @@ -37,7 +35,7 @@ public async Task Handle_ShouldQueryDatabase() // Arrange RemoveCustomCommand command = new( Id: ValidId, - CallerId: adminId + CallerId: ValidAdminId ); // Act @@ -53,7 +51,7 @@ public async Task Handle_ShouldPersistToDatabase() // Arrange RemoveCustomCommand command = new( Id: ValidId, - CallerId: adminId + CallerId: ValidAdminId ); // Act @@ -69,7 +67,7 @@ public async Task Handle_ShouldRaiseEvents() // Arrange RemoveCustomCommand command = new( Id: ValidId, - CallerId: adminId + CallerId: ValidAdminId ); // Act @@ -87,7 +85,7 @@ public async Task Handle_ShouldPopulateProperties() // Arrange RemoveCustomCommand command = new( Id: ValidId, - CallerId: adminId + CallerId: ValidAdminId ); // Act @@ -106,7 +104,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() RemoveCustomCommand command = new( Id: ValidId, - CallerId: adminId + CallerId: ValidAdminId ); // Assert diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs index fefde5765..ea65f3873 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs @@ -18,15 +18,13 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock uow = new(); private readonly Mock raiser = new(); - private static readonly CustomId id = CustomId.New(); - private static readonly AccountId buyerId = AccountId.New(); - private readonly Custom custom = CreateCustom(id: id, buyerId: buyerId); + private readonly Custom custom = CreateCustom(); public Tests() { handler = new(reads.Object, writes.Object, uow.Object, raiser.Object); - reads.Setup(x => x.SingleByIdAsync(id, true, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); } @@ -35,15 +33,15 @@ public async Task Handle_ShouldQueryDatabase() { // Arrange DeleteCustomCommand command = new( - Id: id, - CallerId: buyerId + Id: ValidId, + CallerId: ValidBuyerId ); // Act await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(id, true, ct), Times.Once()); + reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); } [Fact] @@ -51,8 +49,8 @@ public async Task Handle_ShouldPersistToDatabase() { // Arrange DeleteCustomCommand command = new( - Id: id, - CallerId: buyerId + Id: ValidId, + CallerId: ValidBuyerId ); // Act @@ -60,7 +58,7 @@ public async Task Handle_ShouldPersistToDatabase() // Assert writes.Verify(x => x.Remove( - It.Is(x => x.Id == id) + It.Is(x => x.Id == ValidId) ), Times.Once()); uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); } @@ -77,8 +75,8 @@ public async Task Handle_ShouldRaiseEvents(bool isPending) } DeleteCustomCommand command = new( - Id: id, - CallerId: buyerId + Id: ValidId, + CallerId: ValidBuyerId ); // Act diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs index dcd6844a7..a67315ab3 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs @@ -17,15 +17,13 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock uow = new(); private readonly Mock raiser = new(); - private static readonly CustomId id = CustomId.New(); - private static readonly AccountId buyerId = AccountId.New(); - private readonly Custom custom = CreateCustom(buyerId: buyerId); + private readonly Custom custom = CreateCustom(); public Tests() { handler = new(reads.Object, uow.Object, raiser.Object); - reads.Setup(x => x.SingleByIdAsync(id, true, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); } @@ -34,18 +32,18 @@ public async Task Handle_ShouldQueryDatabase() { // Arrange EditCustomCommand command = new( - Id: id, + Id: ValidId, Name: MaxValidName, Description: MaxValidDescription, CategoryId: ValidCategoryId, - CallerId: buyerId + CallerId: ValidBuyerId ); // Act await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(id, true, ct), Times.Once()); + reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); } [Fact] @@ -53,11 +51,11 @@ public async Task Handle_ShouldPersistToDatabase() { // Arrange EditCustomCommand command = new( - Id: id, + Id: ValidId, Name: MaxValidName, Description: MaxValidDescription, CategoryId: ValidCategoryId, - CallerId: buyerId + CallerId: ValidBuyerId ); // Act @@ -79,11 +77,11 @@ public async Task Handle_ShouldRaiseEvents(bool isPending) } EditCustomCommand command = new( - Id: id, + Id: ValidId, Name: MaxValidName, Description: MaxValidDescription, CategoryId: ValidCategoryId, - CallerId: buyerId + CallerId: ValidBuyerId ); // Act diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs index fb3f4022e..2e8254914 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs @@ -25,7 +25,6 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock raiser = new(); private const string PaymentMethodId = "payment-method-id"; - private static readonly AccountId buyerId = AccountId.New(); private readonly Custom custom = CreateCustom( buyerId: ValidBuyerId ); @@ -135,7 +134,7 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange - PurchaseCustomCommand command = new(ValidId, string.Empty, buyerId); + PurchaseCustomCommand command = new(ValidId, string.Empty, AccountId.New()); // Assert await Assert.ThrowsAsync>( diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs index 846438cb9..d037d17d7 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs @@ -27,7 +27,6 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock payment = new(); private readonly Mock raiser = new(); - private static readonly AccountId buyerId = AccountId.New(); private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); private static readonly ContactDto contact = new(null, null); private readonly Custom custom = CreateCustom(forDelivery: true); @@ -207,7 +206,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() CustomizationId: ValidCustomizationId, PaymentMethodId: string.Empty, ShipmentService: string.Empty, - CallerId: buyerId, + CallerId: AccountId.New(), Address: address, Contact: contact ); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs index 1e66938c7..de37a70f6 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs @@ -1,28 +1,24 @@ using CustomCADs.Modules.Customs.Application.Customs.Commands.Internal.Customers.Purchase.WithDelivery; -using CustomCADs.Shared.Domain.TypedIds.Accounts; -using CustomCADs.Shared.Domain.TypedIds.Printing; using FluentValidation.TestHelper; namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Purchase.WithDelivery; +using static Data.Customs.TestData; + public class Validator : Data.Customs.BaseUnitTests { private readonly PurchaseCustomWithDeliveryValidator validator = new(); - private static readonly CustomId id = CustomId.New(); - private static readonly AccountId buyerId = AccountId.New(); - private static readonly CustomizationId customizationId = CustomizationId.New(); - [Theory] [ClassData(typeof(ValidData))] public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange PurchaseCustomWithDeliveryCommand command = new( - Id: id, + Id: ValidId, PaymentMethodId: paymentMethodId, - CallerId: buyerId, - CustomizationId: customizationId, + CallerId: ValidBuyerId, + CustomizationId: ValidCustomizationId, Count: count, ShipmentService: shipmentService, Address: new(country, city, street), @@ -46,10 +42,10 @@ public async Task Validate_ShouldBeInvalid_WhenCartIsNotValid(string paymentMeth { // Arrange PurchaseCustomWithDeliveryCommand command = new( - Id: id, + Id: ValidId, PaymentMethodId: paymentMethodId, - CallerId: buyerId, - CustomizationId: customizationId, + CallerId: ValidBuyerId, + CustomizationId: ValidCustomizationId, Count: count, ShipmentService: shipmentService, Address: new(country, city, street), @@ -69,10 +65,10 @@ public async Task Validate_ShouldReturnProperErrors_WhenShipmentServiceIsNotVali { // Arrange PurchaseCustomWithDeliveryCommand command = new( - Id: id, + Id: ValidId, PaymentMethodId: paymentMethodId, - CallerId: buyerId, - CustomizationId: customizationId, + CallerId: ValidBuyerId, + CustomizationId: ValidCustomizationId, Count: count, ShipmentService: shipmentService, Address: new(country, city, street), @@ -92,10 +88,10 @@ public async Task Validate_ShouldReturnProperErrors_WhenCountryIsNotValid(string { // Arrange PurchaseCustomWithDeliveryCommand command = new( - Id: id, + Id: ValidId, PaymentMethodId: paymentMethodId, - CallerId: buyerId, - CustomizationId: customizationId, + CallerId: ValidBuyerId, + CustomizationId: ValidCustomizationId, Count: count, ShipmentService: shipmentService, Address: new(country, city, street), @@ -115,10 +111,10 @@ public async Task Validate_ShouldReturnProperErrors_WhenCityIsNotValid(string pa { // Arrange PurchaseCustomWithDeliveryCommand command = new( - Id: id, + Id: ValidId, PaymentMethodId: paymentMethodId, - CallerId: buyerId, - CustomizationId: customizationId, + CallerId: ValidBuyerId, + CustomizationId: ValidCustomizationId, Count: count, ShipmentService: shipmentService, Address: new(country, city, street), @@ -138,10 +134,10 @@ public async Task Validate_ShouldReturnProperErrors_WhenPhoneIsNotValid(string p { // Arrange PurchaseCustomWithDeliveryCommand command = new( - Id: id, + Id: ValidId, PaymentMethodId: paymentMethodId, - CallerId: buyerId, - CustomizationId: customizationId, + CallerId: ValidBuyerId, + CustomizationId: ValidCustomizationId, Count: count, ShipmentService: shipmentService, Address: new(country, city, street), @@ -161,10 +157,10 @@ public async Task Validate_ShouldReturnProperErrors_WhenEmailIsNotValid(string p { // Arrange PurchaseCustomWithDeliveryCommand command = new( - Id: id, + Id: ValidId, PaymentMethodId: paymentMethodId, - CallerId: buyerId, - CustomizationId: customizationId, + CallerId: ValidBuyerId, + CustomizationId: ValidCustomizationId, Count: count, ShipmentService: shipmentService, Address: new(country, city, street), diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs index faf9f09bf..b58ef0a44 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs @@ -5,7 +5,6 @@ using CustomCADs.Shared.Application.Dtos.Notifications; using CustomCADs.Shared.Application.Events.Notifications; using CustomCADs.Shared.Application.Exceptions; -using CustomCADs.Shared.Domain.TypedIds.Accounts; namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.SetDelivery; @@ -18,16 +17,14 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock uow = new(); private readonly Mock raiser = new(); - private static readonly CustomId id = CustomId.New(); - private static readonly bool value = true; - private static readonly AccountId buyerId = AccountId.New(); - private readonly Custom custom = CreateCustom(forDelivery: !value); + private static readonly bool NewValue = true; + private readonly Custom custom = CreateCustom(forDelivery: !NewValue); public Tests() { handler = new(reads.Object, uow.Object, raiser.Object); - reads.Setup(x => x.SingleByIdAsync(id, true, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); } @@ -36,16 +33,16 @@ public async Task Handle_ShouldQueryDatabase() { // Arrange SetCustomDeliveryCommand command = new( - Id: id, - Value: value, - BuyerId: buyerId + Id: ValidId, + Value: NewValue, + BuyerId: ValidBuyerId ); // Act await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(id, true, ct), Times.Once()); + reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); } [Fact] @@ -53,9 +50,9 @@ public async Task Handle_ShouldPersistToDatabase() { // Arrange SetCustomDeliveryCommand command = new( - Id: id, - Value: value, - BuyerId: buyerId + Id: ValidId, + Value: NewValue, + BuyerId: ValidBuyerId ); // Act @@ -77,9 +74,9 @@ public async Task Handle_ShouldRaiseEvents(bool isPending) } SetCustomDeliveryCommand command = new( - Id: id, - Value: value, - BuyerId: buyerId + Id: ValidId, + Value: NewValue, + BuyerId: ValidBuyerId ); // Act @@ -96,29 +93,29 @@ public async Task Handle_ShouldPopulateProperties() { // Arrange SetCustomDeliveryCommand command = new( - Id: id, - Value: value, - BuyerId: buyerId + Id: ValidId, + Value: NewValue, + BuyerId: ValidBuyerId ); // Act await handler.Handle(command, ct); // Assert - Assert.Equal(value, custom.ForDelivery); + Assert.Equal(NewValue, custom.ForDelivery); } [Fact] public async Task Handle_ShouldThrowException_WhenCustomNotFound() { // Arrange - reads.Setup(x => x.SingleByIdAsync(id, true, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); SetCustomDeliveryCommand command = new( - Id: id, - Value: value, - BuyerId: buyerId + Id: ValidId, + Value: NewValue, + BuyerId: ValidBuyerId ); // Assert diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs index 621f526d2..0bdd96e06 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs @@ -19,7 +19,6 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock uow = new(); private readonly Mock raiser = new(); - private static readonly AccountId designerId = AccountId.New(); private readonly Custom custom = CreateCustom(); public Tests() @@ -105,7 +104,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange var custom = CreateCustom(); - custom.Accept(designerId); + custom.Accept(AccountId.New()); reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs index d008e4dd7..d50a20c05 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs @@ -19,7 +19,6 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock uow = new(); private readonly Mock raiser = new(); - private static readonly AccountId designerId = AccountId.New(); private readonly Custom custom = CreateCustom(); public Tests() @@ -105,7 +104,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange var custom = CreateCustom(); - custom.Accept(designerId); + custom.Accept(AccountId.New()); reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs index 195ff420b..d1e6688fc 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs @@ -22,7 +22,6 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock sender = new(); private readonly Mock raiser = new(); - private static readonly AccountId designerId = AccountId.New(); private readonly Custom custom = CreateCustom(); public Tests() @@ -143,7 +142,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange var custom = CreateCustom(); - custom.Accept(designerId); + custom.Accept(AccountId.New()); reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs index 3f105b436..f3f95e569 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs @@ -22,7 +22,6 @@ public class Tests : Data.Customs.BaseUnitTests private readonly Mock sender = new(); private readonly Mock raiser = new(); - private static readonly AccountId designerId = AccountId.New(); private readonly Custom custom = CreateCustom(); public Tests() @@ -128,7 +127,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Arrange ReportCustomCommand command = new( Id: ValidId, - CallerId: designerId + CallerId: AccountId.New() ); // Assert @@ -145,7 +144,7 @@ public async Task Handle_ShouldNotThrowException_WhenUnauthorizedAccessButPendin custom.Cancel(); ReportCustomCommand command = new( Id: ValidId, - CallerId: designerId + CallerId: AccountId.New() ); // Assert diff --git a/tests/UnitTests/Customs/Data/Customs/TestData.cs b/tests/UnitTests/Customs/Data/Customs/TestData.cs index 7a9e22544..e87e700a0 100644 --- a/tests/UnitTests/Customs/Data/Customs/TestData.cs +++ b/tests/UnitTests/Customs/Data/Customs/TestData.cs @@ -30,6 +30,7 @@ public static class TestData public static readonly CustomId ValidId = CustomId.New(); public static readonly AccountId ValidBuyerId = AccountId.New(); public static readonly AccountId ValidDesignerId = AccountId.New(); + public static readonly AccountId ValidAdminId = AccountId.New(); public static readonly CategoryId ValidCategoryId = CategoryId.New(); public static readonly CadId ValidCadId = CadId.New(); public static readonly ShipmentId ValidShipmentId = ShipmentId.New(); From 14f111b81e7e8876ce97f7c7fde431e2e7f928e4 Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Thu, 21 May 2026 01:56:42 +0300 Subject: [PATCH 07/15] Normalized `Verify`/`Times` indentation --- .../Commands/Internal/Create/Tests.cs | 45 +++--- .../Commands/Internal/Delete/Tests.cs | 24 +++- .../Accounts/Commands/Shared/Create/Tests.cs | 26 ++-- .../Events/Application/Deleted/Tests.cs | 15 +- .../Events/Application/Edited/Tests.cs | 10 +- .../Events/Application/Viewed/Tests.cs | 10 +- .../Accounts/Queries/Internal/GetAll/Tests.cs | 5 +- .../Queries/Internal/GetById/Tests.cs | 5 +- .../Accounts/Queries/Shared/GetEmail/Tests.cs | 5 +- .../Queries/Shared/GetExists/ById/Tests.cs | 5 +- .../Shared/GetExists/ByUsername/Tests.cs | 5 +- .../Accounts/Queries/Shared/GetInfo/Tests.cs | 5 +- .../Queries/Shared/GetUserRole/Tests.cs | 5 +- .../Queries/Shared/GetUsername/Batch/Tests.cs | 5 +- .../Shared/GetUsername/Single/Tests.cs | 5 +- .../Shared/ViewedProducts/ById/Tests.cs | 5 +- .../Shared/ViewedProducts/ByName/Tests.cs | 5 +- .../Roles/Commands/Internal/Create/Tests.cs | 30 ++-- .../Roles/Commands/Internal/Delete/Tests.cs | 28 ++-- .../Roles/Queries/Internal/GetAll/Tests.cs | 6 +- .../Roles/Queries/Internal/GetById/Tests.cs | 11 +- .../Commands/Internal/Add/Tests.cs | 27 ++-- .../Internal/Purchase/Normal/Tests.cs | 80 +++++++---- .../Internal/Purchase/WithDelivery/Tests.cs | 111 +++++++++------ .../Internal/Quantity/Decrease/Tests.cs | 10 +- .../Internal/Quantity/Increase/Tests.cs | 10 +- .../Commands/Internal/Remove/Tests.cs | 10 +- .../Internal/ToggleForDelivery/Tests.cs | 37 +++-- .../Application/ProductDeleted/Tests.cs | 5 +- .../Internal/CalculateShipment/Tests.cs | 27 ++-- .../Queries/Internal/Count/Tests.cs | 5 +- .../Queries/Internal/GetAll/Tests.cs | 16 ++- .../Queries/Internal/GetSingle/Tests.cs | 5 +- .../Commands/Internal/Create/Tests.cs | 58 +++++--- .../Application/DeliveryRequested/Tests.cs | 27 ++-- ...mpletedApplicationEventHandlerUnitTests.cs | 63 ++++++--- .../Queries/Internal/Count/Carts/Tests.cs | 5 +- .../Queries/Internal/Count/Items/Tests.cs | 5 +- .../Queries/Internal/GetAll/Tests.cs | 5 +- .../Queries/Internal/GetById/Tests.cs | 15 +- .../Commands/Internal/Create/Tests.cs | 29 ++-- .../Commands/Internal/Delete/Tests.cs | 26 +++- .../Commands/Internal/Edit/Tests.cs | 23 ++- .../Queries/Internal/GetAll/Tests.cs | 9 +- .../Queries/Internal/GetById/Tests.cs | 4 +- .../Queries/Shared/BatchGetById/Tests.cs | 5 +- .../Queries/Shared/GetById/Tests.cs | 7 +- .../Queries/Shared/GetExists/Tests.cs | 5 +- .../Commands/Internal/Admin/Remove/Tests.cs | 34 +++-- .../Commands/Internal/Creator/Create/Tests.cs | 132 +++++++++++------- .../Commands/Internal/Creator/Delete/Tests.cs | 44 ++++-- .../Commands/Internal/Creator/Edit/Tests.cs | 41 ++++-- .../Internal/Designer/AddTag/Tests.cs | 24 +++- .../Internal/Designer/RemoveTag/Tests.cs | 24 +++- .../Internal/Designer/Report/Tests.cs | 45 ++++-- .../Internal/Designer/Validate/Tests.cs | 45 ++++-- .../Events/Application/Created/Tests.cs | 5 +- .../Events/Application/Purchased/Tests.cs | 5 +- .../Events/Application/Viewed/Tests.cs | 101 ++++++++++---- .../Queries/Internal/Creator/Count/Tests.cs | 5 +- .../Queries/Internal/Creator/GetAll/Tests.cs | 24 ++-- .../Queries/Internal/Creator/GetById/Tests.cs | 27 ++-- .../Queries/Internal/Designer/GetAll/Tests.cs | 35 +++-- .../Internal/Designer/GetById/Tests.cs | 27 ++-- .../Queries/Internal/Gallery/GetAll/Tests.cs | 35 +++-- .../Queries/Internal/Gallery/GetById/Tests.cs | 36 +++-- .../Queries/Shared/BatchCadIdById/Tests.cs | 5 +- .../Queries/Shared/BatchPriceById/Tests.cs | 5 +- .../Queries/Shared/GetExists/Tests.cs | 5 +- .../Tags/Commands/Internal/Create/Tests.cs | 18 ++- .../Tags/Commands/Internal/Delete/Tests.cs | 15 +- .../Tags/Commands/Internal/Edit/Tests.cs | 15 +- .../Commands/Internal/Admin/Remove/Tests.cs | 19 ++- .../Internal/Admin/SetCategory/Tests.cs | 10 +- .../Internal/Customer/Create/Tests.cs | 55 +++++--- .../Internal/Customer/Delete/Tests.cs | 28 ++-- .../Commands/Internal/Customer/Edit/Tests.cs | 19 ++- .../Customer/Purchase/Normal/Tests.cs | 53 ++++--- .../Customer/Purchase/WithDelivery/Tests.cs | 81 +++++++---- .../Internal/Customer/SetDelivery/Tests.cs | 19 ++- .../Internal/Designer/Accept/Tests.cs | 41 ++++-- .../Commands/Internal/Designer/Begin/Tests.cs | 19 ++- .../Internal/Designer/Cancel/Tests.cs | 19 ++- .../Internal/Designer/Finish/Tests.cs | 30 ++-- .../Internal/Designer/Report/Tests.cs | 30 ++-- .../Internal/Designer/SetCategory/Tests.cs | 10 +- .../Application/DeliveryRequested/Tests.cs | 32 +++-- .../Application/PaymentCompleted/Tests.cs | 69 +++++---- .../Customers/CalculateShipment/Tests.cs | 27 ++-- .../Queries/Internal/Customers/Count/Tests.cs | 5 +- .../Internal/Customers/GetById/Tests.cs | 49 ++++--- .../Internal/Designers/GetById/Tests.cs | 38 +++-- .../Queries/Internal/Shared/GetAll/Tests.cs | 38 +++-- .../Commands/Internal/Cancel/Tests.cs | 5 +- .../Shipments/Commands/Shared/Create/Tests.cs | 27 ++-- .../Queries/Internal/GetTrack/Tests.cs | 5 +- .../Queries/Internal/GetWaybill/Tests.cs | 5 +- .../Queries/Shared/Calculate/Tests.cs | 19 +-- .../Cads/Commands/Internal/Create/Tests.cs | 16 ++- .../Cads/Commands/Internal/Edit/Tests.cs | 10 +- .../Cads/Commands/Internal/SetCoords/Tests.cs | 10 +- .../Shared/BatchDuplicateById/Tests.cs | 15 +- .../Cads/Events/Application/Tests.cs | 20 ++- .../Internal/PresignedUrls/Get/Tests.cs | 5 +- .../Internal/PresignedUrls/Post/Tests.cs | 5 +- .../Internal/PresignedUrls/Put/Tests.cs | 5 +- .../Cads/Queries/Shared/Exists/Tests.cs | 5 +- .../Cads/Queries/Shared/IsPrintable/Tests.cs | 11 +- .../Images/Commands/Internal/Create/Tests.cs | 16 ++- .../Images/Commands/Internal/Edit/Tests.cs | 10 +- .../Images/Events/Application/Tests.cs | 20 ++- .../Internal/PresignedUrls/Get/Tests.cs | 5 +- .../Internal/PresignedUrls/Post/Tests.cs | 5 +- .../Internal/PresignedUrls/Put/Tests.cs | 5 +- .../Commands/Internal/Complete/Tests.cs | 20 ++- .../Commands/Internal/Create/Tests.cs | 20 ++- .../Commands/Internal/Delete/Tests.cs | 25 ++-- .../Queries/Internal/Get/Tests.cs | 15 +- .../Commands/Internal/ChangeUsername/Tests.cs | 25 ++-- .../Users/Commands/Internal/Delete/Tests.cs | 14 +- .../Users/Commands/Internal/Login/Tests.cs | 29 +++- .../Users/Commands/Internal/Logout/Tests.cs | 5 +- .../Users/Commands/Internal/Refresh/Tests.cs | 10 +- .../Users/Commands/Internal/Register/Tests.cs | 36 +++-- .../Commands/Internal/ResetPassword/Tests.cs | 5 +- .../Internal/ResetPasswordEmail/Tests.cs | 24 ++-- .../Users/Commands/Internal/SSO/Tests.cs | 76 +++++++--- .../ToggleViewedProductsTracking/Tests.cs | 26 ++-- .../Internal/VerificationEmail/Tests.cs | 23 ++- .../Commands/Internal/VerifyEmail/Tests.cs | 24 +++- .../Emails/EmailVerification/Tests.cs | 5 +- .../Application/Emails/PasswordReset/Tests.cs | 5 +- .../Events/Application/Roles/Created/Tests.cs | 5 +- .../Events/Application/Roles/Deleted/Tests.cs | 5 +- .../Events/Application/Users/Created/Tests.cs | 19 +-- .../Events/Application/Users/Deleted/Tests.cs | 5 +- .../Queries/Internal/GetByUsername/Tests.cs | 27 ++-- .../Commands/Internal/Hide/Tests.cs | 10 +- .../Commands/Internal/Open/Tests.cs | 10 +- .../Commands/Internal/Read/Tests.cs | 10 +- ...nRequestedHandlerUnitTests.cs => Tests.cs} | 61 +++++--- .../Queries/Internal/Count/Tests.cs | 5 +- .../Queries/Internal/GetAll/Tests.cs | 24 ++-- .../Commands/Internal/Create/Tests.cs | 26 ++-- .../Commands/Internal/Delete/Tests.cs | 15 +- .../Commands/Internal/Edit/Tests.cs | 10 +- .../Queries/Internal/GetById/Tests.cs | 28 ++-- .../Queries/Shared/Cost/Batch/Tests.cs | 21 ++- .../Queries/Shared/Cost/Single/Tests.cs | 19 ++- .../Queries/Shared/Exists/Tests.cs | 5 +- .../Queries/Shared/Weight/Batch/Tests.cs | 25 ++-- .../Queries/Shared/Weight/Single/Tests.cs | 23 ++- .../Commands/Internal/Create/Tests.cs | 26 +++- .../Commands/Internal/Delete/Tests.cs | 20 ++- .../Materials/Commands/Internal/Edit/Tests.cs | 15 +- .../Queries/Internal/GetAll/Tests.cs | 5 +- .../Queries/Internal/GetById/Tests.cs | 5 +- 157 files changed, 2322 insertions(+), 1045 deletions(-) rename tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/{NotificationRequestedHandlerUnitTests.cs => Tests.cs} (79%) diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs index c52ef98de..62594765e 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs @@ -49,17 +49,23 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => - x.RoleName == ValidRole - && x.Username == ValidUsername - && x.Email == ValidEmail1 - && x.FirstName == ValidFirstName - && x.LastName == ValidLastName + writes.Verify( + x => x.AddAsync( + It.Is(x => + x.RoleName == ValidRole + && x.Username == ValidUsername + && x.Email == ValidEmail1 + && x.FirstName == ValidFirstName + && x.LastName == ValidLastName + ), + ct ), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -79,14 +85,17 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, CancellationToken.None); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => - x.Id == ValidId - && x.Username == ValidUsername - && x.Email == ValidEmail1 - && x.Password == ValidPassword - ) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => + x.Id == ValidId + && x.Username == ValidUsername + && x.Email == ValidEmail1 + && x.Password == ValidPassword + ) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs index f644da8d5..89f280269 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -49,8 +52,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.Remove(It.Is(x => x.Id == ValidId)), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove(It.Is(x => x.Id == ValidId)), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -63,9 +72,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == ValidId) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Id == ValidId) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs index dc65323a3..2fdc9edfe 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs @@ -46,17 +46,23 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => - x.RoleName == ValidRole - && x.Username == ValidUsername - && x.Email == ValidEmail1 - && x.FirstName == ValidFirstName - && x.LastName == ValidLastName + writes.Verify( + x => x.AddAsync( + It.Is(x => + x.RoleName == ValidRole + && x.Username == ValidUsername + && x.Email == ValidEmail1 + && x.FirstName == ValidFirstName + && x.LastName == ValidLastName + ), + ct ), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs index c92002ff6..4006d8f97 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShoulQueryDatabase() await handler.HandleAsync(@event); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -49,8 +52,14 @@ public async Task Handle_ShoulPersistToDatabase() await handler.HandleAsync(@event); // Assert - writes.Verify(x => x.Remove(account), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove(account), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs index 8a24f021e..044e00ca6 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShoulQueryDatabase() await handler.HandleAsync(@event); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -53,7 +56,10 @@ public async Task Handle_ShoulPersistToDatabase() await handler.HandleAsync(@event); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs index e0a624480..f6afbd753 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs @@ -31,7 +31,13 @@ public async Task Handle_ShouldPersistToDatabase() await handler.HandleAsync(@event); // Assert - writes.Verify(x => x.ViewProductAsync(ValidId, ValidProductId, viewedAt, ct), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.ViewProductAsync(ValidId, ValidProductId, viewedAt, ct), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs index 6841449b2..7be476bc2 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync(this.query, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(this.query, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs index a3215b1a5..16a99af36 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs @@ -29,7 +29,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs index 404e6e1f5..1cf6c9784 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs @@ -31,7 +31,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs index ad1bd5e96..99dca1dd4 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs @@ -26,7 +26,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.ExistsByIdAsync(ValidId, ct), Times.Once()); + reads.Verify( + x => x.ExistsByIdAsync(ValidId, ct), + Times.Once() + ); } [Theory] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs index 0596baf34..a754513b2 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs @@ -26,7 +26,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.ExistsByUsernameAsync(ValidUsername, ct), Times.Once()); + reads.Verify( + x => x.ExistsByUsernameAsync(ValidUsername, ct), + Times.Once() + ); } [Theory] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs index b6a31bac5..a4d18d958 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs @@ -31,7 +31,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByUsernameAsync(ValidUsername, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByUsernameAsync(ValidUsername, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs index bf5f59b46..51b6fcdee 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs @@ -29,7 +29,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs index dd6e8c2b9..e8e44010f 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs @@ -44,7 +44,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync(accountQuery, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(accountQuery, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs index c4e6a78e5..05e06a814 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs @@ -29,7 +29,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs index d6655664c..d0e0736f5 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs @@ -29,7 +29,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.ViewedProductsByIdAsync(ValidId, ct), Times.Once()); + reads.Verify( + x => x.ViewedProductsByIdAsync(ValidId, ct), + Times.Once() + ); } [Theory] diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs index a509d1560..f4b556e82 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs @@ -31,7 +31,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.ViewedProductsByUsernameAsync(ValidUsername, ct), Times.Once()); + reads.Verify( + x => x.ViewedProductsByUsernameAsync(ValidUsername, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs index fe45abd6e..f8a947d02 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs @@ -40,11 +40,17 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => x.Name == ValidName && x.Description == ValidDescription), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddAsync( + It.Is(x => x.Name == ValidName && x.Description == ValidDescription), + ct + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -57,7 +63,10 @@ public async Task Handle_ShouldUpdateCache() await handler.Handle(command, ct); // Assert - cache.Verify(x => x.UpdateAsync(ValidId, role), Times.Once()); + cache.Verify( + x => x.UpdateAsync(ValidId, role), + Times.Once() + ); } [Fact] @@ -70,9 +79,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Name == ValidName && x.Description == ValidDescription) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Name == ValidName && x.Description == ValidDescription) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs index 3e6bf47ca..308333722 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs @@ -37,7 +37,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -50,10 +53,16 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.Remove( - It.Is(x => x.Id == ValidId) - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove( + It.Is(x => x.Id == ValidId) + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -66,8 +75,11 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Name == ValidName) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Name == ValidName) + ), + Times.Once() + ); } } diff --git a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs index 556536819..6ca1d02e8 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs @@ -37,8 +37,10 @@ public async Task Handle_ShouldReadCache() await handler.Handle(query, ct); // Assert - cache.Verify(x => x.GetOrCreateAsync( - It.IsAny>>>()), + cache.Verify( + x => x.GetOrCreateAsync( + It.IsAny>>>() + ), Times.Once() ); } diff --git a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs index e145e318e..26ec44149 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs @@ -33,10 +33,13 @@ public async Task Handle_ShouldReadCache() await handler.Handle(query, ct); // Assert - cache.Verify(x => x.GetOrCreateAsync( - ValidId, - It.IsAny>>() - ), Times.Once()); + cache.Verify( + x => x.GetOrCreateAsync( + ValidId, + It.IsAny>>() + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs index aeafe0825..8e24702e1 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs @@ -48,7 +48,10 @@ public async Task Handle_ShouldPersistToDatabase(CustomizationId? customizationI await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct)); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Theory] @@ -67,17 +70,23 @@ public async Task Handle_ShouldSendRequests(CustomizationId? customizationId) await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidProductId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidProductId), + ct + ), + Times.Once() + ); if (customizationId is not null) { - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == customizationId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == customizationId), + ct + ), + Times.Once() + ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs index 6d200e892..e090f44db 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs @@ -59,8 +59,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.ExistsAsync(ValidBuyerId, ct), Times.Once()); - reads.Verify(x => x.AllAsync(ValidBuyerId, false, ct), Times.Once()); + reads.Verify( + x => x.ExistsAsync(ValidBuyerId, ct), + Times.Once() + ); + reads.Verify( + x => x.AllAsync(ValidBuyerId, false, ct), + Times.Once() + ); } [Fact] @@ -73,18 +79,27 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.IsAny(), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendCommandAsync( - It.Is(x => x.BuyerId == ValidBuyerId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.IsAny(), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendCommandAsync( + It.Is(x => x.BuyerId == ValidBuyerId), + ct + ), + Times.Once() + ); } [Fact] @@ -97,12 +112,18 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CartPurchased) - ), Times.Once()); - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.IsAny() - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CartPurchased) + ), + Times.Once() + ); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.IsAny() + ), + Times.Once() + ); } [Fact] @@ -115,14 +136,17 @@ public async Task Handle_ShouldCallPayment() await handler.Handle(command, ct); // Assert - payment.Verify(x => x.InitializeCartPayment( - It.Is(x => x == paymentMethodId), - It.Is(x => x == ValidBuyerId), - It.IsAny(), - It.IsAny(), - It.IsAny<(string, int)>(), - ct - ), Times.Once()); + payment.Verify( + x => x.InitializeCartPayment( + It.Is(x => x == paymentMethodId), + It.Is(x => x == ValidBuyerId), + It.IsAny(), + It.IsAny(), + It.IsAny<(string, int)>(), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs index 59a83df80..cb8c01c76 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs @@ -90,8 +90,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.ExistsAsync(ValidBuyerId, ct), Times.Once()); - reads.Verify(x => x.AllAsync(ValidBuyerId, false, ct), Times.Once()); + reads.Verify( + x => x.ExistsAsync(ValidBuyerId, ct), + Times.Once() + ); + reads.Verify( + x => x.AllAsync(ValidBuyerId, false, ct), + Times.Once() + ); } [Fact] @@ -110,26 +116,41 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.IsAny(), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.IsAny(), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendCommandAsync( - It.IsAny(), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.IsAny(), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.IsAny(), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.IsAny(), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendCommandAsync( + It.IsAny(), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.IsAny(), + ct + ), + Times.Once() + ); } [Fact] @@ -148,14 +169,17 @@ public async Task Handle_ShouldCallPayment() await handler.Handle(command, ct); // Assert - payment.Verify(x => x.InitializeCartPayment( - It.Is(x => x == paymentMethodId), - It.Is(x => x == ValidBuyerId), - It.IsAny(), - It.IsAny(), - It.IsAny<(string, int)>(), - ct - ), Times.Once()); + payment.Verify( + x => x.InitializeCartPayment( + It.Is(x => x == paymentMethodId), + It.Is(x => x == ValidBuyerId), + It.IsAny(), + It.IsAny(), + It.IsAny<(string, int)>(), + ct + ), + Times.Once() + ); } [Fact] @@ -174,15 +198,24 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CartPurchased) - ), Times.Once()); - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.IsAny() - ), Times.Once()); - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.IsAny() - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CartPurchased) + ), + Times.Once() + ); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.IsAny() + ), + Times.Once() + ); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.IsAny() + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs index 4c3356b47..a79fe7ff3 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs @@ -42,7 +42,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleAsync(ValidBuyerId, ValidProductId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleAsync(ValidBuyerId, ValidProductId, true, ct), + Times.Once() + ); } [Fact] @@ -59,7 +62,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs index 2996f06c6..8c0fae608 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs @@ -41,7 +41,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleAsync(ValidBuyerId, ValidProductId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleAsync(ValidBuyerId, ValidProductId, true, ct), + Times.Once() + ); } [Fact] @@ -58,7 +61,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs index cafd7f435..d41eca75c 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs @@ -37,7 +37,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleAsync(ValidBuyerId, ValidProductId, true, ct)); + reads.Verify( + x => x.SingleAsync(ValidBuyerId, ValidProductId, true, ct), + Times.Once() + ); } [Fact] @@ -53,7 +56,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct)); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs index 5af8e37d5..7be1652b1 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs @@ -52,7 +52,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleAsync(ValidBuyerId, productId1, true, ct), Times.Once()); + reads.Verify( + x => x.SingleAsync(ValidBuyerId, productId1, true, ct), + Times.Once() + ); } [Fact] @@ -69,7 +72,10 @@ public async Task Handle_ShouldPersistToDatabase_WhenTurningDeliveryOff() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -86,7 +92,10 @@ public async Task Handle_ShouldPersistToDatabase_WhenTurningDeliveryOn() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -103,10 +112,13 @@ public async Task Handle_ShouldSendRequests_WhenTurningDeliveryOff() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendCommandAsync( - It.Is(x => x.Id == ValidCustomizationId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendCommandAsync( + It.Is(x => x.Id == ValidCustomizationId), + ct + ), + Times.Once() + ); } [Fact] @@ -123,10 +135,13 @@ public async Task Handle_ShouldSendRequests_WhenTurningDeliveryOn() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCustomizationId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCustomizationId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs index 9df5bf630..a73f57880 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs @@ -30,6 +30,9 @@ public async Task Handle_ShouldBulkDelete_WhenThresholdReached() await handler.HandleAsync(ie); // Assert - uow.Verify(x => x.BulkDeleteItemsByProductIdAsync(ValidProductId, ct), Times.Once()); + uow.Verify( + x => x.BulkDeleteItemsByProductIdAsync(ValidProductId, ct), + Times.Once() + ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs index aa0ae4d2e..7bc68b092 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs @@ -51,7 +51,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync(ValidBuyerId, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(ValidBuyerId, false, ct), + Times.Once() + ); } [Fact] @@ -64,14 +67,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.IsAny(), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Address == address), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.IsAny(), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Address == address), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs index 6fa82760b..fec39c18e 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs @@ -30,7 +30,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.CountAsync(ValidBuyerId, ct), Times.Once()); + reads.Verify( + x => x.CountAsync(ValidBuyerId, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs index 77344b0c7..d7e6976b0 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs @@ -42,7 +42,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync(ValidBuyerId, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(ValidBuyerId, false, ct), + Times.Once() + ); } [Fact] @@ -55,10 +58,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs index 03c5612dc..8c2333009 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs @@ -32,7 +32,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleAsync(ValidBuyerId, ValidProductId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleAsync(ValidBuyerId, ValidProductId, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs index 60f6a9148..1e4d7f7c6 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs @@ -68,11 +68,17 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => x.BuyerId == ValidBuyerId), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddAsync( + It.Is(x => x.BuyerId == ValidBuyerId), + ct + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -88,18 +94,27 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == productIds), - ct - ), Times.Once()); - sender.Verify(x => x.SendCommandAsync( - It.Is(x => x.Ids == cadIds), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids == productIds), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendCommandAsync( + It.Is(x => x.Ids == cadIds), + ct + ), + Times.Once() + ); } [Fact] @@ -115,9 +130,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Ids == productIds) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Ids == productIds) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs index df8131df7..482c9eeb6 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs @@ -57,7 +57,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.HandleAsync(@event); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -77,14 +80,20 @@ public async Task Handle_ShouldSendRequests() await handler.HandleAsync(@event); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == cart.BuyerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendCommandAsync( - It.Is(x => x.BuyerId == cart.BuyerId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == cart.BuyerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendCommandAsync( + It.Is(x => x.BuyerId == cart.BuyerId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs index 6a61f4ffa..9113e07ad 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs @@ -50,7 +50,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.HandleAsync(@event); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -63,8 +66,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.HandleAsync(@event); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); - uow.Verify(x => x.BulkDeleteItemsByBuyerIdAsync(ValidBuyerId, ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); + uow.Verify( + x => x.BulkDeleteItemsByBuyerIdAsync(ValidBuyerId, ct), + Times.Once() + ); } [Fact] @@ -77,14 +86,20 @@ public async Task Handle_ShouldSendRequests() await handler.HandleAsync(@event); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.IsAny(), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.IsAny(), + ct + ), + Times.Once() + ); } [Fact] @@ -97,11 +112,14 @@ public async Task Handle_ShouldSendEmail() await handler.HandleAsync(@event); // Assert - email.Verify(x => x.SendRewardGrantedEmailAsync( - To, - $"{Url}/carts/{ValidId}", - ct - ), Times.Once()); + email.Verify( + x => x.SendRewardGrantedEmailAsync( + To, + $"{Url}/carts/{ValidId}", + ct + ), + Times.Once() + ); } [Fact] @@ -122,11 +140,14 @@ public async Task Handle_ShouldIdk_WhenForDelivery() await handler.HandleAsync(@event); // Assert - email.Verify(x => x.SendRewardGrantedEmailAsync( - To, - $"{Url}/shipments/{ValidShipmentId}", - ct - ), Times.Once()); + email.Verify( + x => x.SendRewardGrantedEmailAsync( + To, + $"{Url}/shipments/{ValidShipmentId}", + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs index c0a177652..eedb12c3a 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs @@ -30,7 +30,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.CountAsync(ValidBuyerId, ct), Times.Once()); + reads.Verify( + x => x.CountAsync(ValidBuyerId, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs index 5858754fb..0b8859acf 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs @@ -34,7 +34,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.CountItemsAsync(ValidBuyerId, ct), Times.Once()); + reads.Verify( + x => x.CountItemsAsync(ValidBuyerId, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs index 2bad97691..67e5151a3 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs @@ -43,7 +43,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync(this.query, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(this.query, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs index e21b361bf..e950d7eff 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs @@ -40,7 +40,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -53,9 +56,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs index b0e14e52c..cbf12dff3 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs @@ -17,7 +17,7 @@ public Tests() { handler = new(writes.Object, uow.Object, cache.Object); - writes.Setup(v => v.AddAsync( + writes.Setup(x => x.AddAsync( It.Is(x => x.Name == ValidName && x.Description == ValidDescription), ct )).ReturnsAsync(CreateCategory(id: ValidId)); @@ -33,11 +33,17 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(v => v.AddAsync( - It.Is(x => x.Name == ValidName && x.Description == ValidDescription), - ct - ), Times.Once()); - uow.Verify(v => v.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddAsync( + It.Is(x => x.Name == ValidName && x.Description == ValidDescription), + ct + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -50,10 +56,13 @@ public async Task Handle_ShouldUpdateCache() await handler.Handle(command, ct); // Assert - cache.Verify(v => v.UpdateAsync( - ValidId, - It.Is(x => x.Name == ValidName && x.Description == ValidDescription) - ), Times.Once()); + cache.Verify( + x => x.UpdateAsync( + ValidId, + It.Is(x => x.Name == ValidName && x.Description == ValidDescription) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs index 9d8d6d320..6fe300e29 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs @@ -19,7 +19,7 @@ public Tests() { handler = new(reads.Object, writes.Object, uow.Object, cache.Object); - reads.Setup(v => v.SingleByIdAsync(ValidId, true, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(CreateCategory(ValidName, ValidDescription)); } @@ -33,7 +33,10 @@ public async Task Handle_ShouldReadCache() await handler.Handle(command, ct); // Assert - reads.Verify(v => v.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -46,10 +49,16 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(v => v.Remove( - It.Is(x => x.Id == ValidId) - ), Times.Once()); - uow.Verify(v => v.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove( + It.Is(x => x.Id == ValidId) + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -62,6 +71,9 @@ public async Task Handle_ShouldClearCache() await handler.Handle(command, ct); // Assert - cache.Verify(x => x.ClearAsync(ValidId)); + cache.Verify( + x => x.ClearAsync(ValidId), + Times.Once() + ); } } diff --git a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs index 34fbf97d4..8a2ad847a 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs @@ -18,7 +18,7 @@ public class Tests : Data.Categories.BaseUnitTests public Tests() { handler = new(reads.Object, uow.Object, cache.Object); - reads.Setup(v => v.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(category); + reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(category); } [Fact] @@ -31,7 +31,10 @@ public async Task Handle_ShouldReadCache() await handler.Handle(command, ct); // Assert - reads.Verify(v => v.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -44,7 +47,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(v => v.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -74,9 +80,12 @@ public async Task Handle_ShouldUpdateCache() await handler.Handle(command, ct); // Assert - cache.Verify(v => v.UpdateAsync( - ValidId, - category - ), Times.Once()); + cache.Verify( + x => x.UpdateAsync( + ValidId, + category + ), + Times.Once() + ); } } diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs index 226bc691a..d9be3d15d 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs @@ -22,8 +22,8 @@ public Tests() { handler = new(reads.Object, cache.Object); - cache.Setup(v => v.GetOrCreateAsync(It.IsAny>>>())).ReturnsAsync(categories); - reads.Setup(v => v.AllAsync(false, ct)).ReturnsAsync(categories); + cache.Setup(x => x.GetOrCreateAsync(It.IsAny>>>())).ReturnsAsync(categories); + reads.Setup(x => x.AllAsync(false, ct)).ReturnsAsync(categories); } [Fact] @@ -36,7 +36,10 @@ public async Task Handle_ShouldReadCache() await handler.Handle(query, ct); // Assert - cache.Verify(v => v.GetOrCreateAsync(It.IsAny>>>()), Times.Once()); + cache.Verify( + x => x.GetOrCreateAsync(It.IsAny>>>()), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs index 244c0f242..21e10ed99 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs @@ -15,7 +15,7 @@ public Tests() { handler = new(reads.Object, cache.Object); - cache.Setup(v => v.GetOrCreateAsync(ValidId, It.IsAny>>())) + cache.Setup(x => x.GetOrCreateAsync(ValidId, It.IsAny>>())) .ReturnsAsync(CreateCategory(id: ValidId)); } @@ -30,7 +30,7 @@ public async Task Handle_ShouldReadCache() // Assert cache.Verify( - v => v.GetOrCreateAsync(ValidId, It.IsAny>>()), + x => x.GetOrCreateAsync(ValidId, It.IsAny>>()), Times.Once() ); } diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs index 8d3bd0e6e..86ff8e7b6 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs @@ -35,7 +35,10 @@ public async Task Handle_ShouldReadCache() await handler.Handle(query, ct); // Assert - cache.Verify(x => x.GetOrCreateAsync(It.IsAny>>>()), Times.Once()); + cache.Verify( + x => x.GetOrCreateAsync(It.IsAny>>>()), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs index 11142ec2d..834305a5c 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs @@ -16,7 +16,7 @@ public Tests() { handler = new(reads.Object, cache.Object); - cache.Setup(v => v.GetOrCreateAsync(ValidId, It.IsAny>>())) + cache.Setup(x => x.GetOrCreateAsync(ValidId, It.IsAny>>())) .ReturnsAsync(CreateCategory(name: ValidName)); } @@ -30,7 +30,10 @@ public async Task Handle_ShouldReadCache() await handler.Handle(query, ct); // Assert - cache.Verify(v => v.GetOrCreateAsync(ValidId, It.IsAny>>()), Times.Once()); + cache.Verify( + x => x.GetOrCreateAsync(ValidId, It.IsAny>>()), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs index b104b89e0..f13c927af 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs @@ -27,7 +27,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.ExistsByIdAsync(ValidId, ct), Times.Once()); + reads.Verify( + x => x.ExistsByIdAsync(ValidId, ct), + Times.Once() + ); } [Theory] diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs index c57b0abf4..067227391 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs @@ -43,7 +43,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -56,7 +59,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -69,10 +75,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidAdminId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidAdminId), + ct + ), + Times.Once() + ); } [Fact] @@ -85,11 +94,14 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is( - x => x.Type == NotificationType.ProductRemoved - ) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is( + x => x.Type == NotificationType.ProductRemoved + ) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs index 3979e8f1d..53d7cb36e 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs @@ -92,20 +92,26 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => - x.Name == MinValidName && - x.Description == MinValidDescription && - x.Price == MinValidPrice && - x.Status == ProductStatus.Unchecked && - x.CreatorId == ValidCreatorId && - x.CategoryId == ValidCategoryId && - x.ImageId == ValidImageId && - x.CadId == ValidCadId + writes.Verify( + x => x.AddAsync( + It.Is(x => + x.Name == MinValidName && + x.Description == MinValidDescription && + x.Price == MinValidPrice && + x.Status == ProductStatus.Unchecked && + x.CreatorId == ValidCreatorId && + x.CategoryId == ValidCategoryId && + x.ImageId == ValidImageId && + x.CadId == ValidCadId + ), + ct ), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -126,31 +132,48 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCategoryId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCreatorId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidImageId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCadId), - ct - ), Times.Once()); - - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCreatorId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCadId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCategoryId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCreatorId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidImageId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCadId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCreatorId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCadId), + ct + ), + Times.Once() + ); } [Fact] @@ -171,12 +194,15 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => - x.Id == ValidId - && x.TagIds.Contains(DomainConstants.Tags.NewId) - ) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => + x.Id == ValidId + && x.TagIds.Contains(DomainConstants.Tags.NewId) + ) + ), + Times.Once() + ); } [Fact] @@ -228,9 +254,12 @@ public async Task Handle_ShouldTagProfessional_WhenDesignerRole() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.TagIds.Contains(DomainConstants.Tags.ProfessionalId)) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.TagIds.Contains(DomainConstants.Tags.ProfessionalId)) + ), + Times.Once() + ); } [Fact] @@ -256,9 +285,12 @@ public async Task Handle_ShouldTagPrintable_WhenAppropriateContentType() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.TagIds.Contains(DomainConstants.Tags.PrintableId)) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.TagIds.Contains(DomainConstants.Tags.PrintableId)) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs index 9774e9eb5..b8078033c 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs @@ -48,7 +48,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -61,8 +64,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.Remove(product), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove(product), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -75,10 +84,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.ProductId == ValidId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.ProductId == ValidId), + ct + ), + Times.Once() + ); } [Fact] @@ -91,12 +103,18 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.IsAny() - ), Times.Once()); - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.ProductDeleted) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.IsAny() + ), + Times.Once() + ); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.ProductDeleted) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs index 11a876d89..a04e9e39e 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs @@ -57,7 +57,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -77,7 +80,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -97,14 +103,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCategoryId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.ProductId == ValidId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCategoryId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.ProductId == ValidId), + ct + ), + Times.Once() + ); } [Fact] @@ -124,9 +136,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.ProductEdited) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.ProductEdited) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs index 7dd6f0494..1850f4bc2 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -49,8 +52,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddTagAsync(ValidId, ValidTagId, ct), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddTagAsync(ValidId, ValidTagId, ct), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -63,9 +72,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.ProductTagAdded) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.ProductTagAdded) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs index 7acd16812..1c7591d2f 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -49,8 +52,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.RemoveTagAsync(ValidId, ValidTagId), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.RemoveTagAsync(ValidId, ValidTagId), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -63,9 +72,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.ProductTagRemoved) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.ProductTagRemoved) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs index 6b4c53ebf..34c8adf4d 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs @@ -45,7 +45,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -58,7 +61,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -71,14 +77,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidDesignerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidDesignerId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidDesignerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidDesignerId), + ct + ), + Times.Once() + ); } [Fact] @@ -91,11 +103,14 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is( - x => x.Type == NotificationType.ProductReported - ) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is( + x => x.Type == NotificationType.ProductReported + ) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs index 019388ca1..17248b0e6 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs @@ -45,7 +45,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -58,7 +61,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -71,14 +77,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidDesignerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidDesignerId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidDesignerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidDesignerId), + ct + ), + Times.Once() + ); } [Fact] @@ -91,11 +103,14 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is( - x => x.Type == NotificationType.ProductValidated - ) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is( + x => x.Type == NotificationType.ProductValidated + ) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs index 739c19b1f..627d026bb 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs @@ -33,6 +33,9 @@ public async Task Handle_ShouldPersistToDatabase() x => x.AddTagAsync(ValidId, It.Is(x => TagIds.Contains(x)), ct), Times.Exactly(TagIds.Length) ); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs index 241b1cc30..6e528b15d 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs @@ -26,6 +26,9 @@ public async Task Handle_ShouldPersistToDatabase() await handler.HandleAsync(@event, ct); // Assert - uow.Verify(x => x.AddProductsPurchasesAsync(ids, 1, ct), Times.Once()); + uow.Verify( + x => x.AddProductsPurchasesAsync(ids, 1, ct), + Times.Once() + ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs index ff7e0211f..edcedc7b3 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs @@ -64,7 +64,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.HandleAsync(@event); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -77,7 +80,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.HandleAsync(@event); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -90,18 +96,27 @@ public async Task Handle_ShouldSendRequests() await handler.HandleAsync(@event); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCreatorId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Username == Username), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCreatorId && x.ProductId == ValidId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCreatorId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Username == Username), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCreatorId && x.ProductId == ValidId), + ct + ), + Times.Once() + ); } [Fact] @@ -114,9 +129,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.HandleAsync(@event); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) + ), + Times.Once() + ); } [Fact] @@ -146,11 +164,20 @@ public async Task Handle_ShouldReturnEarly_WhenUserDoesNotTrackViewedProducts() await handler.HandleAsync(@event); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Never()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Never()); - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) - ), Times.Never()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Never() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Never() + ); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) + ), + Times.Never() + ); Assert.Equal(0, product.Counts.Views); } @@ -168,17 +195,29 @@ public async Task Handle_ShouldReturnEarly_WhenUserAlreadyViewedProduct() await handler.HandleAsync(@event); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Username == Username), - ct - ), Times.Never()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Username == Username), + ct + ), + Times.Never() + ); - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Never()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Never()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Never() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Never() + ); - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) - ), Times.Never()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Id == ValidId && x.AccountId == ValidCreatorId) + ), + Times.Never() + ); Assert.Equal(0, product.Counts.Views); } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs index bd204a931..86638f85e 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs @@ -37,7 +37,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.CountByStatusAsync(ValidCreatorId, ct), Times.Once()); + reads.Verify( + x => x.CountByStatusAsync(ValidCreatorId, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs index 15cd3b276..754140d8a 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs @@ -58,11 +58,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync( - It.IsAny(), - false, - ct - ), Times.Once()); + reads.Verify( + x => x.AllAsync( + It.IsAny(), + false, + ct + ), + Times.Once() + ); } [Fact] @@ -81,10 +84,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs index af6b3abca..9d7c3983c 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -49,14 +52,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == product.CreatorId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == product.CategoryId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == product.CreatorId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == product.CategoryId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs index dc682ce27..e5c204932 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs @@ -67,11 +67,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync( - It.IsAny(), - false, - ct - ), Times.Once()); + reads.Verify( + x => x.AllAsync( + It.IsAny(), + false, + ct + ), + Times.Once() + ); } [Fact] @@ -91,14 +94,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs index e924d937c..d38d3fccd 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs @@ -34,7 +34,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -47,14 +50,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCreatorId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCategoryId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCreatorId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCategoryId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs index bf6fc4995..49fc05517 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs @@ -64,11 +64,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync( - It.IsAny(), - false, - ct - ), Times.Once()); + reads.Verify( + x => x.AllAsync( + It.IsAny(), + false, + ct + ), + Times.Once() + ); } [Fact] @@ -87,14 +90,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs index 9829657e0..431efefe5 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs @@ -44,7 +44,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -57,14 +60,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == product.CreatorId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == product.CategoryId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == product.CreatorId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == product.CategoryId), + ct + ), + Times.Once() + ); } [Theory] @@ -83,9 +92,12 @@ public async Task Handle_ShouldRaiseEvents(bool authenticatedUser, bool viewed) await handler.Handle(query, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == product.Id) - ), Times.Exactly(authenticatedUser && viewed ? 1 : 0)); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Id == product.Id) + ), + Times.Exactly(authenticatedUser && viewed ? 1 : 0) + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs index ba1933835..3b651de8d 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs @@ -46,7 +46,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync(this.query, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(this.query, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs index 4efe83e80..3be90e4f9 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs @@ -46,7 +46,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync(this.query, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(this.query, false, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs index 8c7bfdd8c..c22214294 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs @@ -27,7 +27,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.ExistsByIdAsync(ValidId, ct), Times.Once()); + reads.Verify( + x => x.ExistsByIdAsync(ValidId, ct), + Times.Once() + ); } [Theory] diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs index e5cf687fb..a92e09a75 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs @@ -19,7 +19,7 @@ public Tests() { handler = new(writes.Object, uow.Object, cache.Object); - writes.Setup(v => v.AddAsync( + writes.Setup(x => x.AddAsync( It.Is(x => x.Name == MaxValidName), ct )).ReturnsAsync(tag); @@ -35,11 +35,17 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(v => v.AddAsync( - It.Is(x => x.Name == MaxValidName), - ct - ), Times.Once()); - uow.Verify(v => v.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddAsync( + It.Is(x => x.Name == MaxValidName), + ct + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs index 9f6f5be96..ac9bdce21 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(v => v.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -65,8 +68,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(v => v.Remove(tag), Times.Once()); - uow.Verify(v => v.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove(tag), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs index edb71c5c4..83f4efa76 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs @@ -34,7 +34,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(v => v.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -63,8 +66,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(v => v.SingleByIdAsync(ValidId, true, ct), Times.Once()); - uow.Verify(v => v.SaveChangesAsync(ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs index 26781e493..c39435c52 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs @@ -42,7 +42,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -58,7 +61,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -74,9 +80,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomRemoved) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomRemoved) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs index 001d2f50e..fa65b9264 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs @@ -37,7 +37,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -53,7 +56,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs index e4414dd6c..4a7543b4d 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs @@ -60,16 +60,22 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => - x.Name == MaxValidName && - x.Description == MaxValidDescription && - x.ForDelivery && - x.BuyerId == ValidBuyerId + writes.Verify( + x => x.AddAsync( + It.Is(x => + x.Name == MaxValidName && + x.Description == MaxValidDescription && + x.ForDelivery && + x.BuyerId == ValidBuyerId + ), + ct ), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -88,14 +94,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Role == "Designer"), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Role == "Designer"), + ct + ), + Times.Once() + ); } [Fact] @@ -114,9 +126,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomCreated) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomCreated) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs index ea65f3873..205d58c0b 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs @@ -41,7 +41,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -57,10 +60,16 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.Remove( - It.Is(x => x.Id == ValidId) - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove( + It.Is(x => x.Id == ValidId) + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Theory] @@ -83,8 +92,11 @@ public async Task Handle_ShouldRaiseEvents(bool isPending) await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomDeleted) - ), Times.Exactly(isPending ? 0 : 1)); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomDeleted) + ), + Times.Exactly(isPending ? 0 : 1) + ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs index a67315ab3..443af6a06 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs @@ -43,7 +43,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -62,7 +65,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Theory] @@ -88,8 +94,11 @@ public async Task Handle_ShouldRaiseEvents(bool isPending) await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomEdited) - ), Times.Exactly(isPending ? 0 : 1)); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomEdited) + ), + Times.Exactly(isPending ? 0 : 1) + ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs index 2e8254914..6088bce17 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs @@ -51,7 +51,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -64,10 +67,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId || x.Id == ValidDesignerId), - ct - ), Times.Exactly(2)); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId || x.Id == ValidDesignerId), + ct + ), + Times.Exactly(2) + ); } [Fact] @@ -80,12 +86,18 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomCompleted) - ), Times.Once()); - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.IsAny() - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomCompleted) + ), + Times.Once() + ); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.IsAny() + ), + Times.Once() + ); } [Fact] @@ -98,14 +110,17 @@ public async Task Handle_ShouldCallPayment() await handler.Handle(command, ct); // Assert - payment.Verify(x => x.InitializeCustomPayment( - It.Is(x => x == PaymentMethodId), - It.Is(x => x == custom.BuyerId), - It.Is(x => x == custom.Id), - It.Is(x => x == ValidPrice), - It.Is<(string, string Name, string)>(x => x.Name == custom.Name), - ct - ), Times.Once()); + payment.Verify( + x => x.InitializeCustomPayment( + It.Is(x => x == PaymentMethodId), + It.Is(x => x == custom.BuyerId), + It.Is(x => x == custom.Id), + It.Is(x => x == ValidPrice), + It.Is<(string, string Name, string)>(x => x.Name == custom.Name), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs index d037d17d7..3f8d79a6a 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs @@ -72,7 +72,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -94,15 +97,27 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId || x.Id == ValidDesignerId) - , ct), Times.Exactly(2)); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCustomizationId) - , ct), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCustomizationId) - , ct), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId || x.Id == ValidDesignerId), + ct + ), + Times.Exactly(2) + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCustomizationId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCustomizationId), + ct + ), + Times.Once() + ); } [Fact] @@ -124,14 +139,17 @@ public async Task Handle_ShouldCallPayment() await handler.Handle(command, ct); // Assert - payment.Verify(x => x.InitializeCustomPayment( - It.Is(x => string.IsNullOrEmpty(x)), - It.Is(x => x == ValidBuyerId), - It.Is(x => x == ValidId), - It.Is(x => x == ValidPrice), - It.Is<(string, string Name, string)>(x => x.Name == custom.Name), - ct - ), Times.Once()); + payment.Verify( + x => x.InitializeCustomPayment( + It.Is(x => string.IsNullOrEmpty(x)), + It.Is(x => x == ValidBuyerId), + It.Is(x => x == ValidId), + It.Is(x => x == ValidPrice), + It.Is<(string, string Name, string)>(x => x.Name == custom.Name), + ct + ), + Times.Once() + ); } [Fact] @@ -153,15 +171,24 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomCompleted) - ), Times.Once()); - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.CustomId == custom.Id) - ), Times.Once()); - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.IsAny() - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomCompleted) + ), + Times.Once() + ); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.CustomId == custom.Id) + ), + Times.Once() + ); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.IsAny() + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs index b58ef0a44..e8afb3118 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs @@ -42,7 +42,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -59,7 +62,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Theory] @@ -83,9 +89,12 @@ public async Task Handle_ShouldRaiseEvents(bool isPending) await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomToggledDelivery) - ), Times.Exactly(isPending ? 0 : 1)); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomToggledDelivery) + ), + Times.Exactly(isPending ? 0 : 1) + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs index 82e8be288..6ba7192aa 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs @@ -49,7 +49,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -65,7 +68,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -81,14 +87,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidDesignerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidDesignerId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidDesignerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidDesignerId), + ct + ), + Times.Once() + ); } [Fact] @@ -104,9 +116,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomAccepted) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomAccepted) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs index 0bdd96e06..87627d53e 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs @@ -43,7 +43,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -59,7 +62,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -75,9 +81,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomBegun) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomBegun) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs index d50a20c05..eacae336a 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs @@ -43,7 +43,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -59,7 +62,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -75,9 +81,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomCanceled) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomCanceled) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs index d1e6688fc..957b71f0f 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs @@ -54,7 +54,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -72,7 +75,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -90,10 +96,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCadId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCadId), + ct + ), + Times.Once() + ); } [Fact] @@ -111,9 +120,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomFinished) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomFinished) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs index f3f95e569..4054c964b 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs @@ -46,7 +46,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -62,7 +65,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -78,10 +84,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidDesignerId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidDesignerId), + ct + ), + Times.Once() + ); } [Fact] @@ -97,9 +106,12 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Type == NotificationType.CustomReported) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Type == NotificationType.CustomReported) + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs index 70cc0c40c..3353690cf 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs @@ -40,7 +40,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -57,7 +60,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs index 775f796fe..d776ffc2d 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs @@ -65,7 +65,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.HandleAsync(@event); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -85,7 +88,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.HandleAsync(@event); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -105,14 +111,20 @@ public async Task Handle_ShouldSendRequests() await handler.HandleAsync(@event); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == custom.BuyerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendCommandAsync( - It.Is(x => x.BuyerId == custom.BuyerId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == custom.BuyerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendCommandAsync( + It.Is(x => x.BuyerId == custom.BuyerId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs index 05d55f0fa..3ac4f3ad8 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs @@ -55,7 +55,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.HandleAsync(@event); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -68,7 +71,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.HandleAsync(@event); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -81,14 +87,20 @@ public async Task Handle_ShouldSendRequests() await handler.HandleAsync(@event); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.IsAny(), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.IsAny(), + ct + ), + Times.Once() + ); } [Fact] @@ -101,11 +113,14 @@ public async Task Handle_ShouldSendEmail() await handler.HandleAsync(@event); // Assert - email.Verify(x => x.SendRewardGrantedEmailAsync( - ToEmail, - $"{ClientUrl}/customs/{ValidId}", - ct - ), Times.Once()); + email.Verify( + x => x.SendRewardGrantedEmailAsync( + ToEmail, + $"{ClientUrl}/customs/{ValidId}", + ct + ), + Times.Once() + ); } [Fact] @@ -128,15 +143,21 @@ public async Task Handle_ShouldGrantShipment_WhenForDelivery() await handler.HandleAsync(@event); // Assert - sender.Verify(x => x.SendCommandAsync( - It.Is(x => x.Id == ValidShipmentId), - ct - ), Times.Once()); - email.Verify(x => x.SendRewardGrantedEmailAsync( - ToEmail, - $"{ClientUrl}/shipments/{ValidShipmentId}", - ct - ), Times.Once()); + sender.Verify( + x => x.SendCommandAsync( + It.Is(x => x.Id == ValidShipmentId), + ct + ), + Times.Once() + ); + email.Verify( + x => x.SendRewardGrantedEmailAsync( + ToEmail, + $"{ClientUrl}/shipments/{ValidShipmentId}", + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs index fc275c75a..9506c566c 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs @@ -48,7 +48,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -61,14 +64,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCustomizationId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Address == address), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCustomizationId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Address == address), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs index a3d1b3bb7..a123c2d36 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs @@ -39,7 +39,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.CountAsync(ValidBuyerId, ct), Times.Once()); + reads.Verify( + x => x.CountAsync(ValidBuyerId, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs index 724043d1b..c30d91cca 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs @@ -38,7 +38,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -52,14 +55,20 @@ public async Task Handle_ShouldSendRequests_WhenAccepted() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidDesignerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCategoryId), - ct - ), Times.Never()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidDesignerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCategoryId), + ct + ), + Times.Never() + ); } [Fact] @@ -73,14 +82,20 @@ public async Task Handle_ShouldSendRequests_WhenHasCategory() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidDesignerId), - ct - ), Times.Never()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCategoryId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidDesignerId), + ct + ), + Times.Never() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCategoryId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs index 1c2a86e7f..363e9ed73 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); } [Fact] @@ -50,14 +53,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCategoryId), - ct - ), Times.Never()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCategoryId), + ct + ), + Times.Never() + ); } [Fact] @@ -70,10 +79,13 @@ public async Task Handle_ShouldSendRequests_WhenHasCategory() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidCategoryId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidCategoryId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs index 819909b8e..8df758d9b 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs @@ -78,7 +78,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync(this.query, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(this.query, false, ct), + Times.Once() + ); } [Fact] @@ -91,18 +94,27 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids.Contains(ValidBuyerId)), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids.Contains(ValidDesignerId)), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids.Contains(ValidCategoryId)), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids.Contains(ValidBuyerId)), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids.Contains(ValidDesignerId)), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids.Contains(ValidCategoryId)), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs index d8cf73047..67b776486 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs @@ -68,7 +68,10 @@ public async Task Handle_ShouldCallDelivery() await handler.Handle(command, ct); // Assert - delivery.Verify(x => x.CancelAsync(ValidReferenceId, Comment, ct), Times.Once()); + delivery.Verify( + x => x.CancelAsync(ValidReferenceId, Comment, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs index 4dbfa73b4..b042e08e6 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs @@ -52,11 +52,17 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => x.BuyerId == ValidBuyerId), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddAsync( + It.Is(x => x.BuyerId == ValidBuyerId), + ct + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -75,10 +81,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidBuyerId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidBuyerId), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs index 7de52e4c7..6df392be4 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs @@ -52,7 +52,10 @@ public async Task Handle_ShouldCallDelivery() await handler.Handle(query, ct); // Assert - delivery.Verify(x => x.TrackAsync(ValidReferenceId, ct), Times.Once()); + delivery.Verify( + x => x.TrackAsync(ValidReferenceId, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs index d88612eea..85f6c44f0 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs @@ -53,7 +53,10 @@ public async Task Handle_ShouldCallDelivery() await handler.Handle(query, ct); // Assert - delivery.Verify(x => x.PrintAsync(ValidReferenceId, ct), Times.Once()); + delivery.Verify( + x => x.PrintAsync(ValidReferenceId, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs index 6e4756970..5baac12b4 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs @@ -42,15 +42,18 @@ public async Task Handle_ShouldCallDelivery() await handler.Handle(query, ct); // Assert - delivery.Verify(x => x.CalculateAsync( - It.Is(x => - x.Country == address.Country - && x.City == address.City - && x.Street == address.Street - && x.Weights.Length == weights.Length + delivery.Verify( + x => x.CalculateAsync( + It.Is(x => + x.Country == address.Country + && x.City == address.City + && x.Street == address.Street + && x.Weights.Length == weights.Length + ), + ct ), - ct - ), Times.Once()); + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs index 42de3afbe..8d9c30a57 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs @@ -32,11 +32,17 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => x.Key == ValidKey && x.ContentType == ValidContentType), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddAsync( + It.Is(x => x.Key == ValidKey && x.ContentType == ValidContentType), + ct + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs index ea4501002..768b466c5 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs @@ -34,7 +34,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -47,7 +50,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs index 3cd857882..66ea75102 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs @@ -41,7 +41,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -59,7 +62,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs index 060b46071..d3dc23dbd 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs @@ -44,7 +44,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.AllAsync(query, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(query, false, ct), + Times.Once() + ); } [Fact] @@ -57,8 +60,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddRangeAsync(It.Is>(x => x.Count == result.Count), ct), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddRangeAsync(It.Is>(x => x.Count == result.Count), ct), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs b/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs index b693db329..b5712789d 100644 --- a/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs @@ -40,7 +40,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.HandleAsync(@event); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -57,8 +60,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.HandleAsync(@event); // Assert - writes.Verify(x => x.Remove(cad), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove(cad), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -95,7 +104,10 @@ public async Task Handle_ShouldCallStorage() await handler.HandleAsync(@event); // Assert - storage.Verify(x => x.DeleteFileAsync(cad.Key, ct), Times.Once()); + storage.Verify( + x => x.DeleteFileAsync(cad.Key, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs index 578ce3451..960c6aa2e 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs @@ -57,7 +57,10 @@ public async Task Handle_ShouldCallStorage() await handler.Handle(query, ct); // Assert - storage.Verify(x => x.GetPresignedGetUrlAsync(cad.Key, cad.ContentType), Times.Once()); + storage.Verify( + x => x.GetPresignedGetUrlAsync(cad.Key, cad.ContentType), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs index 5fa996165..35420d6de 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs @@ -35,7 +35,10 @@ public async Task Handle_ShouldCallStorage() await handler.Handle(query, ct); // Assert - storage.Verify(x => x.GetPresignedPostUrlAsync(Name, req), Times.Once()); + storage.Verify( + x => x.GetPresignedPostUrlAsync(Name, req), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs index 62b4661d8..b09047fd5 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs @@ -58,7 +58,10 @@ public async Task Handle_ShouldCallStorage() await handler.Handle(query, ct); // Assert - storage.Verify(x => x.GetPresignedPutUrlAsync(cad.Key, req), Times.Once()); + storage.Verify( + x => x.GetPresignedPutUrlAsync(cad.Key, req), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs index bf4de278b..cc8ae01ad 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs @@ -27,7 +27,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.ExistsByIdAsync(ValidId, ct), Times.Once()); + reads.Verify( + x => x.ExistsByIdAsync(ValidId, ct), + Times.Once() + ); } [Theory] diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs index 0bad00304..e16d6c84a 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs @@ -34,10 +34,13 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - cache.Verify(x => x.GetOrCreateAsync( - ValidId, - It.IsAny>>() - ), Times.Once()); + cache.Verify( + x => x.GetOrCreateAsync( + ValidId, + It.IsAny>>() + ), + Times.Once() + ); } [Theory] diff --git a/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs index 54eed2719..4e6932cdf 100644 --- a/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs @@ -32,11 +32,17 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => x.Key == ValidKey && x.ContentType == ValidContentType), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddAsync( + It.Is(x => x.Key == ValidKey && x.ContentType == ValidContentType), + ct + ), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs index 7c0b6941a..84a255d68 100644 --- a/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs @@ -34,7 +34,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -47,7 +50,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs b/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs index 4b7455a36..1132d105d 100644 --- a/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs @@ -40,7 +40,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.HandleAsync(ie); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -57,8 +60,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.HandleAsync(ie); // Assert - writes.Verify(x => x.Remove(image), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove(image), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -95,7 +104,10 @@ public async Task Handle_ShouldCallStorage() await handler.HandleAsync(ie); // Assert - storage.Verify(x => x.DeleteFileAsync(image.Key, ct), Times.Once()); + storage.Verify( + x => x.DeleteFileAsync(image.Key, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs index 2ab8e6286..5c6151338 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs @@ -57,7 +57,10 @@ public async Task Handle_ShouldCallStorage() await handler.Handle(query, ct); // Assert - storage.Verify(x => x.GetPresignedGetUrlAsync(image.Key), Times.Once()); + storage.Verify( + x => x.GetPresignedGetUrlAsync(image.Key), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs index b6fe5a562..33068329d 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldCallStorage() await handler.Handle(query, ct); // Assert - storage.Verify(x => x.GetPresignedPostUrlAsync(Name, req), Times.Once()); + storage.Verify( + x => x.GetPresignedPostUrlAsync(Name, req), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs index 02b842864..1a72caa86 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs @@ -58,7 +58,10 @@ public async Task Handle_ShouldCallStorage() await handler.Handle(query, ct); // Assert - storage.Verify(x => x.GetPresignedPutUrlAsync(image.Key, req), Times.Once()); + storage.Verify( + x => x.GetPresignedPutUrlAsync(image.Key, req), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs index 66cbb65ca..38c21a17d 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs @@ -40,12 +40,15 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync( - ValidId, - ValidRequestHash, - true, - ct - ), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync( + ValidId, + ValidRequestHash, + true, + ct + ), + Times.Once() + ); } [Fact] @@ -63,7 +66,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs index f77c67dc0..e58a64285 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs @@ -38,14 +38,20 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => - x.Id == ValidId - && x.RequestHash == ValidRequestHash + writes.Verify( + x => x.AddAsync( + It.Is(x => + x.Id == ValidId + && x.RequestHash == ValidRequestHash + ), + ct ), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs index b11e2e2c1..54cd9d4ab 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs @@ -39,12 +39,15 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync( - ValidId, - ValidRequestHash, - true, - ct - ), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync( + ValidId, + ValidRequestHash, + true, + ct + ), + Times.Once() + ); } [Fact] @@ -60,8 +63,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.Remove(It.Is(x => x.Id == ValidId)), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove(It.Is(x => x.Id == ValidId)), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs index d55a2e733..5829eae6f 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs @@ -34,12 +34,15 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.SingleByIdAsync( - ValidId, - ValidRequestHash, - false, - ct - ), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync( + ValidId, + ValidRequestHash, + false, + ct + ), + Times.Once() + ); } [Theory] diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs index 79c2d472a..63ae39260 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs @@ -37,8 +37,14 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.GetByAccountIdAsync(user.AccountId), Times.Once()); - service.Verify(x => x.UpdateUsernameAsync(user.Id, MinValidUsername), Times.Once()); + service.Verify( + x => x.GetByAccountIdAsync(user.AccountId), + Times.Once() + ); + service.Verify( + x => x.UpdateUsernameAsync(user.Id, MinValidUsername), + Times.Once() + ); } [Fact] @@ -56,11 +62,14 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => - x.Username == user.Username - && x.Id == user.AccountId - ) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => + x.Username == user.Username + && x.Id == user.AccountId + ) + ), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs index e360ecbc9..0cf05505a 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs @@ -30,7 +30,10 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.DeleteAsync(user.AccountId), Times.Once()); + service.Verify( + x => x.DeleteAsync(user.AccountId), + Times.Once() + ); } [Fact] @@ -43,8 +46,11 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == user.AccountId) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => x.Id == user.AccountId) + ), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs index 5adbc6c63..7cf862326 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs @@ -51,9 +51,18 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.GetByUsernameAsync(MaxValidUsername), Times.Once()); - service.Verify(x => x.GetIsLockedOutAsync(MaxValidUsername), Times.Once()); - service.Verify(x => x.CheckPasswordAsync(User.Username, MinValidPassword), Times.Once()); + service.Verify( + x => x.GetByUsernameAsync(MaxValidUsername), + Times.Once() + ); + service.Verify( + x => x.GetIsLockedOutAsync(MaxValidUsername), + Times.Once() + ); + service.Verify( + x => x.CheckPasswordAsync(User.Username, MinValidPassword), + Times.Once() + ); } [Fact] @@ -71,10 +80,16 @@ public async Task Handle_ShouldIssueTokens() await handler.Handle(command, ct); // Assert - tokenService.Verify(x => x.IssueRefreshToken( - It.IsAny>() - ), Times.Once()); - tokenService.Verify(x => x.IssueTokens(User, RefreshToken), Times.Once()); + tokenService.Verify( + x => x.IssueRefreshToken( + It.IsAny>() + ), + Times.Once() + ); + tokenService.Verify( + x => x.IssueTokens(User, RefreshToken), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs index 41f1aeb29..5d165ee20 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs @@ -34,7 +34,10 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.RevokeRefreshTokenAsync(token.Value), Times.Once()); + service.Verify( + x => x.RevokeRefreshTokenAsync(token.Value), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs index 1342093a6..88fe0daa6 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs @@ -43,7 +43,10 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.GetByRefreshTokenAsync(RefreshToken.Value), Times.Once()); + service.Verify( + x => x.GetByRefreshTokenAsync(RefreshToken.Value), + Times.Once() + ); } [Fact] @@ -56,7 +59,10 @@ public async Task Handle_ShouldIssueTokens() await handler.Handle(command, ct); // Assert - tokenService.Verify(x => x.IssueTokens(User, RefreshToken), Times.Once()); + tokenService.Verify( + x => x.IssueTokens(User, RefreshToken), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs index 97608929c..a19ba6ba0 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs @@ -41,13 +41,16 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.CreateAsync( - It.Is(x => - x.Username == command.Username - && x.AccountId == ValidAccountId + service.Verify( + x => x.CreateAsync( + It.Is(x => + x.Username == command.Username + && x.AccountId == ValidAccountId + ), + command.Password ), - command.Password - ), Times.Once()); + Times.Once() + ); } [Fact] @@ -67,16 +70,19 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendCommandAsync( - It.Is(x => - x.Role == command.Role - && x.Username == command.Username - && x.Email == command.Email - && x.FirstName == command.FirstName - && x.LastName == command.LastName + sender.Verify( + x => x.SendCommandAsync( + It.Is(x => + x.Role == command.Role + && x.Username == command.Username + && x.Email == command.Email + && x.FirstName == command.FirstName + && x.LastName == command.LastName + ), + ct ), - ct - ), Times.Once()); + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs index 8184f130c..9e3dff83d 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs @@ -32,6 +32,9 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.ResetPasswordAsync(user.Email.Value, Token, MinValidPassword), Times.Once()); + service.Verify( + x => x.ResetPasswordAsync(user.Email.Value, Token, MinValidPassword), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs index fe87bb206..5ba0e1479 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.GeneratePasswordResetTokenAsync(user.Email.Value), Times.Once()); + service.Verify( + x => x.GeneratePasswordResetTokenAsync(user.Email.Value), + Times.Once() + ); } [Fact] @@ -49,13 +52,16 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => - x.Email == user.Email.Value - && x.Endpoint.Contains(user.Email.Value) - && x.Endpoint.Contains(Token) - && x.Endpoint.Contains(PreferredUrl) - ) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => + x.Email == user.Email.Value + && x.Endpoint.Contains(user.Email.Value) + && x.Endpoint.Contains(Token) + && x.Endpoint.Contains(PreferredUrl) + ) + ), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs index 8dbd2909c..3ffa7be98 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs @@ -62,11 +62,23 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.GetExistsByUsernameAsync(User.Username), Times.Once()); - service.Verify(x => x.GetExistsByEmailAsync(User.Email.Value), Times.Once()); + service.Verify( + x => x.GetExistsByUsernameAsync(User.Username), + Times.Once() + ); + service.Verify( + x => x.GetExistsByEmailAsync(User.Email.Value), + Times.Once() + ); - service.Verify(x => x.SaveRefreshTokensAsync(User), Times.Once()); - service.Verify(x => x.GetByUsernameAsync(User.Username), Times.Once()); + service.Verify( + x => x.SaveRefreshTokensAsync(User), + Times.Once() + ); + service.Verify( + x => x.GetByUsernameAsync(User.Username), + Times.Once() + ); } [Fact] @@ -91,7 +103,10 @@ public async Task Handle_ShouldCallGetByEmail_WhenUsernameDoesNotExist() await handler.Handle(command, ct); // Assert - service.Verify(x => x.GetByEmailAsync(User.Email.Value), Times.Once()); + service.Verify( + x => x.GetByEmailAsync(User.Email.Value), + Times.Once() + ); } [Fact] @@ -115,22 +130,31 @@ public async Task Handle_ShouldCallCreateUser_WhenUsernameAndEmailDoNotExist() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendCommandAsync( - It.Is(x => - x.Role == command.Role - && x.Username == command.Username - && x.Email == command.Email + sender.Verify( + x => x.SendCommandAsync( + It.Is(x => + x.Role == command.Role + && x.Username == command.Username + && x.Email == command.Email + ), + ct ), - ct - ), Times.Once()); - service.Verify(x => x.CreateSSOAsync( - It.Is(x => - x.Username == command.Username - && x.AccountId == ValidAccountId + Times.Once() + ); + service.Verify( + x => x.CreateSSOAsync( + It.Is(x => + x.Username == command.Username + && x.AccountId == ValidAccountId + ), + Provider ), - Provider - ), Times.Once()); - service.Verify(x => x.GetByUsernameAsync(User.Username), Times.Once()); + Times.Once() + ); + service.Verify( + x => x.GetByUsernameAsync(User.Username), + Times.Once() + ); } [Fact] @@ -151,10 +175,16 @@ public async Task Handle_ShouldIssueTokens() await handler.Handle(command, ct); // Assert - tokenService.Verify(x => x.IssueRefreshToken( - It.IsAny>() - ), Times.Once()); - tokenService.Verify(x => x.IssueTokens(User, RefreshToken), Times.Once()); + tokenService.Verify( + x => x.IssueRefreshToken( + It.IsAny>() + ), + Times.Once() + ); + tokenService.Verify( + x => x.IssueTokens(User, RefreshToken), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs index ba9efa2e5..27b2cdb05 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs @@ -37,10 +37,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Username == MaxValidUsername), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Username == MaxValidUsername), + ct + ), + Times.Once() + ); } [Fact] @@ -53,11 +56,14 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => - x.TrackViewedProducts == !InitialTrackViewedProducts - && x.Id == ValidAccountId - ) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => + x.TrackViewedProducts == !InitialTrackViewedProducts + && x.Id == ValidAccountId + ) + ), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs index 52bc85b6e..f65fe678e 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs @@ -36,8 +36,14 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.GetByUsernameAsync(user.Username), Times.Once()); - service.Verify(x => x.GenerateEmailConfirmationTokenAsync(user.Username), Times.Once()); + service.Verify( + x => x.GetByUsernameAsync(user.Username), + Times.Once() + ); + service.Verify( + x => x.GenerateEmailConfirmationTokenAsync(user.Username), + Times.Once() + ); } [Fact] @@ -50,10 +56,13 @@ public async Task Handle_ShouldRaiseEvents() await handler.Handle(command, ct); // Assert - raiser.Verify(x => x.RaiseApplicationEventAsync( - It.Is(x => - x.Email == user.Email.Value - ) - ), Times.Once()); + raiser.Verify( + x => x.RaiseApplicationEventAsync( + It.Is(x => + x.Email == user.Email.Value + ) + ), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs index 0e22e2860..6dc774a31 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs @@ -46,8 +46,14 @@ public async Task Handle_ShouldCallService() await handler.Handle(command, ct); // Assert - service.Verify(x => x.GetByUsernameAsync(User.Username), Times.Once()); - service.Verify(x => x.ConfirmEmailAsync(User.Username, Token), Times.Once()); + service.Verify( + x => x.GetByUsernameAsync(User.Username), + Times.Once() + ); + service.Verify( + x => x.ConfirmEmailAsync(User.Username, Token), + Times.Once() + ); } [Fact] @@ -60,10 +66,16 @@ public async Task Handle_ShouldIssueTokens() await handler.Handle(command, ct); // Assert - tokenService.Verify(x => x.IssueRefreshToken( - It.IsAny>() - ), Times.Once()); - tokenService.Verify(x => x.IssueTokens(User, RefreshToken), Times.Once()); + tokenService.Verify( + x => x.IssueRefreshToken( + It.IsAny>() + ), + Times.Once() + ); + tokenService.Verify( + x => x.IssueTokens(User, RefreshToken), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs index 1cc3a77bd..62e3e6350 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs @@ -26,6 +26,9 @@ public async Task Handle_ShouldSendEmails() await handler.HandleAsync(@event); // Assert - email.Verify(x => x.SendVerificationEmailAsync(Email, Endpoint, ct), Times.Once()); + email.Verify( + x => x.SendVerificationEmailAsync(Email, Endpoint, ct), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs index cc4e28d67..acc6589bd 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs @@ -26,6 +26,9 @@ public async Task Handle_ShouldSendEmails() await handler.HandleAsync(@event); // Assert - email.Verify(x => x.SendForgotPasswordEmailAsync(Email, Endpoint, ct), Times.Once()); + email.Verify( + x => x.SendForgotPasswordEmailAsync(Email, Endpoint, ct), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs index a415acd1c..682791e3f 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs @@ -29,6 +29,9 @@ public async Task Handle_ShouldCallService() await handler.HandleAsync(@event); // Assert - service.Verify(x => x.CreateAsync(ValidRole), Times.Once()); + service.Verify( + x => x.CreateAsync(ValidRole), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs index 8626ce9e6..86c08066c 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs @@ -26,6 +26,9 @@ public async Task Handle_ShouldCallService() await handler.HandleAsync(@event); // Assert - service.Verify(x => x.DeleteAsync(ValidRole), Times.Once()); + service.Verify( + x => x.DeleteAsync(ValidRole), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs index 87f72eb41..c1a69e28c 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs @@ -34,14 +34,17 @@ public async Task Handle_ShouldCallService() await handler.HandleAsync(@event); // Assert - service.Verify(x => x.CreateAsync( - It.Is(x => - x.Role == @event.Role - && x.Username == @event.Username - && x.Email.Value == @event.Email - && x.AccountId == @event.Id + service.Verify( + x => x.CreateAsync( + It.Is(x => + x.Role == @event.Role + && x.Username == @event.Username + && x.Email.Value == @event.Email + && x.AccountId == @event.Id + ), + @event.Password ), - @event.Password - ), Times.Once()); + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs index bb578104a..cc8c6ca55 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs @@ -26,6 +26,9 @@ public async Task Handle_ShouldCallService() await handler.HandleAsync(@event); // Assert - service.Verify(x => x.DeleteAsync(ValidAccountId), Times.Once()); + service.Verify( + x => x.DeleteAsync(ValidAccountId), + Times.Once() + ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs b/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs index 8556422f4..ac2148ac5 100644 --- a/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs @@ -39,7 +39,10 @@ public async Task Handle_ShouldCallService() await handler.Handle(query, ct); // Assert - service.Verify(x => x.GetByAccountIdAsync(user.AccountId), Times.Once()); + service.Verify( + x => x.GetByAccountIdAsync(user.AccountId), + Times.Once() + ); } [Fact] @@ -52,14 +55,20 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Username == user.Username), - ct - ), Times.Once()); - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Username == user.Username), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Username == user.Username), + ct + ), + Times.Once() + ); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Username == user.Username), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs index ee61610ea..7a391bbce 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs @@ -32,7 +32,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -45,7 +48,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs index 2d8aefed2..fe925c57b 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs @@ -32,7 +32,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -45,7 +48,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs index dfacd6ba4..9aaa6740b 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs @@ -32,7 +32,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -45,7 +48,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/NotificationRequestedHandlerUnitTests.cs b/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/Tests.cs similarity index 79% rename from tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/NotificationRequestedHandlerUnitTests.cs rename to tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/Tests.cs index ede39fef0..1bd104131 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/NotificationRequestedHandlerUnitTests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/Tests.cs @@ -55,16 +55,22 @@ public async Task Handle_ShouldPersistToDatabase_WhenSingleReceiver() await handler.HandleAsync(@event); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => - x.Type == @event.Type.ToString() - && x.Content == new NotificationContent(@event.Description, @event.Link) - && x.AuthorId == @event.AuthorId - && x.ReceiverId == @event.ReceiverIds.First() + writes.Verify( + x => x.AddAsync( + It.Is(x => + x.Type == @event.Type.ToString() + && x.Content == new NotificationContent(@event.Description, @event.Link) + && x.AuthorId == @event.AuthorId + && x.ReceiverId == @event.ReceiverIds.First() + ), + ct ), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -83,10 +89,13 @@ public async Task Handle_ShouldBulkInsert_WhenMultipleReceivers() await handler.HandleAsync(@event); // Assert - uow.Verify(x => x.InsertNotificationsAsync( - It.IsAny(), - ct - ), Times.Once()); + uow.Verify( + x => x.InsertNotificationsAsync( + It.IsAny(), + ct + ), + Times.Once() + ); } [Fact] @@ -105,10 +114,13 @@ public async Task Handle_ShouldSendRequests() await handler.HandleAsync(@event); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidAuthorId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidAuthorId), + ct + ), + Times.Once() + ); } [Fact] @@ -127,11 +139,14 @@ public async Task Handle_ShouldNotifySubscribers() await handler.HandleAsync(@event); // Assert - notifier.Verify(x => x.NotifyUsersAsync( - @event.ReceiverIds, - It.IsAny(), - It.IsAny(), - ct - ), Times.Once()); + notifier.Verify( + x => x.NotifyUsersAsync( + @event.ReceiverIds, + It.IsAny(), + It.IsAny(), + ct + ), + Times.Once() + ); } } diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs index a1b9a57e6..338c3cdc7 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs @@ -37,7 +37,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.CountByStatusAsync(ValidReceiverId, ct), Times.Once()); + reads.Verify( + x => x.CountByStatusAsync(ValidReceiverId, ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs index 59d019402..3a0692056 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs @@ -59,11 +59,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.AllAsync( - It.IsAny(), - false, - ct - ), Times.Once()); + reads.Verify( + x => x.AllAsync( + It.IsAny(), + false, + ct + ), + Times.Once() + ); } [Fact] @@ -80,10 +83,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(query, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Ids.Length == notifications.Length), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Ids.Length == notifications.Length), + ct + ), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs index 424be781c..6dd3dd7d5 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs @@ -44,17 +44,23 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync( - It.Is(x => - x.Scale == MaxValidScale - && x.Infill == MaxValidInfill - && x.Volume == MaxValidVolume - && x.Color == ValidColor - && x.MaterialId == ValidMaterialId + writes.Verify( + x => x.AddAsync( + It.Is(x => + x.Scale == MaxValidScale + && x.Infill == MaxValidInfill + && x.Volume == MaxValidVolume + && x.Color == ValidColor + && x.MaterialId == ValidMaterialId + ), + ct ), - ct - ), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs index bec0344c7..9bdc2249f 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -49,8 +52,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.Remove(customization), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove(customization), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs index 9fe84ffc9..1df01a8a8 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs @@ -41,7 +41,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -61,7 +64,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs index 34ee5c594..4115504bb 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs @@ -23,10 +23,10 @@ public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); - reads.Setup(v => v.SingleByIdAsync(ValidId, false, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(customization); - materialReads.Setup(v => v.SingleByIdAsync(ValidMaterialId, false, ct)) + materialReads.Setup(x => x.SingleByIdAsync(ValidMaterialId, false, ct)) .ReturnsAsync(material); } @@ -40,8 +40,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(v => v.SingleByIdAsync(ValidId, false, ct), Times.Once()); - materialReads.Verify(v => v.SingleByIdAsync(ValidMaterialId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); + materialReads.Verify( + x => x.SingleByIdAsync(ValidMaterialId, false, ct), + Times.Once() + ); } [Fact] @@ -54,8 +60,14 @@ public async Task Handle_ShouldCalculateWeightAndCost() await handler.Handle(query, ct); // Assert - calculator.Verify(v => v.CalculateWeight(customization, material), Times.Once()); - calculator.Verify(v => v.CalculateCost(customization, material), Times.Once()); + calculator.Verify( + x => x.CalculateWeight(customization, material), + Times.Once() + ); + calculator.Verify( + x => x.CalculateCost(customization, material), + Times.Once() + ); } [Fact] @@ -75,7 +87,7 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() { // Arrange - reads.Setup(v => v.SingleByIdAsync(ValidId, false, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Customization); GetCustomizationByIdQuery query = new(ValidId); @@ -91,7 +103,7 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenMaterialNotFound() { // Arrange - materialReads.Setup(v => v.SingleByIdAsync(ValidMaterialId, false, ct)) + materialReads.Setup(x => x.SingleByIdAsync(ValidMaterialId, false, ct)) .ReturnsAsync(null as Material); GetCustomizationByIdQuery query = new(ValidId); diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs index 041b5dd2c..1dc27b85c 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs @@ -49,8 +49,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(v => v.AllAsync(ids, false, ct), Times.Once()); - materialReads.Verify(v => v.AllByIdsAsync(materialIds, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(ids, false, ct), + Times.Once() + ); + materialReads.Verify( + x => x.AllByIdsAsync(materialIds, false, ct), + Times.Once() + ); } [Fact] @@ -63,10 +69,13 @@ public async Task Handle_ShouldCalculateCost() await handler.Handle(query, ct); // Assert - calculator.Verify(v => v.CalculateCost( - It.Is(x => customizations.Contains(x)), - It.Is(x => materials.Values.Contains(x)) - ), Times.Exactly(customizations.Length)); + calculator.Verify( + x => x.CalculateCost( + It.Is(x => customizations.Contains(x)), + It.Is(x => materials.Values.Contains(x)) + ), + Times.Exactly(customizations.Length) + ); } [Fact] diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs index 99c4711e5..6d421647f 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs @@ -45,8 +45,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(v => v.SingleByIdAsync(ValidId, false, ct), Times.Once()); - materialReads.Verify(v => v.SingleByIdAsync(ValidMaterialId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); + materialReads.Verify( + x => x.SingleByIdAsync(ValidMaterialId, false, ct), + Times.Once() + ); } [Fact] @@ -59,7 +65,10 @@ public async Task Handle_ShouldCalculateCost() await handler.Handle(query, ct); // Assert - calculator.Verify(v => v.CalculateCost(customization, material), Times.Once()); + calculator.Verify( + x => x.CalculateCost(customization, material), + Times.Once() + ); } [Fact] @@ -79,7 +88,7 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() { // Arrange - reads.Setup(v => v.SingleByIdAsync(ValidId, false, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Customization); GetCustomizationCostByIdQuery query = new(ValidId); @@ -95,7 +104,7 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenMaterialNotFound() { // Arrange - materialReads.Setup(v => v.SingleByIdAsync(ValidMaterialId, false, ct)) + materialReads.Setup(x => x.SingleByIdAsync(ValidMaterialId, false, ct)) .ReturnsAsync(null as Material); GetCustomizationCostByIdQuery query = new(ValidId); diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs index cb6555f60..3366ed0a1 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs @@ -29,7 +29,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(x => x.ExistsByIdAsync(ValidId, ct), Times.Once()); + reads.Verify( + x => x.ExistsByIdAsync(ValidId, ct), + Times.Once() + ); } [Theory] diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs index c6911d039..d08619007 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs @@ -29,10 +29,10 @@ public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); - reads.Setup(v => v.AllAsync(ids, false, ct)) + reads.Setup(x => x.AllAsync(ids, false, ct)) .ReturnsAsync(customizations); - materialReads.Setup(v => v.AllByIdsAsync(materialIds, false, ct)) + materialReads.Setup(x => x.AllByIdsAsync(materialIds, false, ct)) .ReturnsAsync(materials); calculator.Setup(x => x.CalculateWeight(It.IsAny(), It.IsAny())) @@ -49,8 +49,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(v => v.AllAsync(ids, false, ct), Times.Once()); - materialReads.Verify(v => v.AllByIdsAsync(materialIds, false, ct), Times.Once()); + reads.Verify( + x => x.AllAsync(ids, false, ct), + Times.Once() + ); + materialReads.Verify( + x => x.AllByIdsAsync(materialIds, false, ct), + Times.Once() + ); } [Fact] @@ -63,10 +69,13 @@ public async Task Handle_ShouldCalculateWeight() await handler.Handle(query, ct); // Assert - calculator.Verify(v => v.CalculateWeight( - It.Is(x => customizations.Contains(x)), - It.Is(x => materials.Values.Contains(x)) - ), Times.Exactly(customizations.Length)); + calculator.Verify( + x => x.CalculateWeight( + It.Is(x => customizations.Contains(x)), + It.Is(x => materials.Values.Contains(x)) + ), + Times.Exactly(customizations.Length) + ); } [Fact] diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs index a35a0263f..1a7b95a17 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs @@ -25,10 +25,10 @@ public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); - reads.Setup(v => v.SingleByIdAsync(ValidId, false, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(customization); - materialReads.Setup(v => v.SingleByIdAsync(ValidMaterialId, false, ct)) + materialReads.Setup(x => x.SingleByIdAsync(ValidMaterialId, false, ct)) .ReturnsAsync(material); calculator.Setup(x => x.CalculateWeight(It.IsAny(), It.IsAny())) @@ -45,8 +45,14 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - reads.Verify(v => v.SingleByIdAsync(ValidId, false, ct), Times.Once()); - materialReads.Verify(v => v.SingleByIdAsync(ValidMaterialId, false, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, false, ct), + Times.Once() + ); + materialReads.Verify( + x => x.SingleByIdAsync(ValidMaterialId, false, ct), + Times.Once() + ); } [Fact] @@ -59,7 +65,10 @@ public async Task Handle_ShouldCalculateWeight() await handler.Handle(query, ct); // Assert - calculator.Verify(v => v.CalculateWeight(customization, material), Times.Once()); + calculator.Verify( + x => x.CalculateWeight(customization, material), + Times.Once() + ); } [Fact] @@ -79,7 +88,7 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() { // Arrange - reads.Setup(v => v.SingleByIdAsync(ValidId, false, ct)) + reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Customization); GetCustomizationWeightByIdQuery query = new(ValidId); @@ -95,7 +104,7 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenMaterialNotFound() { // Arrange - materialReads.Setup(v => v.SingleByIdAsync(ValidMaterialId, false, ct)) + materialReads.Setup(x => x.SingleByIdAsync(ValidMaterialId, false, ct)) .ReturnsAsync(null as Material); GetCustomizationWeightByIdQuery query = new(ValidId); diff --git a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs index 3463fd701..7a5316a5b 100644 --- a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs @@ -47,10 +47,13 @@ public async Task Handle_ShouldSendRequests() await handler.Handle(command, ct); // Assert - sender.Verify(x => x.SendQueryAsync( - It.Is(x => x.Id == ValidTextureId), - ct - ), Times.Once()); + sender.Verify( + x => x.SendQueryAsync( + It.Is(x => x.Id == ValidTextureId), + ct + ), + Times.Once() + ); } [Fact] @@ -68,8 +71,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.AddAsync(It.Is(x => x.Id == material.Id), ct), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.AddAsync(It.Is(x => x.Id == material.Id), ct), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -105,6 +114,9 @@ public async Task Handle_ShouldUpdateCache() await handler.Handle(command, ct); // Assert - cache.Verify(x => x.UpdateAsync(ValidId, It.Is(x => x.Id == material.Id)), Times.Once()); + cache.Verify( + x => x.UpdateAsync(ValidId, It.Is(x => x.Id == material.Id)), + Times.Once() + ); } } diff --git a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs index 63e2df53e..2a93ee077 100644 --- a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs @@ -35,7 +35,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -48,8 +51,14 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - writes.Verify(x => x.Remove(material), Times.Once()); - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + writes.Verify( + x => x.Remove(material), + Times.Once() + ); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -62,6 +71,9 @@ public async Task Handle_ShouldClearCache() await handler.Handle(command, ct); // Assert - cache.Verify(x => x.ClearAsync(ValidId), Times.Once()); + cache.Verify( + x => x.ClearAsync(ValidId), + Times.Once() + ); } } diff --git a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs index ffbb34520..f24a453a8 100644 --- a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs @@ -39,7 +39,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(command, ct); // Assert - reads.Verify(x => x.SingleByIdAsync(ValidId, true, ct), Times.Once()); + reads.Verify( + x => x.SingleByIdAsync(ValidId, true, ct), + Times.Once() + ); } [Fact] @@ -57,7 +60,10 @@ public async Task Handle_ShouldPersistToDatabase() await handler.Handle(command, ct); // Assert - uow.Verify(x => x.SaveChangesAsync(ct), Times.Once()); + uow.Verify( + x => x.SaveChangesAsync(ct), + Times.Once() + ); } [Fact] @@ -75,6 +81,9 @@ public async Task Handle_ShouldUpdateCache() await handler.Handle(command, ct); // Assert - cache.Verify(x => x.UpdateAsync(ValidId, material), Times.Once()); + cache.Verify( + x => x.UpdateAsync(ValidId, material), + Times.Once() + ); } } diff --git a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs index f5409882a..33ad6cd84 100644 --- a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs @@ -36,7 +36,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - cache.Verify(x => x.GetOrCreateAsync(It.IsAny>>>()), Times.Once()); + cache.Verify( + x => x.GetOrCreateAsync(It.IsAny>>>()), + Times.Once() + ); } [Fact] diff --git a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs index 4aaca629f..6ee247a07 100644 --- a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs @@ -34,7 +34,10 @@ public async Task Handle_ShouldQueryDatabase() await handler.Handle(query, ct); // Assert - cache.Verify(x => x.GetOrCreateAsync(ValidId, It.IsAny>>()), Times.Once()); + cache.Verify( + x => x.GetOrCreateAsync(ValidId, It.IsAny>>()), + Times.Once() + ); } [Fact] From c6071b9a5e1b81f6b9dcdb8ec663b86ad214fdcc Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Thu, 21 May 2026 02:02:01 +0300 Subject: [PATCH 08/15] Normalized `Assert.ThrowsAsync` calls --- .../Accounts/Commands/Internal/Delete/Tests.cs | 2 +- .../Accounts/Events/Application/Deleted/Tests.cs | 2 +- .../Accounts/Events/Application/Edited/Tests.cs | 2 +- .../Accounts/Queries/Internal/GetById/Tests.cs | 2 +- .../Accounts/Queries/Shared/GetEmail/Tests.cs | 2 +- .../Accounts/Queries/Shared/GetInfo/Tests.cs | 2 +- .../Accounts/Queries/Shared/GetUserRole/Tests.cs | 2 +- .../Queries/Shared/GetUsername/Single/Tests.cs | 2 +- .../ActiveCarts/Commands/Internal/Add/Tests.cs | 2 +- .../Commands/Internal/Purchase/Normal/Tests.cs | 2 +- .../Commands/Internal/Purchase/WithDelivery/Tests.cs | 2 +- .../Commands/Internal/Quantity/Decrease/Tests.cs | 4 ++-- .../Commands/Internal/Quantity/Increase/Tests.cs | 4 ++-- .../ActiveCarts/Commands/Internal/Remove/Tests.cs | 2 +- .../Commands/Internal/ToggleForDelivery/Tests.cs | 8 ++++---- .../ActiveCarts/Queries/Internal/GetSingle/Tests.cs | 4 ++-- .../PurchasedCarts/Commands/Internal/Create/Tests.cs | 2 +- .../Events/Application/DeliveryRequested/Tests.cs | 2 +- ...PaymentCompletedApplicationEventHandlerUnitTests.cs | 2 +- .../PurchasedCarts/Queries/Internal/GetById/Tests.cs | 2 +- .../Products/Commands/Internal/Admin/Remove/Tests.cs | 4 ++-- .../Products/Commands/Internal/Creator/Create/Tests.cs | 4 ++-- .../Products/Commands/Internal/Creator/Delete/Tests.cs | 4 ++-- .../Products/Commands/Internal/Creator/Edit/Tests.cs | 6 +++--- .../Commands/Internal/Designer/AddTag/Tests.cs | 2 +- .../Commands/Internal/Designer/RemoveTag/Tests.cs | 2 +- .../Commands/Internal/Designer/Report/Tests.cs | 6 +++--- .../Commands/Internal/Designer/Validate/Tests.cs | 6 +++--- .../Products/Events/Application/Viewed/Tests.cs | 2 +- .../Products/Queries/Internal/Creator/GetById/Tests.cs | 4 ++-- .../Queries/Internal/Designer/GetById/Tests.cs | 4 ++-- .../Products/Queries/Internal/Gallery/GetById/Tests.cs | 4 ++-- .../Application/Tags/Commands/Internal/Delete/Tests.cs | 2 +- .../Application/Tags/Commands/Internal/Edit/Tests.cs | 2 +- .../Customs/Commands/Internal/Admin/Remove/Tests.cs | 2 +- .../Commands/Internal/Admin/SetCategory/Tests.cs | 2 +- .../Customs/Commands/Internal/Customer/Create/Tests.cs | 2 +- .../Internal/Customer/Purchase/Normal/Tests.cs | 10 +++++----- .../Internal/Customer/Purchase/WithDelivery/Tests.cs | 10 +++++----- .../Commands/Internal/Customer/SetDelivery/Tests.cs | 2 +- .../Customs/Commands/Internal/Designer/Accept/Tests.cs | 4 ++-- .../Customs/Commands/Internal/Designer/Begin/Tests.cs | 4 ++-- .../Customs/Commands/Internal/Designer/Cancel/Tests.cs | 4 ++-- .../Customs/Commands/Internal/Designer/Finish/Tests.cs | 4 ++-- .../Customs/Commands/Internal/Designer/Report/Tests.cs | 4 ++-- .../Commands/Internal/Designer/SetCategory/Tests.cs | 4 ++-- .../Events/Application/DeliveryRequested/Tests.cs | 2 +- .../Events/Application/PaymentCompleted/Tests.cs | 2 +- .../Queries/Internal/Customers/GetById/Tests.cs | 4 ++-- .../Queries/Internal/Designers/GetById/Tests.cs | 6 +++--- .../Shipments/Commands/Internal/Cancel/Tests.cs | 4 ++-- .../Shipments/Commands/Shared/Create/Tests.cs | 4 ++-- .../Shipments/Queries/Internal/GetTrack/Tests.cs | 4 ++-- .../Shipments/Queries/Internal/GetWaybill/Tests.cs | 6 +++--- .../Application/Cads/Commands/Internal/Edit/Tests.cs | 2 +- .../Cads/Commands/Internal/SetCoords/Tests.cs | 2 +- .../Files/Application/Cads/Events/Application/Tests.cs | 2 +- .../Application/Images/Commands/Internal/Edit/Tests.cs | 2 +- .../Application/Images/Events/Application/Tests.cs | 2 +- .../Commands/Internal/Complete/Tests.cs | 2 +- .../IdempotencyKeys/Commands/Internal/Delete/Tests.cs | 2 +- .../IdempotencyKeys/Queries/Internal/Get/Tests.cs | 2 +- .../Application/Users/Commands/Internal/Login/Tests.cs | 6 +++--- .../Users/Commands/Internal/Logout/Tests.cs | 2 +- .../Users/Commands/Internal/Refresh/Tests.cs | 4 ++-- .../Users/Commands/Internal/Register/Tests.cs | 2 +- .../Users/Commands/Internal/VerifyEmail/Tests.cs | 2 +- .../Notifications/Commands/Internal/Hide/Tests.cs | 4 ++-- .../Notifications/Commands/Internal/Open/Tests.cs | 4 ++-- .../Notifications/Commands/Internal/Read/Tests.cs | 4 ++-- .../Customizations/Commands/Internal/Delete/Tests.cs | 2 +- .../Customizations/Commands/Internal/Edit/Tests.cs | 2 +- .../Customizations/Queries/Internal/GetById/Tests.cs | 4 ++-- .../Customizations/Queries/Shared/Cost/Single/Tests.cs | 4 ++-- .../Queries/Shared/Weight/Single/Tests.cs | 4 ++-- 75 files changed, 124 insertions(+), 124 deletions(-) diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs index 89f280269..a22f9a12e 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs @@ -90,7 +90,7 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs index 4006d8f97..61490bf0e 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs @@ -72,7 +72,7 @@ public async Task Handle_ShoulThrowException_WhenNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(@event) + () => handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs index 044e00ca6..259bfa2d0 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs @@ -76,7 +76,7 @@ public async Task Handle_ShoulThrowException_WhenNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(@event) + () => handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs index 16a99af36..dfd43688d 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs @@ -58,7 +58,7 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs index 1cf6c9784..d392c9d6b 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs @@ -60,7 +60,7 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs index a4d18d958..cf8b5ac5e 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs @@ -66,7 +66,7 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs index 51b6fcdee..f4c6dd9ad 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs @@ -58,7 +58,7 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs index 05e06a814..7101b855f 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs @@ -58,7 +58,7 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs index 8e24702e1..c4e86bd3f 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs @@ -110,7 +110,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound(CustomizationI // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs index e090f44db..edfe2f3ce 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs @@ -188,7 +188,7 @@ public async Task Handle_ShouldThrowException_WhenCartForDelivery() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs index cb8c01c76..f70e80f25 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs @@ -269,7 +269,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotForDelivery() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs index a79fe7ff3..fdcefea24 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs @@ -101,7 +101,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -118,7 +118,7 @@ public async Task Handle_ShouldThrowException_WhenItemNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs index 8c0fae608..dfcffd823 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs @@ -100,7 +100,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -117,7 +117,7 @@ public async Task Handle_ShouldThrowException_WhenItemNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs index d41eca75c..694a7bec4 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs @@ -77,7 +77,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs index 7be1652b1..2ce356180 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs @@ -160,7 +160,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -177,7 +177,7 @@ public async Task Handle_ShouldThrowException_WhenItemNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -199,7 +199,7 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -216,7 +216,7 @@ public async Task Handle_ShouldThrowException_WhenDeliveryMismatch() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs index 8c2333009..87bda2de2 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs @@ -60,7 +60,7 @@ public async Task Handle_ShouldThrowException_WhenCartItemNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -73,7 +73,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs index 1e4d7f7c6..6b23332f3 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs @@ -171,7 +171,7 @@ public async Task Handle_ShouldThrowException_WhenPurchasedCartNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs index 482c9eeb6..88326571c 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs @@ -115,7 +115,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(@event) + () => handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs index 9113e07ad..5aecf464b 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs @@ -160,7 +160,7 @@ public async Task Handle_ShouldThrowException_WhenNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(@event) + () => handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs index e950d7eff..dae942580 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs @@ -89,7 +89,7 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs index 067227391..ac27f2b70 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs @@ -117,7 +117,7 @@ public async Task Handle_ShouldThrowException_WhenAdminNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -132,7 +132,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs index 53d7cb36e..4315fdd72 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs @@ -336,7 +336,7 @@ public async Task Handle_ShouldThrowException_WhenCategoryNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -362,7 +362,7 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs index b8078033c..79b45eb0e 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs @@ -126,7 +126,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -141,7 +141,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs index a04e9e39e..e790413d2 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs @@ -160,7 +160,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -185,7 +185,7 @@ public async Task Handle_ShouldThrowException_WhenCategoryNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -208,7 +208,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs index 1850f4bc2..bf0bba6aa 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs @@ -90,7 +90,7 @@ public async Task Handle_ShouldThrow_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs index 1c7591d2f..ca9d18473 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs @@ -90,7 +90,7 @@ public async Task Handle_ShouldThrow_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs index 34c8adf4d..6af9100b8 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs @@ -123,7 +123,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -140,7 +140,7 @@ public async Task Handle_ShouldThrowException_WhenDesignerNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -155,7 +155,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs index 17248b0e6..e1baba60c 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs @@ -123,7 +123,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -140,7 +140,7 @@ public async Task Handle_ShouldThrowException_WhenDesignerNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -155,7 +155,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs index edcedc7b3..e46b900fa 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs @@ -233,7 +233,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(@event) + () => handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs index 9d7c3983c..5f35c6e33 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs @@ -98,7 +98,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -113,7 +113,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs index d38d3fccd..b19dee8cd 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs @@ -95,7 +95,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAndChecked() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -110,7 +110,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs index 431efefe5..8162c7e6b 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs @@ -129,7 +129,7 @@ public async Task Handle_ShouldThrowException_WhenStatusIsNotValid() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -144,7 +144,7 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs index ac9bdce21..3b47fa8f8 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs @@ -89,7 +89,7 @@ public async Task Handle_ShouldThrowException_WhenTagNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs index 83f4efa76..207d17e79 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs @@ -88,7 +88,7 @@ public async Task Handle_ShouldThrowException_WhenTagNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs index c39435c52..c3634df61 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs @@ -119,7 +119,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs index fa65b9264..0ddf16bd7 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs @@ -96,7 +96,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs index 4a7543b4d..9446cb142 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs @@ -173,7 +173,7 @@ public async Task Handle_ShouldThrowException_WhenBuyerNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs index 6088bce17..f827b3d02 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs @@ -154,7 +154,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -170,7 +170,7 @@ public async Task Handle_ShouldThrowException_WhenNotAccepted() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -187,7 +187,7 @@ public async Task Handle_ShouldThrowException_WhenNotFinished() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -203,7 +203,7 @@ public async Task Handle_ShouldThrowException_WhenForDelivery() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -218,7 +218,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs index 3f8d79a6a..bac69e0e3 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs @@ -241,7 +241,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -267,7 +267,7 @@ public async Task Handle_ShouldThrowException_WhenNotAccepted() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -294,7 +294,7 @@ public async Task Handle_ShouldThrowException_WhenNotFinished() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -319,7 +319,7 @@ public async Task Handle_ShouldThrowException_WhenNoForDelivery() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -344,7 +344,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs index e8afb3118..3d522895f 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs @@ -130,7 +130,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs index 6ba7192aa..059c97883 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs @@ -160,7 +160,7 @@ public async Task Handle_ShouldThrowException_WhenDesignerNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -179,7 +179,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs index 87627d53e..28329d09c 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs @@ -125,7 +125,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -144,7 +144,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs index eacae336a..8c6963dee 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs @@ -125,7 +125,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -144,7 +144,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs index 957b71f0f..f7036d571 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs @@ -168,7 +168,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -189,7 +189,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs index 4054c964b..ca969067d 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs @@ -145,7 +145,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -179,7 +179,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs index 3353690cf..c4017cb1c 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs @@ -99,7 +99,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -135,7 +135,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs index d776ffc2d..35e642ee1 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs @@ -166,7 +166,7 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(@event) + () => handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs index 3ac4f3ad8..0c3eec8ce 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs @@ -170,7 +170,7 @@ public async Task Handle_ShouldThrowException_WhenNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(@event) + () => handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs index c30d91cca..bbc06d97c 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs @@ -121,7 +121,7 @@ public async Task Handle_ShouldThrowException_WhenNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -134,7 +134,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorized() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs index 363e9ed73..f456bf0ac 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs @@ -111,7 +111,7 @@ public async Task Handle_ShouldThrowException_WhenNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -125,7 +125,7 @@ public async Task Handle_ShouldThrowException_WhenUnauthorized() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -137,7 +137,7 @@ public async Task Handle_ShouldNotThrowException_WhenPending() // Act Exception? ex = await Record.ExceptionAsync( - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); // Assert diff --git a/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs index 67b776486..aae99f6ba 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs @@ -87,7 +87,7 @@ public async Task Handle_ShouldThrowException_WhenShipmentStatusInvalid() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -101,7 +101,7 @@ public async Task Handle_ShouldThrowException_WhenShipmentNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs index b042e08e6..5475e4b8e 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs @@ -127,7 +127,7 @@ public async Task Handle_ShouldThrowException_WhenDeliveryDetailsInvalid() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -151,7 +151,7 @@ public async Task Handle_ShouldThrowException_WhenDesignerNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs index 6df392be4..f1139a240 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs @@ -82,7 +82,7 @@ public async Task Handle_ShouldThrowException_WhenShipmentStatusInvalid() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -96,7 +96,7 @@ public async Task Handle_ShouldThrowException_WhenShipmentNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs index 85f6c44f0..cd9b72e75 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs @@ -81,7 +81,7 @@ public async Task Handle_ShouldThrowException_WhenCallerNotHeadDesigner() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -95,7 +95,7 @@ public async Task Handle_ShouldThrowException_WhenShipmentStatusInvalid() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -109,7 +109,7 @@ public async Task Handle_ShouldThrowException_WhenShipmentNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs index 768b466c5..18f9a2ffc 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs @@ -99,7 +99,7 @@ public async Task Handle_ShouldThrowException_WhenCadNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs index 66ea75102..2d6da6377 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs @@ -131,7 +131,7 @@ public async Task Handle_ShouldThrowException_WhenCadNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs b/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs index b5712789d..f64a13ec9 100644 --- a/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs @@ -126,7 +126,7 @@ public async Task Handle_ShouldThrowException_WhenCadNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(@event) + () => handler.HandleAsync(@event) ); } } diff --git a/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs index 84a255d68..4cf5571a4 100644 --- a/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs @@ -99,7 +99,7 @@ public async Task Handle_ShouldThrowException_WhenImageNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs b/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs index 1132d105d..d0d328a98 100644 --- a/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs @@ -126,7 +126,7 @@ public async Task Handle_ShouldThrowException_WhenImageNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.HandleAsync(ie) + () => handler.HandleAsync(ie) ); } } diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs index 38c21a17d..e6beb9586 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs @@ -88,7 +88,7 @@ public async Task Handle_ShouldThrowException_WhenIdempotencyKeyNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs index 54cd9d4ab..509d63cee 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs @@ -87,7 +87,7 @@ public async Task Handle_ShouldThrowException_WhenIdempotencyKeyNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs index 5829eae6f..e5c5d3650 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs @@ -92,7 +92,7 @@ public async Task Handle_ShouldThrowException_WhenIdempotencyKeyNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs index 7cf862326..4c76d3718 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs @@ -126,7 +126,7 @@ public async Task Handle_ShouldThrowException_WhenPasswordIncorrect() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -146,7 +146,7 @@ public async Task Handle_ShouldThrowException_WhenUserLockedOut() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -167,7 +167,7 @@ public async Task Handle_ShouldThrowException_WhenUserNotVerified() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs index 5d165ee20..fceef5d67 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs @@ -49,7 +49,7 @@ public async Task Handle_ShouldThrowException_WhenMissingToken() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs index 88fe0daa6..2dc1dbcc4 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs @@ -87,7 +87,7 @@ public async Task Handle_ShouldThrowException_WhenMissingToken() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -111,7 +111,7 @@ public async Task Handle_ShouldThrowException_WhenTokenExpired() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs index a19ba6ba0..96bc558d8 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs @@ -106,7 +106,7 @@ public async Task Handle_ShouldThrowException_WhenRegisterUnsuccessfuly() // Assert await Assert.ThrowsAsync( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs index 6dc774a31..00b29f45b 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs @@ -103,7 +103,7 @@ public async Task Handle_ShouldThrowException_WhenEmailVerified() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs index 7a391bbce..4cf5174e8 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs @@ -64,7 +64,7 @@ public async Task Handle_ShouldThrow_WhenCallerUnauthorized() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -78,7 +78,7 @@ public async Task Handle_ShouldThrow_WhenNotificationNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs index fe925c57b..630431eb6 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs @@ -64,7 +64,7 @@ public async Task Handle_ShouldThrow_WhenCallerUnauthorized() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -78,7 +78,7 @@ public async Task Handle_ShouldThrow_WhenNotificationNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs index 9aaa6740b..d6eff8d01 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs @@ -64,7 +64,7 @@ public async Task Handle_ShouldThrow_WhenCallerUnauthorized() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } @@ -78,7 +78,7 @@ public async Task Handle_ShouldThrow_WhenNotificationNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs index 9bdc2249f..dbba9a6b1 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs @@ -72,7 +72,7 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs index 1df01a8a8..55bc3cc2b 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs @@ -87,7 +87,7 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(command, ct) + () => handler.Handle(command, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs index 4115504bb..71d0eb97c 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs @@ -95,7 +95,7 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -111,7 +111,7 @@ public async Task Handle_ShouldThrowException_WhenMaterialNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs index 6d421647f..1d07514c6 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs @@ -96,7 +96,7 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -112,7 +112,7 @@ public async Task Handle_ShouldThrowException_WhenMaterialNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs index 1a7b95a17..ecf54c674 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs @@ -96,7 +96,7 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } @@ -112,7 +112,7 @@ public async Task Handle_ShouldThrowException_WhenMaterialNotFound() // Assert await Assert.ThrowsAsync>( // Act - async () => await handler.Handle(query, ct) + () => handler.Handle(query, ct) ); } } From 5cf889faf6e5b7a6fbb759d1e6fed9dde1c4e243 Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Sun, 24 May 2026 00:25:16 +0300 Subject: [PATCH 09/15] Additional test refactorings - Centralized Request definition with non-destructive mutations - Normalized static properties to PascalCase --- ...ductHandler.cs => ProductViewedHandler.cs} | 2 +- ... => ActiveCartDeliveryRequestedHandler.cs} | 2 +- ...dler.cs => CartPaymentCompletedHandler.cs} | 2 +- .../Infrastructure/DependencyInjection.cs | 4 +- .../Sagas/PurchasedCartDeliveryPaymentSaga.cs | 4 +- ...r.cs => CustomDeliveryRequestedHandler.cs} | 2 +- ...er.cs => CustomPaymentCompletedHandler.cs} | 2 +- .../Infrastructure/DependencyInjection.cs | 4 +- .../Sagas/CustomDeliveryPaymentSaga.cs | 4 +- .../Commands/Internal/Create/Tests.cs | 39 ++--- .../Commands/Internal/Delete/Tests.cs | 14 +- .../Accounts/Commands/Shared/Create/Tests.cs | 26 ++-- .../Events/Application/Deleted/Tests.cs | 11 +- .../Events/Application/Edited/Tests.cs | 27 ++-- .../Events/Application/Viewed/Tests.cs | 12 +- .../Accounts/Queries/Internal/GetAll/Tests.cs | 20 +-- .../Queries/Internal/GetById/Tests.cs | 11 +- .../Queries/Internal/GetSortings/Tests.cs | 4 +- .../Accounts/Queries/Shared/GetEmail/Tests.cs | 14 +- .../Queries/Shared/GetExists/ById/Tests.cs | 8 +- .../Shared/GetExists/ByUsername/Tests.cs | 8 +- .../Accounts/Queries/Shared/GetInfo/Tests.cs | 14 +- .../Queries/Shared/GetUserRole/Tests.cs | 11 +- .../Queries/Shared/GetUsername/Batch/Tests.cs | 23 ++- .../Shared/GetUsername/Single/Tests.cs | 11 +- .../Shared/ViewedProducts/ById/Tests.cs | 9 +- .../Shared/ViewedProducts/ByName/Tests.cs | 14 +- .../Roles/Commands/Internal/Create/Tests.cs | 16 +- .../Roles/Commands/Internal/Delete/Tests.cs | 11 +- .../Roles/Queries/Internal/GetAll/Tests.cs | 8 +- .../Roles/Queries/Internal/GetById/Tests.cs | 8 +- .../Commands/Internal/Add/Tests.cs | 33 ++--- .../Internal/Purchase/Normal/Tests.cs | 28 ++-- .../Internal/Purchase/WithDelivery/Tests.cs | 76 +++------- .../Purchase/WithDelivery/Validator.cs | 93 +++++------- .../Internal/Quantity/Decrease/Tests.cs | 46 ++---- .../Internal/Quantity/Increase/Tests.cs | 47 ++---- .../Commands/Internal/Remove/Tests.cs | 21 +-- .../Internal/ToggleForDelivery/Tests.cs | 92 ++++-------- .../Application/ProductDeleted/Tests.cs | 13 +- .../Internal/CalculateShipment/Tests.cs | 21 ++- .../Queries/Internal/Count/Tests.cs | 8 +- .../Queries/Internal/GetAll/Tests.cs | 17 +-- .../Queries/Internal/GetSingle/Tests.cs | 15 +- .../Commands/Internal/Create/Tests.cs | 54 +++---- .../Application/DeliveryRequested/Tests.cs | 43 ++---- ...mpletedApplicationEventHandlerUnitTests.cs | 23 ++- .../Queries/Internal/Count/Carts/Tests.cs | 8 +- .../Queries/Internal/Count/Items/Tests.cs | 16 +- .../Queries/Internal/GetAll/Tests.cs | 31 ++-- .../Queries/Internal/GetById/Tests.cs | 14 +- .../Internal/GetPaymentStatuses/Tests.cs | 4 +- .../Queries/Internal/GetSortings/Tests.cs | 4 +- .../Data/PurchasedCarts/BaseUnitTests.cs | 4 +- .../Commands/Internal/Create/Tests.cs | 11 +- .../Commands/Internal/Delete/Tests.cs | 11 +- .../Commands/Internal/Edit/Tests.cs | 14 +- .../Queries/Internal/GetAll/Tests.cs | 8 +- .../Queries/Internal/GetById/Tests.cs | 8 +- .../Queries/Shared/BatchGetById/Tests.cs | 18 +-- .../Queries/Shared/GetById/Tests.cs | 8 +- .../Queries/Shared/GetExists/Tests.cs | 8 +- .../Commands/Internal/Admin/Remove/Tests.cs | 20 +-- .../Commands/Internal/Creator/Create/Tests.cs | 114 +++----------- .../Commands/Internal/Creator/Delete/Tests.cs | 20 +-- .../Commands/Internal/Creator/Edit/Tests.cs | 81 ++-------- .../Internal/Designer/AddTag/Tests.cs | 14 +- .../Internal/Designer/RemoveTag/Tests.cs | 14 +- .../Internal/Designer/Report/Tests.cs | 23 ++- .../Internal/Designer/Validate/Tests.cs | 23 ++- .../Events/Application/Created/Tests.cs | 5 +- .../Events/Application/Purchased/Tests.cs | 9 +- .../Events/Application/Viewed/Tests.cs | 35 ++--- .../Queries/Internal/Creator/Count/Tests.cs | 8 +- .../Queries/Internal/Creator/GetAll/Tests.cs | 64 +++----- .../Queries/Internal/Creator/GetById/Tests.cs | 17 +-- .../Internal/Creator/GetSortings/Tests.cs | 4 +- .../Queries/Internal/Designer/GetAll/Tests.cs | 77 ++++------ .../Internal/Designer/GetById/Tests.cs | 33 +++-- .../Internal/Designer/GetSortings/Tests.cs | 4 +- .../Queries/Internal/Gallery/GetAll/Tests.cs | 70 ++++----- .../Queries/Internal/Gallery/GetById/Tests.cs | 23 ++- .../Internal/Gallery/GetSortings/Tests.cs | 4 +- .../Queries/Shared/BatchCadIdById/Tests.cs | 41 +++-- .../Queries/Shared/BatchPriceById/Tests.cs | 40 +++-- .../Queries/Shared/GetExists/Tests.cs | 8 +- .../Tags/Commands/Internal/Create/Tests.cs | 11 +- .../Tags/Commands/Internal/Delete/Tests.cs | 16 +- .../Tags/Commands/Internal/Edit/Tests.cs | 14 +- .../Tags/Queries/Internal/GetAll/Tests.cs | 16 +- .../Tags/Queries/Internal/GetById/Tests.cs | 10 +- .../Commands/Internal/Admin/Remove/Tests.cs | 33 +---- .../Internal/Admin/SetCategory/Tests.cs | 27 +--- .../Internal/Customer/Create/Tests.cs | 55 ++----- .../Internal/Customer/Delete/Tests.cs | 26 +--- .../Commands/Internal/Customer/Edit/Tests.cs | 42 ++---- .../Customer/Purchase/Normal/Tests.cs | 32 ++-- .../Customer/Purchase/WithDelivery/Tests.cs | 140 +++--------------- .../Purchase/WithDelivery/Validator.cs | 116 +++++---------- .../Internal/Customer/SetDelivery/Tests.cs | 44 +----- .../Internal/Designer/Accept/Tests.cs | 46 ++---- .../Commands/Internal/Designer/Begin/Tests.cs | 40 +---- .../Internal/Designer/Cancel/Tests.cs | 40 +---- .../Internal/Designer/Finish/Tests.cs | 60 ++------ .../Internal/Designer/Report/Tests.cs | 56 ++----- .../Internal/Designer/SetCategory/Tests.cs | 49 ++---- .../Application/DeliveryRequested/Tests.cs | 67 +++------ .../Application/PaymentCompleted/Tests.cs | 22 +-- .../Customers/CalculateShipment/Tests.cs | 21 ++- .../Queries/Internal/Customers/Count/Tests.cs | 24 +-- .../Internal/Customers/GetById/Tests.cs | 22 ++- .../Internal/Designers/GetById/Tests.cs | 30 ++-- .../Queries/Internal/Shared/GetAll/Tests.cs | 34 ++--- .../Shared/GetPaymentStatuses/Tests.cs | 4 +- .../Internal/Shared/GetSortings/Tests.cs | 4 +- .../Customs/Data/Customs/BaseUnitTests.cs | 3 + .../Behaviors/Statuses/Accept/Tests.cs | 15 +- .../Customs/Behaviors/Statuses/Begin/Tests.cs | 15 +- .../Behaviors/Statuses/Cancel/Tests.cs | 11 +- .../Behaviors/Statuses/Complete/Tests.cs | 15 +- .../Behaviors/Statuses/Finish/Tests.cs | 15 +- .../Behaviors/Statuses/Remove/Tests.cs | 13 +- .../Behaviors/Statuses/Report/Tests.cs | 11 +- .../Domain/Customs/Create/WithId/Tests.cs | 6 +- .../Commands/Internal/Cancel/Tests.cs | 18 +-- .../Shipments/Commands/Shared/Create/Tests.cs | 55 ++----- .../Queries/Internal/GetAll/Tests.cs | 28 ++-- .../Queries/Internal/GetSortings/Tests.cs | 4 +- .../Queries/Internal/GetTrack/Tests.cs | 23 ++- .../Queries/Internal/GetWaybill/Tests.cs | 26 ++-- .../Queries/Shared/Calculate/Tests.cs | 34 ++--- .../Queries/Shared/Calculate/Validator.cs | 11 +- .../Cads/Commands/Internal/Create/Tests.cs | 11 +- .../Cads/Commands/Internal/Edit/Tests.cs | 17 +-- .../Cads/Commands/Internal/SetCoords/Tests.cs | 64 +++----- .../Shared/BatchDuplicateById/Tests.cs | 39 +++-- .../Cads/Events/Application/Tests.cs | 42 ++---- .../Internal/PresignedUrls/Get/Tests.cs | 13 +- .../Internal/PresignedUrls/Post/Tests.cs | 22 +-- .../Internal/PresignedUrls/Put/Tests.cs | 18 +-- .../Cads/Queries/Shared/Exists/Tests.cs | 8 +- .../Cads/Queries/Shared/IsPrintable/Tests.cs | 8 +- .../Images/Commands/Internal/Create/Tests.cs | 11 +- .../Images/Commands/Internal/Edit/Tests.cs | 17 +-- .../Images/Events/Application/Tests.cs | 40 +---- .../Internal/PresignedUrls/Get/Tests.cs | 13 +- .../Internal/PresignedUrls/Post/Tests.cs | 23 +-- .../Internal/PresignedUrls/Put/Tests.cs | 18 +-- .../Cads/Behaviors/CamCoordinates/Tests.cs | 10 +- .../Cads/Behaviors/PanCoordinates/Tests.cs | 10 +- .../Commands/Internal/Complete/Tests.cs | 32 ++-- .../Commands/Internal/Create/Tests.cs | 17 +-- .../Commands/Internal/Delete/Tests.cs | 24 +-- .../Queries/Internal/Get/Tests.cs | 23 +-- .../Commands/Internal/ChangeUsername/Tests.cs | 36 ++--- .../Users/Commands/Internal/Delete/Tests.cs | 14 +- .../Users/Commands/Internal/Login/Tests.cs | 58 ++------ .../Users/Commands/Internal/Logout/Tests.cs | 16 +- .../Users/Commands/Internal/Refresh/Tests.cs | 18 +-- .../Users/Commands/Internal/Register/Tests.cs | 54 +++---- .../Commands/Internal/ResetPassword/Tests.cs | 13 +- .../Internal/ResetPasswordEmail/Tests.cs | 10 +- .../Users/Commands/Internal/SSO/Tests.cs | 107 +++++-------- .../ToggleViewedProductsTracking/Tests.cs | 8 +- .../Internal/VerificationEmail/Tests.cs | 10 +- .../Commands/Internal/VerifyEmail/Tests.cs | 17 +-- .../Emails/EmailVerification/Tests.cs | 5 +- .../Application/Emails/PasswordReset/Tests.cs | 5 +- .../Events/Application/Roles/Created/Tests.cs | 11 +- .../Events/Application/Roles/Deleted/Tests.cs | 5 +- .../Events/Application/Users/Created/Tests.cs | 29 ++-- .../Events/Application/Users/Deleted/Tests.cs | 5 +- .../Queries/Internal/GetByUsername/Tests.cs | 14 +- .../Users/Queries/Shared/ClientUrl/Tests.cs | 5 +- .../Users/Behaviors/AddRefreshToken/Tests.cs | 2 +- .../Behaviors/RemoveRefreshToken/Tests.cs | 2 +- .../Commands/Internal/Hide/Tests.cs | 16 +- .../Commands/Internal/Open/Tests.cs | 16 +- .../Commands/Internal/Read/Tests.cs | 16 +- .../Events/NotificationRequested/Tests.cs | 54 +++---- .../Queries/Internal/Count/Tests.cs | 8 +- .../Queries/Internal/GetAll/Tests.cs | 58 +++----- .../Queries/Internal/GetSortings/Tests.cs | 4 +- .../Queries/Internal/GetStatuses/Tests.cs | 4 +- .../Data/Notifications/BaseUnitTests.cs | 4 + .../Behaviors/Statuses/Hide/Tests.cs | 9 +- .../Behaviors/Statuses/Open/Tests.cs | 21 ++- .../Behaviors/Statuses/Read/Tests.cs | 21 ++- .../Behaviors/Statuses/Unhide/Tests.cs | 21 ++- .../Commands/Internal/Create/Tests.cs | 26 ++-- .../Commands/Internal/Delete/Tests.cs | 11 +- .../Commands/Internal/Edit/Tests.cs | 39 ++--- .../Queries/Internal/GetById/Tests.cs | 19 +-- .../Queries/Shared/Cost/Batch/Tests.cs | 37 +++-- .../Queries/Shared/Cost/Single/Tests.cs | 19 +-- .../Queries/Shared/Exists/Tests.cs | 8 +- .../Queries/Shared/Weight/Batch/Tests.cs | 37 +++-- .../Queries/Shared/Weight/Single/Tests.cs | 19 +-- .../Commands/Internal/Create/Tests.cs | 39 ++--- .../Commands/Internal/Delete/Tests.cs | 11 +- .../Materials/Commands/Internal/Edit/Tests.cs | 31 ++-- .../Queries/Internal/GetAll/Tests.cs | 14 +- .../Queries/Internal/GetById/Tests.cs | 10 +- .../Data/Customizations/BaseUnitTests.cs | 2 +- 204 files changed, 1728 insertions(+), 3067 deletions(-) rename src/Modules/Accounts/Application/Accounts/Events/Application/{UserViewedProductHandler.cs => ProductViewedHandler.cs} (86%) rename src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/{ActiveCartDeliveryRequestedApplicationEventHandler.cs => ActiveCartDeliveryRequestedHandler.cs} (95%) rename src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/{CartPaymentCompletedApplicationEventHandler.cs => CartPaymentCompletedHandler.cs} (96%) rename src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/{CustomDeliveryRequestedApplicationEventHandler.cs => CustomDeliveryRequestedHandler.cs} (95%) rename src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/{CustomPaymentCompletedApplicationEventHandler.cs => CustomPaymentCompletedHandler.cs} (96%) diff --git a/src/Modules/Accounts/Application/Accounts/Events/Application/UserViewedProductHandler.cs b/src/Modules/Accounts/Application/Accounts/Events/Application/ProductViewedHandler.cs similarity index 86% rename from src/Modules/Accounts/Application/Accounts/Events/Application/UserViewedProductHandler.cs rename to src/Modules/Accounts/Application/Accounts/Events/Application/ProductViewedHandler.cs index e5965e141..f6869c540 100644 --- a/src/Modules/Accounts/Application/Accounts/Events/Application/UserViewedProductHandler.cs +++ b/src/Modules/Accounts/Application/Accounts/Events/Application/ProductViewedHandler.cs @@ -4,7 +4,7 @@ namespace CustomCADs.Modules.Accounts.Application.Accounts.Events.Application; -public class UserViewedProductHandler(IAccountWrites writes, IUnitOfWork uow) +public class ProductViewedHandler(IAccountWrites writes, IUnitOfWork uow) { public async Task HandleAsync(ProductViewedApplicationEvent @event) { diff --git a/src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandler.cs b/src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedHandler.cs similarity index 95% rename from src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandler.cs rename to src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedHandler.cs index f350896fa..919e6f03b 100644 --- a/src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedApplicationEventHandler.cs +++ b/src/Modules/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/ActiveCartDeliveryRequestedHandler.cs @@ -8,7 +8,7 @@ namespace CustomCADs.Modules.Carts.Application.PurchasedCarts.Events.Application.DeliveryRequested; -public class ActiveCartDeliveryRequestedApplicationEventHandler( +public class ActiveCartDeliveryRequestedHandler( IPurchasedCartReads reads, IUnitOfWork uow, IRequestSender sender diff --git a/src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandler.cs b/src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedHandler.cs similarity index 96% rename from src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandler.cs rename to src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedHandler.cs index eee1a5a20..43fbe955c 100644 --- a/src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandler.cs +++ b/src/Modules/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedHandler.cs @@ -10,7 +10,7 @@ namespace CustomCADs.Modules.Carts.Application.PurchasedCarts.Events.Application.PaymentCompleted; -public class CartPaymentCompletedApplicationEventHandler( +public class CartPaymentCompletedHandler( IPurchasedCartReads reads, IUnitOfWork uow, IRequestSender sender, diff --git a/src/Modules/Carts/Infrastructure/DependencyInjection.cs b/src/Modules/Carts/Infrastructure/DependencyInjection.cs index 3b82dfa4b..c02361bf4 100644 --- a/src/Modules/Carts/Infrastructure/DependencyInjection.cs +++ b/src/Modules/Carts/Infrastructure/DependencyInjection.cs @@ -10,7 +10,7 @@ public static class DependencyInjection { public void AddCartDeliveryPaymentSagaDependencies() => services - .AddScoped() - .AddScoped(); + .AddScoped() + .AddScoped(); } } diff --git a/src/Modules/Carts/Infrastructure/Sagas/PurchasedCartDeliveryPaymentSaga.cs b/src/Modules/Carts/Infrastructure/Sagas/PurchasedCartDeliveryPaymentSaga.cs index 8bfe24afa..0726ca28e 100644 --- a/src/Modules/Carts/Infrastructure/Sagas/PurchasedCartDeliveryPaymentSaga.cs +++ b/src/Modules/Carts/Infrastructure/Sagas/PurchasedCartDeliveryPaymentSaga.cs @@ -16,12 +16,12 @@ public class CartDeliveryPaymentSaga : Saga public static CartDeliveryPaymentSaga Start(CartPaymentStartedApplicationEvent msg) => new() { Id = msg.Id }; - public async Task Handle(ActiveCartDeliveryRequestedApplicationEvent msg, ActiveCartDeliveryRequestedApplicationEventHandler handler) + public async Task Handle(ActiveCartDeliveryRequestedApplicationEvent msg, ActiveCartDeliveryRequestedHandler handler) { await handler.HandleAsync(msg).ConfigureAwait(false); } - public async Task Handle(CartPaymentCompletedApplicationEvent msg, CartPaymentCompletedApplicationEventHandler handler) + public async Task Handle(CartPaymentCompletedApplicationEvent msg, CartPaymentCompletedHandler handler) { await handler.HandleAsync(msg).ConfigureAwait(false); diff --git a/src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandler.cs b/src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedHandler.cs similarity index 95% rename from src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandler.cs rename to src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedHandler.cs index 7e404d0cd..b702133c0 100644 --- a/src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedApplicationEventHandler.cs +++ b/src/Modules/Customs/Application/Customs/Events/Application/DeliveryRequested/CustomDeliveryRequestedHandler.cs @@ -7,7 +7,7 @@ namespace CustomCADs.Modules.Customs.Application.Customs.Events.Application.DeliveryRequested; -public class CustomDeliveryRequestedApplicationEventHandler( +public class CustomDeliveryRequestedHandler( ICustomReads reads, IUnitOfWork uow, IRequestSender sender diff --git a/src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandler.cs b/src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedHandler.cs similarity index 96% rename from src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandler.cs rename to src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedHandler.cs index f4ed4a4b1..91efe7ce2 100644 --- a/src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedApplicationEventHandler.cs +++ b/src/Modules/Customs/Application/Customs/Events/Application/PaymentCompleted/CustomPaymentCompletedHandler.cs @@ -10,7 +10,7 @@ namespace CustomCADs.Modules.Customs.Application.Customs.Events.Application.PaymentCompleted; -public class CustomPaymentCompletedApplicationEventHandler( +public class CustomPaymentCompletedHandler( ICustomReads reads, IUnitOfWork uow, IRequestSender sender, diff --git a/src/Modules/Customs/Infrastructure/DependencyInjection.cs b/src/Modules/Customs/Infrastructure/DependencyInjection.cs index df8b34b0b..f294cf5d5 100644 --- a/src/Modules/Customs/Infrastructure/DependencyInjection.cs +++ b/src/Modules/Customs/Infrastructure/DependencyInjection.cs @@ -10,7 +10,7 @@ public static class DependencyInjection { public void AddCustomDeliveryPaymentSagaDependencies() => services - .AddScoped() - .AddScoped(); + .AddScoped() + .AddScoped(); } } diff --git a/src/Modules/Customs/Infrastructure/Sagas/CustomDeliveryPaymentSaga.cs b/src/Modules/Customs/Infrastructure/Sagas/CustomDeliveryPaymentSaga.cs index f4530fb4a..6b80c8860 100644 --- a/src/Modules/Customs/Infrastructure/Sagas/CustomDeliveryPaymentSaga.cs +++ b/src/Modules/Customs/Infrastructure/Sagas/CustomDeliveryPaymentSaga.cs @@ -16,12 +16,12 @@ public class CustomDeliveryPaymentSaga : Saga public static CustomDeliveryPaymentSaga Start(CustomPaymentStartedApplicationEvent msg) => new() { Id = msg.Id }; - public async Task Handle(CustomDeliveryRequestedApplicationEvent msg, CustomDeliveryRequestedApplicationEventHandler handler) + public async Task Handle(CustomDeliveryRequestedApplicationEvent msg, CustomDeliveryRequestedHandler handler) { await handler.HandleAsync(msg).ConfigureAwait(false); } - public async Task Handle(CustomPaymentCompletedApplicationEvent msg, CustomPaymentCompletedApplicationEventHandler handler) + public async Task Handle(CustomPaymentCompletedApplicationEvent msg, CustomPaymentCompletedHandler handler) { await handler.HandleAsync(msg).ConfigureAwait(false); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs index 62594765e..7d0bc0d50 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Create/Tests.cs @@ -12,6 +12,15 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Commands.Internal.C public class Tests : Data.Accounts.BaseUnitTests { private readonly CreateAccountHandler handler; + private readonly CreateAccountCommand request = new( + Role: ValidRole, + Username: ValidUsername, + Email: ValidEmail1, + Password: ValidPassword, + FirstName: ValidFirstName, + LastName: ValidLastName + ); + private readonly Mock writes = new(); private readonly Mock uow = new(); private readonly Mock raiser = new(); @@ -36,17 +45,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateAccountCommand command = new( - Role: ValidRole, - Username: ValidUsername, - Email: ValidEmail1, - Password: ValidPassword, - FirstName: ValidFirstName, - LastName: ValidLastName - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -72,17 +73,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - CreateAccountCommand command = new( - Role: ValidRole, - Username: ValidUsername, - Email: ValidEmail1, - Password: ValidPassword, - FirstName: ValidFirstName, - LastName: ValidLastName - ); // Act - await handler.Handle(command, CancellationToken.None); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -102,17 +95,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldReturnResult() { // Arrange - CreateAccountCommand command = new( - Role: ValidRole, - Username: ValidUsername, - Email: ValidEmail1, - Password: ValidPassword, - FirstName: ValidFirstName, - LastName: ValidLastName - ); // Act - AccountId id = await handler.Handle(command, CancellationToken.None); + AccountId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs index a22f9a12e..0e7d38e66 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Internal/Delete/Tests.cs @@ -13,6 +13,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Commands.Internal.D public class Tests : Data.Accounts.BaseUnitTests { private readonly DeleteAccountHandler handler; + private readonly DeleteAccountCommand request = new(ValidId); + private readonly Mock raiser = new(); private readonly Mock uow = new(); private readonly Mock writes = new(); @@ -30,10 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DeleteAccountCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DeleteAccountCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -66,10 +66,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - DeleteAccountCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -85,12 +84,11 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Account); - DeleteAccountCommand command = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs index 2fdc9edfe..8a10779dc 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Commands/Shared/Create/Tests.cs @@ -11,6 +11,14 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Commands.Shared.Cre public class Tests : Data.Accounts.BaseUnitTests { private readonly CreateAccountHandler handler; + private readonly CreateAccountCommand request = new( + Role: ValidRole, + Username: ValidUsername, + Email: ValidEmail1, + FirstName: ValidFirstName, + LastName: ValidLastName + ); + private readonly Mock writes = new(); private readonly Mock uow = new(); @@ -34,16 +42,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateAccountCommand command = new( - Role: ValidRole, - Username: ValidUsername, - Email: ValidEmail1, - FirstName: ValidFirstName, - LastName: ValidLastName - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -69,16 +70,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - CreateAccountCommand command = new( - Role: ValidRole, - Username: ValidUsername, - Email: ValidEmail1, - FirstName: ValidFirstName, - LastName: ValidLastName - ); // Act - AccountId id = await handler.Handle(command, ct); + AccountId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs index 61490bf0e..5b8ee6a61 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Deleted/Tests.cs @@ -12,6 +12,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application. public class Tests : Data.Accounts.BaseUnitTests { private readonly UserDeletedHandler handler; + private readonly UserDeletedApplicationEvent request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock writes = new(); private readonly Mock uow = new(); @@ -30,10 +32,9 @@ public Tests() public async Task Handle_ShoulQueryDatabase() { // Arrange - UserDeletedApplicationEvent @event = new(ValidId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShoulQueryDatabase() public async Task Handle_ShoulPersistToDatabase() { // Arrange - UserDeletedApplicationEvent @event = new(ValidId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert writes.Verify( @@ -67,12 +67,11 @@ public async Task Handle_ShoulThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Account); - UserDeletedApplicationEvent @event = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.HandleAsync(@event) + () => handler.HandleAsync(request) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs index 259bfa2d0..b4f7aa16f 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Edited/Tests.cs @@ -11,6 +11,12 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application. public class Tests : Data.Accounts.BaseUnitTests { private readonly UserEditedHandler handler; + private readonly UserEditedApplicationEvent request = new( + Id: ValidId, + Username: null, + TrackViewedProducts: null + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); @@ -26,14 +32,9 @@ public Tests() public async Task Handle_ShoulQueryDatabase() { // Arrange - UserEditedApplicationEvent @event = new( - Id: ValidId, - Username: null, - TrackViewedProducts: null - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -46,14 +47,9 @@ public async Task Handle_ShoulQueryDatabase() public async Task Handle_ShoulPersistToDatabase() { // Arrange - UserEditedApplicationEvent @event = new( - Id: ValidId, - Username: null, - TrackViewedProducts: null - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert uow.Verify( @@ -67,16 +63,11 @@ public async Task Handle_ShoulThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Account); - UserEditedApplicationEvent @event = new( - Id: ValidId, - Username: null, - TrackViewedProducts: null - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.HandleAsync(@event) + () => handler.HandleAsync(request) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs index f6afbd753..47a10e974 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Events/Application/Viewed/Tests.cs @@ -2,7 +2,6 @@ using CustomCADs.Modules.Accounts.Domain.Repositories; using CustomCADs.Modules.Accounts.Domain.Repositories.Writes; using CustomCADs.Shared.Application.Events.Catalog; -using CustomCADs.Shared.Domain.TypedIds.Catalog; namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application.Viewed; @@ -10,11 +9,13 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Events.Application. public class Tests : Data.Accounts.BaseUnitTests { - private readonly UserViewedProductHandler handler; + private readonly ProductViewedHandler handler; + private readonly ProductViewedApplicationEvent request = new(ValidProductId, ValidId, ViewedAt); + private readonly Mock writes = new(); private readonly Mock uow = new(); - private static readonly DateTimeOffset viewedAt = DateTimeOffset.UtcNow; + private static readonly DateTimeOffset ViewedAt = DateTimeOffset.UtcNow; public Tests() { @@ -25,14 +26,13 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductViewedApplicationEvent @event = new(ValidProductId, ValidId, viewedAt); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert writes.Verify( - x => x.ViewProductAsync(ValidId, ValidProductId, viewedAt, ct), + x => x.ViewProductAsync(ValidId, ValidProductId, ViewedAt, ct), Times.Once() ); uow.Verify( diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs index 7be476bc2..8603ba487 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetAll/Tests.cs @@ -8,36 +8,37 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Internal.Ge public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAllAccountsHandler handler; + private readonly GetAllAccountsQuery request = new(Query.Pagination); + private readonly Mock reads = new(); - private readonly Account[] accounts = [ + private static readonly Account[] Accounts = [ CreateAccount(id: AccountId.New()), CreateAccount(id: AccountId.New()), CreateAccount(id: AccountId.New()), CreateAccount(id: AccountId.New()), ]; - private readonly AccountQuery query = new(Pagination: new(1, 1)); + private static readonly AccountQuery Query = new(Pagination: new(1, Accounts.Length)); public Tests() { handler = new(reads.Object); - reads.Setup(x => x.AllAsync(query, false, ct)) - .ReturnsAsync(new Result(1, accounts)); + reads.Setup(x => x.AllAsync(Query, false, ct)) + .ReturnsAsync(new Result(1, Accounts)); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAllAccountsQuery query = new(this.query.Pagination); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(this.query, false, ct), + x => x.AllAsync(Query, false, ct), Times.Once() ); } @@ -46,12 +47,11 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetAllAccountsQuery query = new(this.query.Pagination); // Act - Result accounts = await handler.Handle(query, ct); + Result accounts = await handler.Handle(request, ct); // Assert - Assert.Equal(accounts.Items.Select(r => r.Id), this.accounts.Select(r => r.Id)); + Assert.Equal(accounts.Items.Select(r => r.Id), Accounts.Select(r => r.Id)); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs index dfd43688d..39c3f4a7b 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetById/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Internal.Ge public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountByIdHandler handler; + private readonly GetAccountByIdQuery request = new(ValidId); + private readonly Mock reads = new(); public Tests() @@ -23,10 +25,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAccountByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -39,10 +40,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetAccountByIdQuery query = new(ValidId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, result.Id); @@ -53,12 +53,11 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Account); - GetAccountByIdQuery query = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/Tests.cs index 9f7114086..4e4efb663 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Internal/GetSortings/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Internal.Ge public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountSortingsHandler handler = new(); + private readonly GetAccountSortingsQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetAccountSortingsQuery query = new(); // Act - AccountSortingType[] sortings = await handler.Handle(query, ct); + AccountSortingType[] sortings = await handler.Handle(request, ct); // Assert Assert.Equal(sortings, Enum.GetValues()); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs index d392c9d6b..f2fc83f13 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetEmail/Tests.cs @@ -10,9 +10,11 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetE public class Tests : Data.Accounts.BaseUnitTests { private readonly GetUserEmailByIdHandler handler; + private readonly GetUserEmailByIdQuery request = new(ValidId); + private readonly Mock reads = new(); - private static readonly Account account = CreateAccount(); + private readonly Account account = CreateAccount(); public Tests() { @@ -25,10 +27,10 @@ public Tests() [Fact] public async Task Handle_ShouldQueryDatabase() { - GetUserEmailByIdQuery query = new(ValidId); + // Arrange // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -41,10 +43,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetUserEmailByIdQuery query = new(ValidId); // Act - string email = await handler.Handle(query, ct); + string email = await handler.Handle(request, ct); // Assert Assert.Equal(account.Email, email); @@ -55,12 +56,11 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Account); - GetUserEmailByIdQuery query = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs index 99dca1dd4..760b88236 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ById/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetE public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountExistsByIdHandler handler; + private readonly GetAccountExistsByIdQuery request = new(ValidId); + private readonly Mock reads = new(); public Tests() @@ -20,10 +22,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAccountExistsByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -39,10 +40,9 @@ public async Task Handle_ShouldReturnResult(bool exists) { // Arrange reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)).ReturnsAsync(exists); - GetAccountExistsByIdQuery query = new(ValidId); // Act - bool result = await handler.Handle(query, ct); + bool result = await handler.Handle(request, ct); // Assert Assert.Equal(exists, result); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs index a754513b2..157bae8ce 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetExists/ByUsername/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetE public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountExistsByUsernameHandler handler; + private readonly GetAccountExistsByUsernameQuery request = new(ValidUsername); + private readonly Mock reads = new(); public Tests() @@ -20,10 +22,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAccountExistsByUsernameQuery query = new(ValidUsername); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -39,10 +40,9 @@ public async Task Handle_ShouldReturnResult(bool exists) { // Arrange reads.Setup(x => x.ExistsByUsernameAsync(ValidUsername, ct)).ReturnsAsync(exists); - GetAccountExistsByUsernameQuery query = new(ValidUsername); // Act - bool result = await handler.Handle(query, ct); + bool result = await handler.Handle(request, ct); // Assert Assert.Equal(exists, result); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs index cf8b5ac5e..eeef6d479 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetInfo/Tests.cs @@ -10,9 +10,11 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetI public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountInfoByUsernameHandler handler; + private readonly GetAccountInfoByUsernameQuery request = new(ValidUsername); + private readonly Mock reads = new(); - private static readonly Account account = CreateAccount(); + private readonly Account account = CreateAccount(); public Tests() { @@ -25,10 +27,10 @@ public Tests() [Fact] public async Task Handle_ShouldQueryDatabase() { - GetAccountInfoByUsernameQuery query = new(ValidUsername); + // Arrange // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -41,10 +43,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetAccountInfoByUsernameQuery query = new(ValidUsername); // Act - AccountInfoDto info = await handler.Handle(query, ct); + AccountInfoDto info = await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -61,12 +62,11 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() { // Arrange reads.Setup(x => x.SingleByUsernameAsync(ValidUsername, false, ct)).ReturnsAsync(null as Account); - GetAccountInfoByUsernameQuery query = new(ValidUsername); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs index f4c6dd9ad..0751aab61 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUserRole/Tests.cs @@ -10,6 +10,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetU public class Tests : Data.Accounts.BaseUnitTests { private readonly GetUserRoleByIdHandler handler; + private readonly GetUserRoleByIdQuery request = new(ValidId); + private readonly Mock reads = new(); public Tests() @@ -23,10 +25,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetUserRoleByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -39,10 +40,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetUserRoleByIdQuery query = new(ValidId); // Act - string actualRole = await handler.Handle(query, ct); + string actualRole = await handler.Handle(request, ct); // Assert Assert.Equal(Data.Roles.TestData.ValidName, actualRole); @@ -53,12 +53,11 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Account); - GetUserRoleByIdQuery query = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs index e8e44010f..e4f429b9d 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Batch/Tests.cs @@ -12,18 +12,20 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetU public class Tests : Data.Accounts.BaseUnitTests { private readonly BatchGetUsernamesByIdHandler handler; + private readonly BatchGetUsernamesByIdQuery request = new(Ids); + private readonly Mock reads = new(); - private static readonly AccountId[] ids = [ValidId, ValidId, ValidId, ValidId]; - private static readonly string[] usernames = [CustomerUsername, ContributorUsername, DesignerUsername, HeadDesignerUsername, AdminUsername]; - private static readonly AccountQuery accountQuery = new(Pagination: new(1, ids.Length), Ids: ids); + private static readonly AccountId[] Ids = [ValidId, ValidId, ValidId, ValidId]; + private static readonly string[] Usernames = [CustomerUsername, ContributorUsername, DesignerUsername, HeadDesignerUsername, AdminUsername]; + private static readonly AccountQuery Query = new(Pagination: new(1, Ids.Length), Ids: Ids); public Tests() { handler = new(reads.Object); - reads.Setup(x => x.AllAsync(accountQuery, false, ct)).ReturnsAsync(new Result( - Count: ids.Length, + reads.Setup(x => x.AllAsync(Query, false, ct)).ReturnsAsync(new Result( + Count: Ids.Length, Items: [ CreateAccount(id: AccountId.New(), username: CustomerUsername), CreateAccount(id: AccountId.New(), username: ContributorUsername), @@ -38,14 +40,13 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - BatchGetUsernamesByIdQuery query = new(ids); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(accountQuery, false, ct), + x => x.AllAsync(Query, false, ct), Times.Once() ); } @@ -54,13 +55,11 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - BatchGetUsernamesByIdQuery query = new(ids); // Act - Dictionary result = await handler.Handle(query, ct); - string[] actualUsernames = [.. result.Select(kvp => kvp.Value)]; + Dictionary result = await handler.Handle(request, ct); // Assert - Assert.Equal(usernames, actualUsernames); + Assert.Equal(Usernames, result.Select(kvp => kvp.Value)); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs index 7101b855f..11d944837 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/GetUsername/Single/Tests.cs @@ -10,6 +10,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.GetU public class Tests : Data.Accounts.BaseUnitTests { private readonly GetUsernameByIdHandler handler; + private readonly GetUsernameByIdQuery request = new(ValidId); + private readonly Mock reads = new(); public Tests() @@ -23,10 +25,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetUsernameByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -39,10 +40,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetUsernameByIdQuery query = new(ValidId); // Act - string actualUsername = await handler.Handle(query, ct); + string actualUsername = await handler.Handle(request, ct); // Assert Assert.Equal(ValidUsername, actualUsername); @@ -53,12 +53,11 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Account); - GetUsernameByIdQuery query = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs index d0e0736f5..74a0f49fb 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ById/Tests.cs @@ -1,7 +1,6 @@ using CustomCADs.Modules.Accounts.Application.Accounts.Queries.Shared.ViewedProducts; using CustomCADs.Modules.Accounts.Domain.Repositories.Reads; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -using CustomCADs.Shared.Domain.TypedIds.Catalog; namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.ViewedProducts.ById; @@ -10,6 +9,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.View public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountViewedProductHandler handler; + private readonly GetAccountViewedProductQuery request = new(ValidId, ValidProductId); + private readonly Mock reads = new(); public Tests() @@ -23,10 +24,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAccountViewedProductQuery query = new(ValidId, ValidProductId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -46,10 +46,9 @@ public async Task Handle_ShouldReturnResult(bool expected) reads.Setup(x => x.ViewedProductsByIdAsync(ValidId, ct)) .ReturnsAsync([ValidProductId]); } - GetAccountViewedProductQuery query = new(ValidId, ValidProductId); // Act - bool actual = await handler.Handle(query, ct); + bool actual = await handler.Handle(request, ct); // Assert Assert.Equal(expected, actual); diff --git a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs index f4b556e82..f7860215c 100644 --- a/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Accounts/Queries/Shared/ViewedProducts/ByName/Tests.cs @@ -10,25 +10,26 @@ namespace CustomCADs.UnitTests.Accounts.Application.Accounts.Queries.Shared.View public class Tests : Data.Accounts.BaseUnitTests { private readonly GetAccountViewedProductsByUsernameHandler handler; + private readonly GetAccountViewedProductsByUsernameQuery request = new(ValidUsername); + private readonly Mock reads = new(); - private static readonly ViewedProduct[] expected = []; + private static readonly ViewedProduct[] Expected = []; public Tests() { handler = new(reads.Object); reads.Setup(x => x.ViewedProductsByUsernameAsync(ValidUsername, ct)) - .ReturnsAsync(expected); + .ReturnsAsync(Expected); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAccountViewedProductsByUsernameQuery query = new(ValidUsername); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -41,12 +42,11 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetAccountViewedProductsByUsernameQuery query = new(ValidUsername); // Act - ViewedProductDto[] products = await handler.Handle(query, ct); + ViewedProductDto[] products = await handler.Handle(request, ct); // Assert - Assert.Equal(expected.Select(x => x.ProductId), products.Select(x => x.Id)); + Assert.Equal(Expected.Select(x => x.ProductId), products.Select(x => x.Id)); } } diff --git a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs index f8a947d02..5b28ffb4e 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Create/Tests.cs @@ -13,12 +13,14 @@ namespace CustomCADs.UnitTests.Accounts.Application.Roles.Commands.Internal.Crea public class Tests : Data.Roles.BaseUnitTests { private readonly CreateRoleHandler handler; + private readonly CreateRoleCommand request = new(ValidName, ValidDescription); + private readonly Mock raiser = new(); private readonly Mock> cache = new(); private readonly Mock uow = new(); private readonly Mock writes = new(); - private static readonly Role role = CreateRole(id: ValidId); + private readonly Role role = CreateRole(id: ValidId); public Tests() { @@ -34,10 +36,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateRoleCommand command = new(ValidName, ValidDescription); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -57,10 +58,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldUpdateCache() { // Arrange - CreateRoleCommand command = new(ValidName, ValidDescription); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -73,10 +73,9 @@ public async Task Handle_ShouldUpdateCache() public async Task Handle_ShouldRaiseEvents() { // Arrange - CreateRoleCommand command = new(ValidName, ValidDescription); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -91,10 +90,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldReturnResult() { // Arrange - CreateRoleCommand command = new(ValidName, ValidDescription); // Act - RoleId id = await handler.Handle(command, ct); + RoleId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); diff --git a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs index 308333722..18102753d 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Commands/Internal/Delete/Tests.cs @@ -14,6 +14,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Roles.Commands.Internal.Dele public class Tests : Data.Roles.BaseUnitTests { private readonly DeleteRoleHandler handler; + private readonly DeleteRoleCommand request = new(ValidId); + private readonly Mock raiser = new(); private readonly Mock> cache = new(); private readonly Mock uow = new(); @@ -31,10 +33,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DeleteRoleCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -47,10 +48,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DeleteRoleCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -69,10 +69,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - DeleteRoleCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( diff --git a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs index 6ca1d02e8..ef1662f8c 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetAll/Tests.cs @@ -8,6 +8,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Roles.Queries.Internal.GetAl public class Tests : Data.Roles.BaseUnitTests { private readonly GetAllRolesHandler handler; + private readonly GetAllRolesQuery request = new(); + private readonly Mock reads = new(); private readonly Mock> cache = new(); @@ -31,10 +33,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - GetAllRolesQuery query = new(); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -49,10 +50,9 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - GetAllRolesQuery query = new(); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Equal(roles.Select(x => x.Id), result.Select(x => x.Id)); diff --git a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs index 26ec44149..6e09f997f 100644 --- a/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Accounts/Application/Roles/Queries/Internal/GetById/Tests.cs @@ -10,6 +10,8 @@ namespace CustomCADs.UnitTests.Accounts.Application.Roles.Queries.Internal.GetBy public class Tests : Data.Roles.BaseUnitTests { private readonly GetRoleByIdHandler handler; + private readonly GetRoleByIdQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock> cache = new(); @@ -27,10 +29,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - GetRoleByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - GetRoleByIdQuery query = new(ValidId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, result.Id); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs index c4e86bd3f..80d6ba927 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Add/Tests.cs @@ -13,6 +13,14 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.A public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly AddActiveCartItemHandler handler; + private static AddActiveCartItemCommand Request(CustomizationId? customizationId) + => new( + CallerId: ValidBuyerId, + CustomizationId: customizationId, + ForDelivery: customizationId is not null, + ProductId: ValidProductId + ); + private readonly Mock uow = new(); private readonly Mock> writes = new(); private readonly Mock sender = new(); @@ -37,15 +45,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase(CustomizationId? customizationId) { // Arrange - AddActiveCartItemCommand command = new( - CallerId: ValidBuyerId, - CustomizationId: customizationId, - ForDelivery: customizationId is not null, - ProductId: ValidProductId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(Request(customizationId), ct); // Assert uow.Verify( @@ -59,15 +61,9 @@ public async Task Handle_ShouldPersistToDatabase(CustomizationId? customizationI public async Task Handle_ShouldSendRequests(CustomizationId? customizationId) { // Arrange - AddActiveCartItemCommand command = new( - CallerId: ValidBuyerId, - CustomizationId: customizationId, - ForDelivery: customizationId is not null, - ProductId: ValidProductId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(Request(customizationId), ct); // Assert sender.Verify( @@ -100,17 +96,10 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound(CustomizationI ct )).ReturnsAsync(false); - AddActiveCartItemCommand command = new( - CallerId: ValidBuyerId, - CustomizationId: customizationId, - ForDelivery: customizationId is not null, - ProductId: ValidProductId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(Request(customizationId), ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs index edfe2f3ce..26db3e5ad 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/Normal/Tests.cs @@ -21,12 +21,14 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.P public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly PurchaseActiveCartHandler handler; + private readonly PurchaseActiveCartCommand request = new(PaymentMethodId, ValidBuyerId); + private readonly Mock reads = new(); private readonly Mock sender = new(); private readonly Mock payment = new(); private readonly Mock raiser = new(); - private static readonly string paymentMethodId = string.Empty; + private static readonly string PaymentMethodId = string.Empty; public Tests() { @@ -53,10 +55,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - PurchaseActiveCartCommand command = new(paymentMethodId, ValidBuyerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -73,10 +74,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - PurchaseActiveCartCommand command = new(paymentMethodId, ValidBuyerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -106,10 +106,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - PurchaseActiveCartCommand command = new(paymentMethodId, ValidBuyerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -130,15 +129,14 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldCallPayment() { // Arrange - PurchaseActiveCartCommand command = new(paymentMethodId, ValidBuyerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert payment.Verify( x => x.InitializeCartPayment( - It.Is(x => x == paymentMethodId), + It.Is(x => x == PaymentMethodId), It.Is(x => x == ValidBuyerId), It.IsAny(), It.IsAny(), @@ -155,7 +153,7 @@ public async Task Handle_ShouldReturnResult() // Arrange PaymentDto expected = new(string.Empty, Message: "Payment Status Message"); payment.Setup(x => x.InitializeCartPayment( - It.Is(x => x == paymentMethodId), + It.Is(x => x == PaymentMethodId), It.Is(x => x == ValidBuyerId), It.IsAny(), It.IsAny(), @@ -163,10 +161,8 @@ public async Task Handle_ShouldReturnResult() ct )).ReturnsAsync(expected); - PurchaseActiveCartCommand command = new(paymentMethodId, ValidBuyerId); - // Act - PaymentDto actual = await handler.Handle(command, ct); + PaymentDto actual = await handler.Handle(request, ct); // Assert Assert.Equal(expected, actual); @@ -183,12 +179,10 @@ public async Task Handle_ShouldThrowException_WhenCartForDelivery() CreateItemWithDelivery(), ]); - PurchaseActiveCartCommand command = new(paymentMethodId, ValidBuyerId); - // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs index f70e80f25..dd750b7bd 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Tests.cs @@ -25,15 +25,23 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.P public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly PurchaseActiveCartWithDeliveryHandler handler; + private readonly PurchaseActiveCartWithDeliveryCommand request = new( + PaymentMethodId: PaymentMethodId, + ShipmentService: ShipmentService, + CallerId: ValidBuyerId, + Address: Address, + Contact: Contact + ); + private readonly Mock reads = new(); private readonly Mock sender = new(); private readonly Mock payment = new(); private readonly Mock raiser = new(); - private static readonly string paymentMethodId = string.Empty; - private static readonly string shipmentService = string.Empty; - private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); - private static readonly ContactDto contact = new(null, null); + private static readonly string PaymentMethodId = string.Empty; + private static readonly string ShipmentService = string.Empty; + private static readonly AddressDto Address = new("Bulgaria", "Burgas", "Slivnitsa"); + private static readonly ContactDto Contact = new(null, null); public Tests() { @@ -78,16 +86,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - ShipmentService: shipmentService, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -104,16 +105,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - ShipmentService: shipmentService, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -157,21 +151,14 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldCallPayment() { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert payment.Verify( x => x.InitializeCartPayment( - It.Is(x => x == paymentMethodId), + It.Is(x => x == PaymentMethodId), It.Is(x => x == ValidBuyerId), It.IsAny(), It.IsAny(), @@ -186,16 +173,9 @@ public async Task Handle_ShouldCallPayment() public async Task Handle_ShouldRaiseEvents() { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - ShipmentService: shipmentService, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -224,7 +204,7 @@ public async Task Handle_ShouldReturnResult() // Arrange PaymentDto expected = new(string.Empty, Message: "Payment Status Message"); payment.Setup(x => x.InitializeCartPayment( - It.Is(x => x == paymentMethodId), + It.Is(x => x == PaymentMethodId), It.Is(x => x == ValidBuyerId), It.IsAny(), It.IsAny(), @@ -232,16 +212,8 @@ public async Task Handle_ShouldReturnResult() ct )).ReturnsAsync(expected); - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - ShipmentService: shipmentService, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); - // Act - PaymentDto actual = await handler.Handle(command, ct); + PaymentDto actual = await handler.Handle(request, ct); // Assert Assert.Equal(expected, actual); @@ -258,18 +230,10 @@ public async Task Handle_ShouldThrowException_WhenCartNotForDelivery() CreateItem(productId: ProductId.New()), ]); - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - ShipmentService: shipmentService, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); - // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Validator.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Validator.cs index 73b39a2df..17b28d507 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Validator.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Purchase/WithDelivery/Validator.cs @@ -1,4 +1,5 @@ using CustomCADs.Modules.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; +using CustomCADs.Shared.Application.Dtos.Delivery; using FluentValidation.TestHelper; namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Purchase.WithDelivery; @@ -8,22 +9,26 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.P public class Validator : Data.ActiveCarts.BaseUnitTests { private readonly PurchaseActiveCartWithDeliveryValidator validator = new(); + private static PurchaseActiveCartWithDeliveryCommand Request(string paymentMethodId, string shipmentService, AddressDto address, ContactDto contact) + => new( + PaymentMethodId: paymentMethodId, + CallerId: ValidBuyerId, + ShipmentService: shipmentService, + Address: address, + Contact: contact + ); [Theory] [ClassData(typeof(ValidData))] public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, shipmentService, new(country, city, street), new(phone, email)), + cancellationToken: ct + ); // Assert Assert.True(result.IsValid); @@ -38,16 +43,12 @@ public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, public async Task Validate_ShouldBeInvalid_WhenCartIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, shipmentService, new(country, city, street), new(phone, email)), + cancellationToken: ct + ); // Assert Assert.False(result.IsValid); @@ -58,16 +59,12 @@ public async Task Validate_ShouldBeInvalid_WhenCartIsNotValid(string paymentMeth public async Task Validate_ShouldReturnProperErrors_WhenShipmentServiceIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, shipmentService, new(country, city, street), new(phone, email)), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.ShipmentService); @@ -78,16 +75,12 @@ public async Task Validate_ShouldReturnProperErrors_WhenShipmentServiceIsNotVali public async Task Validate_ShouldReturnProperErrors_WhenCountryIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, shipmentService, new(country, city, street), new(phone, email)), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.Address.Country); @@ -98,16 +91,12 @@ public async Task Validate_ShouldReturnProperErrors_WhenCountryIsNotValid(string public async Task Validate_ShouldReturnProperErrors_WhenCityIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, shipmentService, new(country, city, street), new(phone, email)), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.Address.City); @@ -118,16 +107,12 @@ public async Task Validate_ShouldReturnProperErrors_WhenCityIsNotValid(string pa public async Task Validate_ShouldReturnProperErrors_WhenPhoneIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, shipmentService, new(country, city, street), new(phone, email)), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.Contact.Phone); @@ -138,16 +123,12 @@ public async Task Validate_ShouldReturnProperErrors_WhenPhoneIsNotValid(string p public async Task Validate_ShouldReturnProperErrors_WhenEmailIsNotValid(string paymentMethodId, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseActiveCartWithDeliveryCommand command = new( - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, shipmentService, new(country, city, street), new(phone, email)), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.Contact.Email); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs index fdcefea24..66dec14b0 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Decrease/Tests.cs @@ -12,10 +12,16 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Q public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly DecreaseActiveCartItemQuantityHandler handler; + private readonly DecreaseActiveCartItemQuantityCommand request = new( + CallerId: ValidBuyerId, + ProductId: ValidProductId, + Amount: MinValidQuantity + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); - private int oldQuantity; + private readonly int oldQuantity; public Tests() { @@ -32,14 +38,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DecreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId, - Amount: MinValidQuantity - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -52,14 +53,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DecreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId, - Amount: MinValidQuantity - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -72,17 +68,12 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - DecreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId, - Amount: MinValidQuantity - ); // Act - int result = await handler.Handle(command, ct); + int result = await handler.Handle(request, ct); // Assert - Assert.Equal(oldQuantity - command.Amount, result); + Assert.Equal(oldQuantity - request.Amount, result); } [Fact] @@ -92,16 +83,10 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() reads.Setup(x => x.SingleAsync(ValidBuyerId, ValidProductId, true, ct)) .ReturnsAsync(null as ActiveCartItem); - DecreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId, - Amount: MinValidQuantity - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -109,16 +94,11 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenItemNotFound() { // Arrange - DecreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ProductId.New(), - Amount: MinValidQuantity - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { ProductId = new() }, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs index dfcffd823..c398ad757 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Quantity/Increase/Tests.cs @@ -2,7 +2,6 @@ using CustomCADs.Modules.Carts.Domain.Repositories; using CustomCADs.Modules.Carts.Domain.Repositories.Reads; using CustomCADs.Shared.Application.Exceptions; -using CustomCADs.Shared.Domain.TypedIds.Catalog; namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Quantity.Increase; @@ -11,10 +10,16 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.Q public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly IncreaseActiveCartItemQuantityHandler handler; + private readonly IncreaseActiveCartItemQuantityCommand request = new( + CallerId: ValidBuyerId, + ProductId: ValidProductId, + Amount: MinValidQuantity + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); - private int oldQuantity; + private readonly int oldQuantity; public Tests() { @@ -31,14 +36,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - IncreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId, - Amount: MinValidQuantity - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -51,14 +51,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - IncreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId, - Amount: MinValidQuantity - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -71,17 +66,12 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - IncreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId, - Amount: MinValidQuantity - ); // Act - int result = await handler.Handle(command, ct); + int result = await handler.Handle(request, ct); // Assert - Assert.Equal(oldQuantity + command.Amount, result); + Assert.Equal(oldQuantity + request.Amount, result); } [Fact] @@ -91,16 +81,10 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() reads.Setup(x => x.SingleAsync(ValidBuyerId, ValidProductId, true, ct)) .ReturnsAsync(null as ActiveCartItem); - IncreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId, - Amount: MinValidQuantity - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -108,16 +92,11 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenItemNotFound() { // Arrange - IncreaseActiveCartItemQuantityCommand command = new( - CallerId: ValidBuyerId, - ProductId: ProductId.New(), - Amount: MinValidQuantity - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { ProductId = new() }, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs index 694a7bec4..e4fb7b89a 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/Remove/Tests.cs @@ -10,6 +10,8 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.R public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly RemoveActiveCartItemHandler handler; + private readonly RemoveActiveCartItemCommand request = new(ValidBuyerId, ValidProductId); + private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); @@ -28,13 +30,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - RemoveActiveCartItemCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -47,13 +45,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - RemoveActiveCartItemCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -69,15 +63,10 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() reads.Setup(x => x.SingleAsync(ValidBuyerId, ValidProductId, true, ct)) .ReturnsAsync(null as ActiveCartItem); - RemoveActiveCartItemCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs index 2ce356180..a3a91548b 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Commands/Internal/ToggleForDelivery/Tests.cs @@ -14,23 +14,34 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Commands.Internal.T public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly ToggleActiveCartItemForDeliveryHandler handler; + private readonly ToggleActiveCartItemForDeliveryCommand request = new( + CallerId: ValidBuyerId, + ProductId: ProductId1, + CustomizationId: null + ); + private readonly ToggleActiveCartItemForDeliveryCommand requestForDelivery = new( + CallerId: ValidBuyerId, + ProductId: ProductId2, + CustomizationId: ValidCustomizationId + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); - private static readonly ProductId productId1 = ProductId.New(); - private static readonly ProductId productId2 = ProductId.New(); + private static readonly ProductId ProductId1 = ProductId.New(); + private static readonly ProductId ProductId2 = ProductId.New(); public Tests() { handler = new(reads.Object, uow.Object, sender.Object); - reads.Setup(x => x.SingleAsync(ValidBuyerId, productId1, true, ct)) - .ReturnsAsync(CreateItemWithDelivery(ValidBuyerId, productId1)); + reads.Setup(x => x.SingleAsync(ValidBuyerId, ProductId1, true, ct)) + .ReturnsAsync(CreateItemWithDelivery(ValidBuyerId, ProductId1)); - reads.Setup(x => x.SingleAsync(ValidBuyerId, productId2, true, ct)) - .ReturnsAsync(CreateItem(ValidBuyerId, productId2)); + reads.Setup(x => x.SingleAsync(ValidBuyerId, ProductId2, true, ct)) + .ReturnsAsync(CreateItem(ValidBuyerId, ProductId2)); sender.Setup(x => x.SendQueryAsync( It.Is(x => x.Id == ValidCustomizationId), @@ -42,18 +53,13 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ToggleActiveCartItemForDeliveryCommand command = new( - CallerId: ValidBuyerId, - ProductId: productId1, - CustomizationId: null - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.SingleAsync(ValidBuyerId, productId1, true, ct), + x => x.SingleAsync(ValidBuyerId, ProductId1, true, ct), Times.Once() ); } @@ -62,14 +68,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase_WhenTurningDeliveryOff() { // Arrange - ToggleActiveCartItemForDeliveryCommand command = new( - CallerId: ValidBuyerId, - ProductId: productId1, - CustomizationId: null - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -82,14 +83,9 @@ public async Task Handle_ShouldPersistToDatabase_WhenTurningDeliveryOff() public async Task Handle_ShouldPersistToDatabase_WhenTurningDeliveryOn() { // Arrange - ToggleActiveCartItemForDeliveryCommand command = new( - CallerId: ValidBuyerId, - ProductId: productId2, - CustomizationId: ValidCustomizationId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(requestForDelivery, ct); // Assert uow.Verify( @@ -102,14 +98,9 @@ public async Task Handle_ShouldPersistToDatabase_WhenTurningDeliveryOn() public async Task Handle_ShouldSendRequests_WhenTurningDeliveryOff() { // Arrange - ToggleActiveCartItemForDeliveryCommand command = new( - CallerId: ValidBuyerId, - ProductId: productId1, - CustomizationId: null - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -125,14 +116,9 @@ public async Task Handle_ShouldSendRequests_WhenTurningDeliveryOff() public async Task Handle_ShouldSendRequests_WhenTurningDeliveryOn() { // Arrange - ToggleActiveCartItemForDeliveryCommand command = new( - CallerId: ValidBuyerId, - ProductId: productId2, - CustomizationId: ValidCustomizationId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(requestForDelivery, ct); // Assert sender.Verify( @@ -148,19 +134,13 @@ public async Task Handle_ShouldSendRequests_WhenTurningDeliveryOn() public async Task Handle_ShouldThrowException_WhenCartNotFound() { // Arrange - reads.Setup(x => x.SingleAsync(ValidBuyerId, productId1, true, ct)) + reads.Setup(x => x.SingleAsync(ValidBuyerId, ProductId1, true, ct)) .ReturnsAsync(null as ActiveCartItem); - ToggleActiveCartItemForDeliveryCommand command = new( - CallerId: ValidBuyerId, - ProductId: productId1, - CustomizationId: null - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -168,16 +148,11 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenItemNotFound() { // Arrange - ToggleActiveCartItemForDeliveryCommand command = new( - CallerId: ValidBuyerId, - ProductId: ValidProductId, - CustomizationId: null - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { ProductId = ValidProductId }, ct) ); } @@ -190,16 +165,10 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() ct )).ReturnsAsync(false); - ToggleActiveCartItemForDeliveryCommand command = new( - CallerId: ValidBuyerId, - ProductId: productId2, - CustomizationId: ValidCustomizationId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(requestForDelivery, ct) ); } @@ -207,16 +176,11 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenDeliveryMismatch() { // Arrange - ToggleActiveCartItemForDeliveryCommand command = new( - CallerId: ValidBuyerId, - ProductId: productId2, - CustomizationId: null - ); // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(requestForDelivery with { CustomizationId = null }, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs index a73f57880..92f0cbc9c 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Events/Application/ProductDeleted/Tests.cs @@ -9,6 +9,12 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Events.Application. public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly ProductDeletedHandler handler; + private readonly ProductDeletedApplicationEvent request = new( + Id: ValidProductId, + ImageId: default, + CadId: default + ); + private readonly Mock uow = new(); public Tests() @@ -20,14 +26,9 @@ public Tests() public async Task Handle_ShouldBulkDelete_WhenThresholdReached() { // Arrange - ProductDeletedApplicationEvent ie = new( - Id: ValidProductId, - ImageId: default, - CadId: default - ); // Act - await handler.HandleAsync(ie); + await handler.HandleAsync(request); // Assert uow.Verify( diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs index 7bc68b092..d6ce3faa2 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/CalculateShipment/Tests.cs @@ -12,11 +12,13 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.Ca public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly CalculateActiveCartShipmentHandler handler; + private readonly CalculateActiveCartShipmentQuery request = new(ValidBuyerId, Address); + private readonly Mock reads = new(); private readonly Mock sender = new(); - private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); - private static readonly CalculateShipmentDto[] calculations = [ + private static readonly AddressDto Address = new("Bulgaria", "Burgas", "Slivnitsa"); + private static readonly CalculateShipmentDto[] Calculations = [ new(default, string.Empty, string.Empty, default, default) ]; @@ -38,17 +40,16 @@ public Tests() sender.Setup(x => x.SendQueryAsync( It.IsAny(), ct - )).ReturnsAsync(calculations); + )).ReturnsAsync(Calculations); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - CalculateActiveCartShipmentQuery query = new(ValidBuyerId, address); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -61,10 +62,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CalculateActiveCartShipmentQuery query = new(ValidBuyerId, address); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -76,7 +76,7 @@ public async Task Handle_ShouldSendRequests() ); sender.Verify( x => x.SendQueryAsync( - It.Is(x => x.Address == address), + It.Is(x => x.Address == Address), ct ), Times.Once() @@ -87,12 +87,11 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - CalculateActiveCartShipmentQuery query = new(ValidBuyerId, address); // Act - CalculateShipmentDto[] result = await handler.Handle(query, ct); + CalculateShipmentDto[] result = await handler.Handle(request, ct); // Assert - Assert.Equal(calculations, result); + Assert.Equal(Calculations, result); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs index fec39c18e..440d7d678 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/Count/Tests.cs @@ -8,6 +8,8 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.Co public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly CountActiveCartItemsHandler handler; + private readonly CountActiveCartItemsQuery request = new(ValidBuyerId); + private readonly Mock reads = new(); private const int Count = 5; @@ -24,10 +26,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CountActiveCartItemsQuery query = new(ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -40,10 +41,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - CountActiveCartItemsQuery query = new(ValidBuyerId); // Act - int count = await handler.Handle(query, ct); + int count = await handler.Handle(request, ct); // Assert Assert.Equal(Count, count); diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs index d7e6976b0..b58b6812d 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetAll/Tests.cs @@ -10,11 +10,13 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.Ge public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly GetActiveCartItemsHandler handler; + private readonly GetActiveCartItemsQuery request = new(ValidBuyerId); + private readonly Mock reads = new(); private readonly Mock sender = new(); private const string Buyer = "For7a7a"; - private static readonly ActiveCartItem[] items = [ + private static readonly ActiveCartItem[] Items = [ CreateItem(), CreateItemWithDelivery(), ]; @@ -24,7 +26,7 @@ public Tests() handler = new(reads.Object, sender.Object); reads.Setup(x => x.AllAsync(ValidBuyerId, false, ct)) - .ReturnsAsync(items); + .ReturnsAsync(Items); sender.Setup(x => x.SendQueryAsync( It.Is(x => x.Id == ValidBuyerId), @@ -36,10 +38,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetActiveCartItemsQuery query = new(ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -52,10 +53,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - GetActiveCartItemsQuery query = new(ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -71,12 +71,11 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - GetActiveCartItemsQuery query = new(ValidBuyerId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert - Assert.Equal(items.Select(x => x.ProductId), result.Select(x => x.ProductId)); + Assert.Equal(Items.Select(x => x.ProductId), result.Select(x => x.ProductId)); } } diff --git a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs index 87bda2de2..f0653bf5a 100644 --- a/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs +++ b/tests/UnitTests/Carts/Application/ActiveCarts/Queries/Internal/GetSingle/Tests.cs @@ -2,7 +2,6 @@ using CustomCADs.Modules.Carts.Domain.Repositories.Reads; using CustomCADs.Shared.Application.Abstractions.Requests.Sender; using CustomCADs.Shared.Application.Exceptions; -using CustomCADs.Shared.Domain.TypedIds.Catalog; namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.GetSingle; @@ -11,6 +10,8 @@ namespace CustomCADs.UnitTests.Carts.Application.ActiveCarts.Queries.Internal.Ge public class Tests : Data.ActiveCarts.BaseUnitTests { private readonly GetActiveCartItemHandler handler; + private readonly GetActiveCartItemQuery request = new(ValidBuyerId, ValidProductId); + private readonly Mock reads = new(); private readonly Mock sender = new(); @@ -26,10 +27,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetActiveCartItemQuery query = new(ValidBuyerId, ValidProductId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -42,10 +42,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetActiveCartItemQuery query = new(ValidBuyerId, ValidProductId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Equal(ValidProductId, result.ProductId); @@ -55,12 +54,11 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenCartItemNotFound() { // Arrange - GetActiveCartItemQuery query = new(ValidBuyerId, ProductId.New()); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request with { ProductId = new() }, ct) ); } @@ -68,12 +66,11 @@ await Assert.ThrowsAsync>( public async Task Handle_ShouldThrowException_WhenCartNotFound() { // Arrange - GetActiveCartItemQuery query = new(ValidBuyerId, ProductId.New()); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request with { ProductId = new() }, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs index 6b23332f3..b67680273 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Commands/Internal/Create/Tests.cs @@ -8,7 +8,6 @@ using CustomCADs.Shared.Application.UseCases.Accounts.Queries; using CustomCADs.Shared.Application.UseCases.Cads.Commands; using CustomCADs.Shared.Application.UseCases.Products.Queries; -using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Carts; using CustomCADs.Shared.Domain.TypedIds.Catalog; using CustomCADs.Shared.Domain.TypedIds.Files; @@ -20,15 +19,17 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Commands.Interna public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly CreatePurchasedCartHandler handler; + private readonly CreatePurchasedCartCommand request = new(ValidBuyerId, Items); + private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); private readonly Mock raiser = new(); - private static readonly Dictionary items = []; - private static readonly ProductId[] productIds = [.. items.Keys.Select(x => x.ProductId)]; - private static readonly Dictionary cads = []; - private static readonly CadId[] cadIds = [.. cads.Select(x => x.Value)]; + private static readonly Dictionary Items = []; + private static readonly ProductId[] ProductIds = [.. Items.Keys.Select(x => x.ProductId)]; + private static readonly Dictionary Cads = []; + private static readonly CadId[] CadIds = [.. Cads.Select(x => x.Value)]; public Tests() { @@ -45,12 +46,12 @@ public Tests() )).ReturnsAsync(true); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == productIds), + It.Is(x => x.Ids == ProductIds), ct - )).ReturnsAsync(cads); + )).ReturnsAsync(Cads); sender.Setup(x => x.SendCommandAsync( - It.Is(x => x.Ids == cadIds), + It.Is(x => x.Ids == CadIds), ct )).ReturnsAsync([]); } @@ -59,13 +60,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreatePurchasedCartCommand command = new( - BuyerId: ValidBuyerId, - Items: items - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -85,13 +82,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CreatePurchasedCartCommand command = new( - BuyerId: ValidBuyerId, - Items: items - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -103,14 +96,14 @@ public async Task Handle_ShouldSendRequests() ); sender.Verify( x => x.SendQueryAsync( - It.Is(x => x.Ids == productIds), + It.Is(x => x.Ids == ProductIds), ct ), Times.Once() ); sender.Verify( x => x.SendCommandAsync( - It.Is(x => x.Ids == cadIds), + It.Is(x => x.Ids == CadIds), ct ), Times.Once() @@ -121,18 +114,14 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - CreatePurchasedCartCommand command = new( - BuyerId: ValidBuyerId, - Items: items - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( x => x.RaiseApplicationEventAsync( - It.Is(x => x.Ids == productIds) + It.Is(x => x.Ids == ProductIds) ), Times.Once() ); @@ -142,13 +131,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldReturnResult() { // Arrange - CreatePurchasedCartCommand command = new( - BuyerId: ValidBuyerId, - Items: items - ); // Act - PurchasedCartId result = await handler.Handle(command, ct); + PurchasedCartId result = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, result); @@ -163,15 +148,10 @@ public async Task Handle_ShouldThrowException_WhenPurchasedCartNotFound() ct )).ReturnsAsync(false); - CreatePurchasedCartCommand command = new( - BuyerId: ValidBuyerId, - Items: items - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs index 88326571c..d0a26ac09 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/DeliveryRequested/Tests.cs @@ -13,7 +13,17 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Events.Applicati public class Tests : Data.PurchasedCarts.BaseUnitTests { - private readonly ActiveCartDeliveryRequestedApplicationEventHandler handler; + private readonly ActiveCartDeliveryRequestedHandler handler; + private readonly ActiveCartDeliveryRequestedApplicationEvent request = new( + PurchasedCartId: ValidId, + ShipmentService: string.Empty, + Weight: default, + Count: default, + Address: new(string.Empty, string.Empty, string.Empty), + Contact: new(default, default) + ); + + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -44,17 +54,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ActiveCartDeliveryRequestedApplicationEvent @event = new( - PurchasedCartId: ValidId, - ShipmentService: string.Empty, - Weight: default, - Count: default, - Address: new(string.Empty, string.Empty, string.Empty), - Contact: new(default, default) - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -67,17 +69,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - ActiveCartDeliveryRequestedApplicationEvent @event = new( - PurchasedCartId: ValidId, - ShipmentService: string.Empty, - Weight: default, - Count: default, - Address: new(string.Empty, string.Empty, string.Empty), - Contact: new(default, default) - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert sender.Verify( @@ -103,19 +97,10 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as PurchasedCart); - ActiveCartDeliveryRequestedApplicationEvent @event = new( - PurchasedCartId: ValidId, - ShipmentService: string.Empty, - Weight: default, - Count: default, - Address: new(string.Empty, string.Empty, string.Empty), - Contact: new(default, default) - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.HandleAsync(@event) + () => handler.HandleAsync(request) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs index 5aecf464b..1adfaf50f 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Events/Application/PaymentCompleted/CartPaymentCompletedApplicationEventHandlerUnitTests.cs @@ -14,7 +14,9 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Events.Applicati public class Tests : Data.PurchasedCarts.BaseUnitTests { - private readonly CartPaymentCompletedApplicationEventHandler handler; + private readonly CartPaymentCompletedHandler handler; + private readonly CartPaymentCompletedApplicationEvent request = new(ValidId, ValidBuyerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -44,10 +46,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -60,10 +61,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert uow.Verify( @@ -80,10 +80,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert sender.Verify( @@ -106,10 +105,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldSendEmail() { // Arrange - CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert email.Verify( @@ -134,10 +132,8 @@ public async Task Handle_ShouldIdk_WhenForDelivery() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(cart); - CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); - // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert email.Verify( @@ -155,12 +151,11 @@ public async Task Handle_ShouldThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as PurchasedCart); - CartPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.HandleAsync(@event) + () => handler.HandleAsync(request) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs index eedb12c3a..fe19caf8d 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Carts/Tests.cs @@ -8,6 +8,8 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly CountPurchasedCartsHandler handler; + private readonly CountPurchasedCartsQuery request = new(ValidBuyerId); + private readonly Mock reads = new(); private const int Count = 4; @@ -24,10 +26,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CountPurchasedCartsQuery query = new(ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -40,10 +41,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - CountPurchasedCartsQuery query = new(ValidBuyerId); // Act - int count = await handler.Handle(query, ct); + int count = await handler.Handle(request, ct); // Assert Assert.Equal(Count, count); diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs index 0b8859acf..f3a60a362 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/Count/Items/Tests.cs @@ -9,29 +9,30 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly CountPurchasedCartItemsHandler handler; + private readonly CountPurchasedCartItemsQuery request = new(ValidBuyerId); + private readonly Mock reads = new(); - private static readonly Dictionary count = new() { [ValidId] = 4 }; + private static readonly Dictionary Count = new() { [ValidId] = 4 }; public Tests() { handler = new(reads.Object); reads.Setup(x => x.CountItemsAsync(ValidBuyerId, ct)) - .ReturnsAsync(count); + .ReturnsAsync(Count); reads.Setup(x => x.CountItemsAsync(ValidBuyerId, ct)) - .ReturnsAsync(count); + .ReturnsAsync(Count); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - CountPurchasedCartItemsQuery query = new(ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -44,12 +45,11 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - CountPurchasedCartItemsQuery query = new(ValidBuyerId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert - Assert.Equal(count, result); + Assert.Equal(Count, result); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs index 67e5151a3..81e70f09b 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetAll/Tests.cs @@ -10,26 +10,27 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly GetAllPurchasedCartsHandler handler; + private readonly GetAllPurchasedCartsQuery request = new(Query.Pagination); + private readonly Mock reads = new(); - private readonly PurchasedCart[] carts = [ + private static readonly PurchasedCart[] Carts = [ CreateCart(id: ValidId), CreateCart(id: ValidId), ]; - private readonly PurchasedCartQuery query; + private static readonly PurchasedCartQuery Query = new( + Pagination: new(1, Carts.Length) + ); + public Tests() { handler = new(reads.Object); - query = new( - Pagination: new(1, carts.Length) - ); - - reads.Setup(x => x.AllAsync(query, false, ct)) + reads.Setup(x => x.AllAsync(Query, false, ct)) .ReturnsAsync(new Result( - carts.Length, - carts + Carts.Length, + Carts )); } @@ -37,14 +38,13 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAllPurchasedCartsQuery query = new(this.query.Pagination); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(this.query, false, ct), + x => x.AllAsync(Query, false, ct), Times.Once() ); } @@ -53,14 +53,13 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetAllPurchasedCartsQuery query = new(this.query.Pagination); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert - int expectedCount = carts.Length, actualCount = result.Count; - PurchasedCartId[] expectedIds = [.. carts.Select(x => x.Id)], + int expectedCount = Carts.Length, actualCount = result.Count; + PurchasedCartId[] expectedIds = [.. Carts.Select(x => x.Id)], actualIds = [.. result.Items.Select(x => x.Id)]; Assert.Multiple( diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs index dae942580..4860b5967 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetById/Tests.cs @@ -11,6 +11,8 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly GetPurchasedCartByIdHandler handler; + private readonly GetPurchasedCartByIdQuery request = new(ValidId, ValidBuyerId); + private readonly Mock reads = new(); private readonly Mock sender = new(); @@ -34,10 +36,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetPurchasedCartByIdQuery query = new(ValidId, ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -50,10 +51,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - GetPurchasedCartByIdQuery query = new(ValidId, ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -69,10 +69,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - GetPurchasedCartByIdQuery query = new(ValidId, ValidBuyerId); // Act - var cart = await handler.Handle(query, ct); + var cart = await handler.Handle(request, ct); // Assert Assert.Equal(this.cart.Id, cart.Id); @@ -84,12 +83,11 @@ public async Task Handle_ShouldThrowException_WhenCartNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as PurchasedCart); - GetPurchasedCartByIdQuery query = new(ValidId, ValidBuyerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/Tests.cs index 5a990d061..904c0708a 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetPaymentStatuses/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly GetPurchasedCartPaymentStatusesHandler handler = new(); + private readonly GetPurchasedCartPaymentStatusesQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetPurchasedCartPaymentStatusesQuery query = new(); // Act - PaymentStatus[] statuses = await handler.Handle(query, ct); + PaymentStatus[] statuses = await handler.Handle(request, ct); // Assert Assert.Equal(Enum.GetValues(), statuses); diff --git a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/Tests.cs b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/Tests.cs index 66038e6ca..e3a2fbb1b 100644 --- a/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/Tests.cs +++ b/tests/UnitTests/Carts/Application/PurchasedCarts/Queries/Internal/GetSortings/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Carts.Application.PurchasedCarts.Queries.Internal public class Tests : Data.PurchasedCarts.BaseUnitTests { private readonly GetPurchasedCartSortingsHandler handler = new(); + private readonly GetPurchasedCartSortingsQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetPurchasedCartSortingsQuery query = new(); // Act - PurchasedCartSortingType[] sortings = await handler.Handle(query, ct); + PurchasedCartSortingType[] sortings = await handler.Handle(request, ct); // Assert Assert.Equal(sortings, Enum.GetValues()); diff --git a/tests/UnitTests/Carts/Data/PurchasedCarts/BaseUnitTests.cs b/tests/UnitTests/Carts/Data/PurchasedCarts/BaseUnitTests.cs index 1385d6b8a..061618a22 100644 --- a/tests/UnitTests/Carts/Data/PurchasedCarts/BaseUnitTests.cs +++ b/tests/UnitTests/Carts/Data/PurchasedCarts/BaseUnitTests.cs @@ -70,8 +70,8 @@ protected static ActiveCartItem[] CreateItems(int noDeliveryCount, int forDelive } for (int i = 0; i < forDeliveryCount; i++) { - items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId, CartItemsData.ValidCustomizationId)); - items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId, CartItemsData.ValidCustomizationId)); + items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId, ValidCustomizationId)); + items.Add(ActiveCartItem.Create(ProductId.New(), ValidBuyerId, ValidCustomizationId)); } return [.. items]; diff --git a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs index cbf12dff3..fa5e3aa72 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Create/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Commands.Internal. public class Tests : Data.Categories.BaseUnitTests { private readonly CreateCategoryHandler handler; + private readonly CreateCategoryCommand request = new(Dto: new(ValidName, ValidDescription)); + private readonly Mock writes = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -27,10 +29,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateCategoryCommand command = new(Dto: new(ValidName, ValidDescription)); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -50,10 +51,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldUpdateCache() { // Arrange - CreateCategoryCommand command = new(Dto: new(ValidName, ValidDescription)); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -69,10 +69,9 @@ public async Task Handle_ShouldUpdateCache() public async Task Handle_ShouldReturnResult() { // Arrange - CreateCategoryCommand command = new(Dto: new(ValidName, ValidDescription)); // Act - CategoryId id = await handler.Handle(command, ct); + CategoryId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); diff --git a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs index 6fe300e29..17794f0ca 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Delete/Tests.cs @@ -10,6 +10,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Commands.Internal. public class Tests : Data.Categories.BaseUnitTests { private readonly DeleteCategoryHandler handler; + private readonly DeleteCategoryCommand request = new(ValidId); + private readonly Mock> cache = new(); private readonly Mock uow = new(); private readonly Mock writes = new(); @@ -27,10 +29,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - DeleteCategoryCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -43,10 +44,9 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DeleteCategoryCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -65,10 +65,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldClearCache() { // Arrange - DeleteCategoryCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( diff --git a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs index 8a2ad847a..e3dc72030 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Commands/Internal/Edit/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Commands.Internal. public class Tests : Data.Categories.BaseUnitTests { private readonly EditCategoryHandler handler; + private readonly EditCategoryCommand request = new(ValidId, Dto: new(ValidName, ValidDescription)); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -25,10 +27,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - EditCategoryCommand command = new(ValidId, new(ValidName, ValidDescription)); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -41,10 +42,9 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldPersistToDatabase() { // Arrange - EditCategoryCommand command = new(ValidId, new(ValidName, ValidDescription)); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -57,10 +57,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldModifyCategory() { // Arrange - EditCategoryCommand command = new(ValidId, new(ValidName, ValidDescription)); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple(() => @@ -74,10 +73,9 @@ public async Task Handle_ShouldModifyCategory() public async Task Handle_ShouldUpdateCache() { // Arrange - EditCategoryCommand command = new(ValidId, new(ValidName, ValidDescription)); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs index d9be3d15d..df7b55479 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetAll/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Internal.G public class Tests : Data.Categories.BaseUnitTests { private readonly GetAllCategoriesHandler handler; + private readonly GetAllCategoriesQuery request = new(); + private readonly Mock reads = new(); private readonly Mock> cache = new(); @@ -30,10 +32,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - GetAllCategoriesQuery query = new(); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - GetAllCategoriesQuery query = new(); // Act - IEnumerable categories = await handler.Handle(query, ct); + IEnumerable categories = await handler.Handle(request, ct); // Assert Assert.Equal(categories.Select(r => r.Id), this.categories.Select(r => r.Id)); diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs index 21e10ed99..ccf3cf633 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Internal/GetById/Tests.cs @@ -8,6 +8,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Internal.G public class Tests : Data.Categories.BaseUnitTests { private readonly GetCategoryByIdHandler handler; + private readonly GetCategoryByIdQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock> cache = new(); @@ -23,10 +25,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - GetCategoryByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -39,10 +40,9 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - GetCategoryByIdQuery query = new(ValidId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, result.Id); diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs index 86ff8e7b6..4188958be 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/BatchGetById/Tests.cs @@ -4,35 +4,34 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Shared.BatchGetById; -using static Data.Categories.TestData; - public class Tests : Data.Categories.BaseUnitTests { private readonly BatchGetCategoryByIdHandler handler; + private readonly BatchGetCategorByIdQuery request = new(Ids); + private readonly Mock reads = new(); private readonly Mock> cache = new(); - private readonly static CategoryId[] ids = [ + private static readonly CategoryId[] Ids = [ CategoryId.New(1), CategoryId.New(2), CategoryId.New(3) ]; - private static readonly Category[] categories = [.. ids.Select(id => CreateCategory(id: id))]; + private static readonly Category[] Categories = [.. Ids.Select(id => CreateCategory(id: id))]; public Tests() { handler = new(reads.Object, cache.Object); - cache.Setup(x => x.GetOrCreateAsync(It.IsAny>>>())).ReturnsAsync(categories); + cache.Setup(x => x.GetOrCreateAsync(It.IsAny>>>())).ReturnsAsync(Categories); } [Fact] public async Task Handle_ShouldReadCache() { // Arrange - BatchGetCategorByIdQuery query = new(ids); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -45,12 +44,11 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - BatchGetCategorByIdQuery query = new(ids); // Act - var actualCategories = (await handler.Handle(query, ct)).Select(x => (x.Key, x.Value)); + var actualCategories = (await handler.Handle(request, ct)).Select(x => (x.Key, x.Value)); // Assert - Assert.Equal(actualCategories, [.. categories.Select(c => (c.Id, c.Name))]); + Assert.Equal(actualCategories, [.. Categories.Select(c => (c.Id, c.Name))]); } } diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs index 834305a5c..7ed9db44a 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetById/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Shared.Get public class Tests : Data.Categories.BaseUnitTests { private readonly GetCategoryNameByIdHandler handler; + private readonly GetCategoryNameByIdQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock> cache = new(); @@ -24,10 +26,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - GetCategoryNameByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -40,10 +41,9 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - GetCategoryNameByIdQuery query = new(ValidId); // Act - string result = await handler.Handle(query, ct); + string result = await handler.Handle(request, ct); // Assert Assert.Equal(ValidName, result); diff --git a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs index f13c927af..322d1ff6c 100644 --- a/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Categories/Queries/Shared/GetExists/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Categories.Queries.Shared.Get public class Tests : Data.Categories.BaseUnitTests { private readonly GetCategoryExistsByIdHandler handler; + private readonly GetCategoryExistsByIdQuery request = new(ValidId); + private readonly Mock reads = new(); public Tests() @@ -21,10 +23,9 @@ public async Task Handle_ShouldQueryDatabase() { // Arrange reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)).ReturnsAsync(true); - GetCategoryExistsByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -40,10 +41,9 @@ public async Task Handle_ShouldReturnResult(bool exists) { // Arrange reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)).ReturnsAsync(exists); - GetCategoryExistsByIdQuery query = new(ValidId); // Act - bool result = await handler.Handle(query, ct); + bool result = await handler.Handle(request, ct); // Assert Assert.Equal(exists, result); diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs index ac27f2b70..b9c1750a0 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Admin/Remove/Tests.cs @@ -15,6 +15,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Ad public class Tests : Data.Products.BaseUnitTests { private readonly RemoveProductHandler handler; + private readonly RemoveProductCommand request = new(ValidId, ValidAdminId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -37,10 +39,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - RemoveProductCommand command = new(ValidId, ValidAdminId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -53,10 +54,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - RemoveProductCommand command = new(ValidId, ValidAdminId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -69,10 +69,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - RemoveProductCommand command = new(ValidId, ValidAdminId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -88,10 +87,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - RemoveProductCommand command = new(ValidId, ValidAdminId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -112,12 +110,11 @@ public async Task Handle_ShouldThrowException_WhenAdminNotFound() It.Is(x => x.Id == ValidAdminId), ct )).ReturnsAsync(false); - RemoveProductCommand command = new(ValidId, ValidAdminId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -127,12 +124,11 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Product); - RemoveProductCommand command = new(ValidId, ValidAdminId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs index 4315fdd72..c4999ba13 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Create/Tests.cs @@ -18,6 +18,16 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Cr public class Tests : Data.Products.BaseUnitTests { private readonly CreateProductHandler handler; + private readonly CreateProductCommand request = new( + Name: MinValidName, + Description: MinValidDescription, + Price: MinValidPrice, + CategoryId: ValidCategoryId, + ImageId: ValidImageId, + CadId: ValidCadId, + CallerId: ValidCreatorId + ); + private readonly Mock writes = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -78,18 +88,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateProductCommand command = new( - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - ImageId: ValidImageId, - CadId: ValidCadId, - CallerId: ValidCreatorId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -118,18 +119,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CreateProductCommand command = new( - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - ImageId: ValidImageId, - CadId: ValidCadId, - CallerId: ValidCreatorId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -180,18 +172,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - CreateProductCommand command = new( - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - ImageId: ValidImageId, - CadId: ValidCadId, - CallerId: ValidCreatorId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -214,18 +197,8 @@ public async Task Handle_ShouldValidateStatus_WhenDesignerRole() ct )).ReturnsAsync(DomainConstants.Users.DesignerRole); - CreateProductCommand command = new( - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - ImageId: ValidImageId, - CadId: ValidCadId, - CallerId: ValidCreatorId - ); - // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Equal(ProductStatus.Validated, product.Status); @@ -240,18 +213,8 @@ public async Task Handle_ShouldTagProfessional_WhenDesignerRole() ct )).ReturnsAsync(DomainConstants.Users.DesignerRole); - CreateProductCommand command = new( - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - ImageId: ValidImageId, - CadId: ValidCadId, - CallerId: ValidCreatorId - ); - // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -271,18 +234,8 @@ public async Task Handle_ShouldTagPrintable_WhenAppropriateContentType() ct )).ReturnsAsync(true); - CreateProductCommand command = new( - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - ImageId: ValidImageId, - CadId: ValidCadId, - CallerId: ValidCreatorId - ); - // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -297,18 +250,9 @@ public async Task Handle_ShouldTagPrintable_WhenAppropriateContentType() public async Task Handle_ShouldReturnResult() { // Arrange - CreateProductCommand command = new( - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - ImageId: ValidImageId, - CadId: ValidCadId, - CallerId: ValidCreatorId - ); // Act - ProductId id = await handler.Handle(command, ct); + ProductId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); @@ -323,20 +267,10 @@ public async Task Handle_ShouldThrowException_WhenCategoryNotFound() ct )).ReturnsAsync(false); - CreateProductCommand command = new( - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - ImageId: ValidImageId, - CadId: ValidCadId, - CallerId: ValidCreatorId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -349,20 +283,10 @@ public async Task Handle_ShouldThrowException_WhenAccountNotFound() ct )).ReturnsAsync(false); - CreateProductCommand command = new( - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - ImageId: ValidImageId, - CadId: ValidCadId, - CallerId: ValidCreatorId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs index 79b45eb0e..f67dfa133 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Delete/Tests.cs @@ -17,6 +17,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Cr public class Tests : Data.Products.BaseUnitTests { private readonly DeleteProductHandler handler; + private readonly DeleteProductCommand request = new(ValidId, ValidCreatorId); + private readonly Mock reads = new(); private readonly Mock writes = new(); private readonly Mock uow = new(); @@ -42,10 +44,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DeleteProductCommand command = new(ValidId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -58,10 +59,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DeleteProductCommand command = new(ValidId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -78,10 +78,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - DeleteProductCommand command = new(ValidId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -97,10 +96,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - DeleteProductCommand command = new(ValidId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -121,12 +119,11 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange - DeleteProductCommand command = new(ValidId, ValidDesignerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { CallerId = ValidDesignerId }, ct) ); } @@ -136,12 +133,11 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Product); - DeleteProductCommand command = new(ValidId, ValidCreatorId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs index e790413d2..04c79ba2e 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Creator/Edit/Tests.cs @@ -16,6 +16,15 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.Cr public class Tests : Data.Products.BaseUnitTests { private readonly EditProductHandler handler; + private readonly EditProductCommand request = new( + Id: ValidId, + Name: MinValidName, + Description: MinValidDescription, + Price: MinValidPrice, + CategoryId: ValidCategoryId, + CallerId: ValidCreatorId + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -44,17 +53,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - EditProductCommand command = new( - Id: ValidId, - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - CallerId: ValidCreatorId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -67,17 +68,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - EditProductCommand command = new( - Id: ValidId, - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - CallerId: ValidCreatorId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -90,17 +83,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - EditProductCommand command = new( - Id: ValidId, - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - CallerId: ValidCreatorId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -123,17 +108,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - EditProductCommand command = new( - Id: ValidId, - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - CallerId: ValidCreatorId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -148,19 +125,11 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange - EditProductCommand command = new( - Id: ValidId, - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - CallerId: ValidDesignerId - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { CallerId = ValidDesignerId }, ct) ); } @@ -173,19 +142,10 @@ public async Task Handle_ShouldThrowException_WhenCategoryNotFound() ct )).ReturnsAsync(false); - EditProductCommand command = new( - Id: ValidId, - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - CallerId: ValidCreatorId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -196,19 +156,10 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Product); - EditProductCommand command = new( - Id: ValidId, - Name: MinValidName, - Description: MinValidDescription, - Price: MinValidPrice, - CategoryId: ValidCategoryId, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs index bf0bba6aa..7ae9970b5 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/AddTag/Tests.cs @@ -14,6 +14,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.De public class Tests : Data.Products.BaseUnitTests { private readonly AddProductTagHandler handler; + private readonly AddProductTagCommand request = new(ValidId, ValidTagId, ValidCreatorId); + private readonly Mock reads = new(); private readonly Mock writes = new(); private readonly Mock uow = new(); @@ -30,10 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - AddProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - AddProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -66,10 +66,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - AddProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -85,12 +84,11 @@ public async Task Handle_ShouldThrow_WhenProductNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Product); - AddProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs index ca9d18473..4922684f6 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/RemoveTag/Tests.cs @@ -14,6 +14,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.De public class Tests : Data.Products.BaseUnitTests { private readonly RemoveProductTagHandler handler; + private readonly RemoveProductTagCommand request = new(ValidId, ValidTagId, ValidCreatorId); + private readonly Mock reads = new(); private readonly Mock writes = new(); private readonly Mock uow = new(); @@ -30,10 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - RemoveProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - RemoveProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -66,10 +66,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - RemoveProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -85,12 +84,11 @@ public async Task Handle_ShouldThrow_WhenProductNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Product); - RemoveProductTagCommand command = new(ValidId, ValidTagId, ValidCreatorId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs index 6af9100b8..f0e58f565 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Report/Tests.cs @@ -15,6 +15,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.De public class Tests : Data.Products.BaseUnitTests { private readonly ReportProductHandler handler; + private readonly ReportProductCommand request = new(ValidId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -39,10 +41,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ReportProductCommand command = new(ValidId, ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -55,10 +56,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ReportProductCommand command = new(ValidId, ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -71,10 +71,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - ReportProductCommand command = new(ValidId, ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -97,10 +96,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - ReportProductCommand command = new(ValidId, ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -118,12 +116,11 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange product.Report(ValidDesignerId); - ReportProductCommand command = new(ValidId, ValidDesignerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -135,12 +132,11 @@ public async Task Handle_ShouldThrowException_WhenDesignerNotFound() It.Is(x => x.Id == ValidDesignerId), ct )).ReturnsAsync(false); - ReportProductCommand command = new(ValidId, ValidDesignerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -150,12 +146,11 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Product); - ReportProductCommand command = new(ValidId, ValidDesignerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs index e1baba60c..3df1e1f80 100644 --- a/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Commands/Internal/Designer/Validate/Tests.cs @@ -15,6 +15,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Commands.Internal.De public class Tests : Data.Products.BaseUnitTests { private readonly ValidateProductHandler handler; + private readonly ValidateProductCommand request = new(ValidId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -39,10 +41,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ValidateProductCommand command = new(ValidId, ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -55,10 +56,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ValidateProductCommand command = new(ValidId, ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -71,10 +71,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - ValidateProductCommand command = new(ValidId, ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -97,10 +96,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - ValidateProductCommand command = new(ValidId, ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -118,12 +116,11 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange product.Validate(ValidDesignerId); - ValidateProductCommand command = new(ValidId, ValidDesignerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -135,12 +132,11 @@ public async Task Handle_ShouldThrowException_WhenDesignerNotFound() It.Is(x => x.Id == ValidDesignerId), ct )).ReturnsAsync(false); - ValidateProductCommand command = new(ValidId, ValidDesignerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -150,12 +146,11 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Product); - ValidateProductCommand command = new(ValidId, ValidDesignerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs index 627d026bb..100024177 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Created/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application.C public class Tests : Data.Products.BaseUnitTests { private readonly ProductCreatedHandler handler; + private readonly ProductCreatedApplicationEvent request = new(ValidId, TagIds); + private readonly Mock writes = new(); private readonly Mock uow = new(); @@ -23,10 +25,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductCreatedApplicationEvent @event = new(ValidId, TagIds); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert writes.Verify( diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs index 6e528b15d..9130b1886 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Purchased/Tests.cs @@ -7,9 +7,11 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application.P public class Tests : Data.Products.BaseUnitTests { private readonly ProductsPurchasedHandler handler; + private readonly ProductsPurchasedApplicationEvent request = new(Ids); + private readonly Mock uow = new(); - private static readonly ProductId[] ids = []; + private static readonly ProductId[] Ids = []; public Tests() { @@ -20,14 +22,13 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductsPurchasedApplicationEvent @event = new(ids); // Act - await handler.HandleAsync(@event, ct); + await handler.HandleAsync(request, ct); // Assert uow.Verify( - x => x.AddProductsPurchasesAsync(ids, 1, ct), + x => x.AddProductsPurchasesAsync(Ids, 1, ct), Times.Once() ); } diff --git a/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs index e46b900fa..fffcf0733 100644 --- a/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Events/Application/Viewed/Tests.cs @@ -15,21 +15,23 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Events.Application.V public class Tests : Data.Products.BaseUnitTests { private readonly ProductViewedHandler handler; + private readonly ProductViewedApplicationEvent request = new(ValidId, ValidCreatorId, ViewedAt); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); private readonly Mock raiser = new(); private const string Username = Users.CustomerUsername; - private readonly AccountInfoDto info = new( + private static readonly AccountInfoDto Info = new( Id: ValidCreatorId, CreatedAt: default, TrackViewedProducts: true, FirstName: null, LastName: null ); + private static readonly DateTimeOffset ViewedAt = DateTimeOffset.UtcNow; private readonly Product product = CreateProduct(); - private static readonly DateTimeOffset viewedAt = DateTimeOffset.UtcNow; public Tests() { @@ -46,7 +48,7 @@ public Tests() sender.Setup(x => x.SendQueryAsync( It.Is(x => x.Username == Username), ct - )).ReturnsAsync(info); + )).ReturnsAsync(Info); sender.Setup(x => x.SendQueryAsync( It.Is(x => x.Id == ValidCreatorId && x.ProductId == ValidId), @@ -58,10 +60,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -74,10 +75,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert uow.Verify( @@ -90,10 +90,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert sender.Verify( @@ -123,10 +122,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert raiser.Verify( @@ -141,10 +139,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldPopulateProperties() { // Arrange - ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert Assert.Equal(1, product.Counts.Views); @@ -157,11 +154,10 @@ public async Task Handle_ShouldReturnEarly_WhenUserDoesNotTrackViewedProducts() sender.Setup(x => x.SendQueryAsync( It.Is(x => x.Username == Username), ct - )).ReturnsAsync(info with { TrackViewedProducts = false }); - ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); + )).ReturnsAsync(Info with { TrackViewedProducts = false }); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -189,10 +185,9 @@ public async Task Handle_ShouldReturnEarly_WhenUserAlreadyViewedProduct() It.Is(x => x.Id == ValidCreatorId && x.ProductId == ValidId), ct )).ReturnsAsync(true); - ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert sender.Verify( @@ -228,12 +223,10 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Product); - ProductViewedApplicationEvent @event = new(ValidId, ValidCreatorId, viewedAt); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.HandleAsync(@event) + () => handler.HandleAsync(request) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs index 86638f85e..7034bd7a9 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/Count/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Cre public class Tests : Data.Products.BaseUnitTests { private readonly ProductsCountHandler handler; + private readonly ProductsCountQuery request = new(ValidCreatorId); + private readonly Mock reads = new(); private readonly Dictionary dict = new() @@ -31,10 +33,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ProductsCountQuery query = new(ValidCreatorId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -47,10 +48,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - ProductsCountQuery query = new(ValidCreatorId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Multiple( diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs index 754140d8a..e8ff3eb20 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetAll/Tests.cs @@ -11,51 +11,49 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Cre public class Tests : Data.Products.BaseUnitTests { private readonly CreatorGetAllProductsHandler handler; + private readonly CreatorGetAllProductsQuery request = new( + Pagination: Query.Pagination, + CallerId: ValidCreatorId, + CategoryId: Query.CategoryId, + Name: Query.Name, + Sorting: Query.Sorting + ); + private readonly Mock reads = new(); private readonly Mock sender = new(); - private readonly Product[] products = []; - private readonly ProductQuery query; - private readonly Result result; + private static readonly Product[] Products = []; + private static readonly ProductQuery Query = new( + Pagination: new(1, Products.Length) + ); + private static readonly Result Result = new( + Count: Products.Length, + Items: Products + ); public Tests() { handler = new(reads.Object, sender.Object); - query = new( - Pagination: new(1, products.Length) - ); - result = new( - Count: products.Length, - Items: products - ); - reads.Setup(x => x.AllAsync( It.IsAny(), false, ct - )).ReturnsAsync(result); + )).ReturnsAsync(Result); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == Products.Select(x => x.CategoryId)), ct - )).ReturnsAsync(products.ToDictionary(x => x.CategoryId, x => "Cateogry123")); + )).ReturnsAsync(Products.ToDictionary(x => x.CategoryId, x => "Cateogry123")); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - CreatorGetAllProductsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidCreatorId, - CategoryId: this.query.CategoryId, - Name: this.query.Name, - Sorting: this.query.Sorting - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -72,21 +70,14 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CreatorGetAllProductsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidCreatorId, - CategoryId: this.query.CategoryId, - Name: this.query.Name, - Sorting: this.query.Sorting - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == Products.Select(x => x.CategoryId)), ct ), Times.Once() @@ -97,18 +88,11 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - CreatorGetAllProductsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidCreatorId, - CategoryId: this.query.CategoryId, - Name: this.query.Name, - Sorting: this.query.Sorting - ); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert - Assert.Equal(result.Count, products.Length); + Assert.Equal(result.Count, Products.Length); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs index 5f35c6e33..512531535 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetById/Tests.cs @@ -13,6 +13,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Cre public class Tests : Data.Products.BaseUnitTests { private readonly CreatorGetProductByIdHandler handler; + private readonly CreatorGetProductByIdQuery request = new(ValidId, ValidCreatorId); + private readonly Mock reads = new(); private readonly Mock sender = new(); @@ -30,10 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CreatorGetProductByIdQuery query = new(ValidId, ValidCreatorId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CreatorGetProductByIdQuery query = new(ValidId, ValidCreatorId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -72,10 +72,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - CreatorGetProductByIdQuery query = new(ValidId, ValidCreatorId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -93,12 +92,11 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(CreateProduct(creatorId: AccountId.New())); - CreatorGetProductByIdQuery query = new(ValidId, ValidCreatorId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } @@ -108,12 +106,11 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Product); - CreatorGetProductByIdQuery query = new(ValidId, ValidCreatorId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/Tests.cs index 2aea7fce8..4ee547c58 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Creator/GetSortings/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Cre public class Tests : Data.Products.BaseUnitTests { private readonly GetProductCreatorSortingsHandler handler = new(); + private readonly GetProductCreatorSortingsQuery reqeust = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetProductCreatorSortingsQuery query = new(); // Act - ProductCreatorSortingType[] sortings = await handler.Handle(query, ct); + ProductCreatorSortingType[] sortings = await handler.Handle(reqeust, ct); // Assert Assert.Equal(sortings, Enum.GetValues()); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs index e5c204932..a7f106615 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetAll/Tests.cs @@ -13,58 +13,57 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Des public class Tests : Data.Products.BaseUnitTests { private readonly DesignerGetAllProductsHandler handler; + private readonly DesignerGetAllProductsQuery request = new( + Pagination: Query.Pagination, + CallerId: ValidDesignerId, + CategoryId: Query.CategoryId, + Status: Status, + Name: Query.Name, + Sorting: Query.Sorting + ); + private readonly Mock reads = new(); private readonly Mock sender = new(); - private readonly Product[] products = []; - private readonly ProductQuery query; - private readonly Result result; - private readonly ProductStatus Status = ProductStatus.Unchecked; + private static readonly ProductStatus Status = ProductStatus.Unchecked; + private static readonly Product[] Products = []; + private static readonly ProductQuery Query = new( + Pagination: new(1, Products.Length) + ); + private static readonly Result Result = new( + Count: Products.Length, + Items: Products + ); + public Tests() { handler = new(reads.Object, sender.Object); - query = new( - Pagination: new(1, products.Length) - ); - result = new( - Count: products.Length, - Items: products - ); - reads.Setup(x => x.AllAsync( It.IsAny(), false, ct - )).ReturnsAsync(result); + )).ReturnsAsync(Result); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + It.Is(x => x.Ids == Products.Select(x => x.CreatorId)), ct - )).ReturnsAsync(products.ToDictionary(x => x.CreatorId, x => "Username123")); + )).ReturnsAsync(Products.ToDictionary(x => x.CreatorId, x => "Username123")); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == Products.Select(x => x.CategoryId)), ct - )).ReturnsAsync(products.ToDictionary(x => x.CategoryId, x => "Cateogry123")); + )).ReturnsAsync(Products.ToDictionary(x => x.CategoryId, x => "Cateogry123")); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - DesignerGetAllProductsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidDesignerId, - CategoryId: this.query.CategoryId, - Status: Status, - Name: this.query.Name, - Sorting: this.query.Sorting - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -81,29 +80,21 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - DesignerGetAllProductsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidDesignerId, - CategoryId: this.query.CategoryId, - Status: Status, - Name: this.query.Name, - Sorting: this.query.Sorting - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + It.Is(x => x.Ids == Products.Select(x => x.CreatorId)), ct ), Times.Once() ); sender.Verify( x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == Products.Select(x => x.CategoryId)), ct ), Times.Once() @@ -114,19 +105,11 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - DesignerGetAllProductsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidDesignerId, - CategoryId: this.query.CategoryId, - Status: Status, - Name: this.query.Name, - Sorting: this.query.Sorting - ); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert - Assert.Equal(result.Count, products.Length); + Assert.Equal(result.Count, Products.Length); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs index b19dee8cd..f9aad7753 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetById/Tests.cs @@ -12,6 +12,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Des public class Tests : Data.Products.BaseUnitTests { private readonly DesignerGetProductByIdHandler handler; + private readonly DesignerGetProductByIdQuery request = new(ValidId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock sender = new(); @@ -28,10 +30,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DesignerGetProductByIdQuery query = new(ValidId, ValidDesignerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -44,10 +45,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - DesignerGetProductByIdQuery query = new(ValidId, ValidDesignerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -70,10 +70,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - DesignerGetProductByIdQuery query = new(ValidId, ValidDesignerId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -86,16 +85,29 @@ public async Task Handle_ShouldReturnResult() } [Fact] - public async Task Handle_ShouldThrowException_WhenUnauthorizedAndChecked() + public async Task Handle_ShouldNotThrowException_WhenUnauthorizedAccess() + { + // Arrange + + // Act + Exception? ex = await Record.ExceptionAsync( + () => handler.Handle(request with { CallerId = ValidCreatorId }, ct) + ); + + // Assert + Assert.Null(ex); + } + + [Fact] + public async Task Handle_ShouldThrowException_WhenUnauthorizedAccessButValidated() { // Arrange product.Validate(ValidDesignerId); - DesignerGetProductByIdQuery query = new(ValidId, ValidCreatorId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request with { CallerId = ValidCreatorId }, ct) ); } @@ -105,12 +117,11 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Product); - DesignerGetProductByIdQuery query = new(ValidId, ValidDesignerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/Tests.cs index 7c31ce40a..015455a24 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Designer/GetSortings/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Des public class Tests : Data.Products.BaseUnitTests { private readonly GetProductDesignerSortingsHandler handler = new(); + private readonly GetProductDesignerSortingsQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetProductDesignerSortingsQuery query = new(); // Act - ProductDesignerSortingType[] sortings = await handler.Handle(query, ct); + ProductDesignerSortingType[] sortings = await handler.Handle(request, ct); // Assert Assert.Equal(sortings, Enum.GetValues()); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs index 49fc05517..12fe4fdaf 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetAll/Tests.cs @@ -12,56 +12,54 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Gal public class Tests : Data.Products.BaseUnitTests { private readonly GalleryGetAllProductsHandler handler; + private readonly GalleryGetAllProductsQuery request = new( + Pagination: Query.Pagination, + CallerId: ValidCreatorId, + CategoryId: Query.CategoryId, + Name: Query.Name, + Sorting: Query.Sorting + ); + private readonly Mock reads = new(); private readonly Mock sender = new(); - private readonly Product[] products = []; - private readonly ProductQuery query; - private readonly Result result; + private static readonly Product[] Products = []; + private static readonly ProductQuery Query = new( + Pagination: new(1, Products.Length) + ); + private static readonly Result Result = new( + Count: Products.Length, + Items: Products + ); public Tests() { handler = new(reads.Object, sender.Object); - query = new( - Pagination: new(1, products.Length) - ); - result = new( - Count: products.Length, - Items: products - ); - reads.Setup(x => x.AllAsync( It.IsAny(), false, ct - )).ReturnsAsync(result); + )).ReturnsAsync(Result); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + It.Is(x => x.Ids == Products.Select(x => x.CreatorId)), ct - )).ReturnsAsync(products.ToDictionary(x => x.CreatorId, x => "Username123")); + )).ReturnsAsync(Products.ToDictionary(x => x.CreatorId, x => "Username123")); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == Products.Select(x => x.CategoryId)), ct - )).ReturnsAsync(products.ToDictionary(x => x.CategoryId, x => "Cateogry123")); + )).ReturnsAsync(Products.ToDictionary(x => x.CategoryId, x => "Cateogry123")); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - GalleryGetAllProductsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidCreatorId, - CategoryId: this.query.CategoryId, - Name: this.query.Name, - Sorting: this.query.Sorting - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -78,28 +76,21 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - GalleryGetAllProductsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidCreatorId, - CategoryId: this.query.CategoryId, - Name: this.query.Name, - Sorting: this.query.Sorting - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CreatorId)), + It.Is(x => x.Ids == Products.Select(x => x.CreatorId)), ct ), Times.Once() ); sender.Verify( x => x.SendQueryAsync( - It.Is(x => x.Ids == products.Select(x => x.CategoryId)), + It.Is(x => x.Ids == Products.Select(x => x.CategoryId)), ct ), Times.Once() @@ -110,18 +101,11 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - GalleryGetAllProductsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidCreatorId, - CategoryId: this.query.CategoryId, - Name: this.query.Name, - Sorting: this.query.Sorting - ); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert - Assert.Equal(result.Count, products.Length); + Assert.Equal(result.Count, Products.Length); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs index 8162c7e6b..24e6ee30c 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs @@ -17,6 +17,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Gal public class Tests : Data.Products.BaseUnitTests { private readonly GalleryGetProductByIdHandler handler; + private readonly GalleryGetProductByIdQuery request = new(ValidId, ValidCreatorId, Viewed: false); + private readonly Mock reads = new(); private readonly Mock sender = new(); private readonly Mock raiser = new(); @@ -38,10 +40,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GalleryGetProductByIdQuery query = new(ValidId, ValidCreatorId, Viewed: false); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -54,10 +55,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - GalleryGetProductByIdQuery query = new(ValidId, ValidCreatorId, Viewed: false); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -83,13 +83,11 @@ public async Task Handle_ShouldSendRequests() [InlineData(true, true)] public async Task Handle_ShouldRaiseEvents(bool authenticatedUser, bool viewed) { - AccountId creatorId = authenticatedUser ? ValidCreatorId : AccountId.New(Guid.Empty); - // Arrange - GalleryGetProductByIdQuery query = new(ValidId, creatorId, Viewed: viewed); + AccountId creatorId = authenticatedUser ? ValidCreatorId : new(); // Act - await handler.Handle(query, ct); + await handler.Handle(request with { CallerId = creatorId }, ct); // Assert raiser.Verify( @@ -104,10 +102,9 @@ public async Task Handle_ShouldRaiseEvents(bool authenticatedUser, bool viewed) public async Task Handle_ShouldReturnResult() { // Arrange - GalleryGetProductByIdQuery query = new(ValidId, ValidCreatorId, Viewed: false); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -124,12 +121,11 @@ public async Task Handle_ShouldThrowException_WhenStatusIsNotValid() { // Arrange product.Report(ValidDesignerId); - GalleryGetProductByIdQuery query = new(ValidId, ValidCreatorId, Viewed: false); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } @@ -139,12 +135,11 @@ public async Task Handle_ShouldThrowException_WhenProductNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Product); - GalleryGetProductByIdQuery query = new(ValidId, ValidCreatorId, Viewed: false); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/Tests.cs index 5b1d7e99e..e5cc1bddf 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetSortings/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Internal.Gal public class Tests : Data.Products.BaseUnitTests { private readonly GetProductGallerySortingsHandler handler = new(); + private readonly GetProductGallerySortingsQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetProductGallerySortingsQuery query = new(); // Act - ProductGallerySortingType[] sortings = await handler.Handle(query, ct); + ProductGallerySortingType[] sortings = await handler.Handle(request, ct); // Assert Assert.Equal(sortings, Enum.GetValues()); diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs index 3b651de8d..c91acce7b 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchCadIdById/Tests.cs @@ -10,44 +10,42 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.Batch public class Tests : Data.Products.BaseUnitTests { private readonly BatchGetProductCadIdByIdHandler handler; + private readonly BatchGetProductCadIdByIdQuery request = new(Ids); + private readonly Mock reads = new(); - private readonly ProductId[] ids = [ValidId, ValidId, ValidId]; - private readonly ProductQuery query; - private readonly Result result; - private readonly Product[] products = [ + private static readonly Product[] Products = [ CreateProduct(MinValidName, MinValidDescription, MinValidPrice, id: ProductId.New()), CreateProduct(MaxValidName, MaxValidDescription, MaxValidPrice, id: ProductId.New()), ]; + private static readonly ProductId[] Ids = [.. Products.Select(x => x.Id)]; + private static readonly ProductQuery Query = new( + Ids: Ids, + Pagination: new(Limit: Ids.Length) + ); + private static readonly Result Result = new( + Count: Products.Length, + Items: Products + ); public Tests() { handler = new(reads.Object); - - query = new( - Ids: ids, - Pagination: new(Limit: ids.Length) - ); - result = new( - Count: products.Length, - Items: products - ); - reads.Setup(x => x.AllAsync(query, false, ct)) - .ReturnsAsync(result); + reads.Setup(x => x.AllAsync(Query, false, ct)) + .ReturnsAsync(Result); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - BatchGetProductCadIdByIdQuery query = new(ids); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(this.query, false, ct), + x => x.AllAsync(Query, false, ct), Times.Once() ); } @@ -56,15 +54,14 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - BatchGetProductCadIdByIdQuery query = new(ids); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Multiple( - () => Assert.True(result.ElementAt(0).Value == ValidCadId), - () => Assert.True(result.ElementAt(1).Value == ValidCadId) + () => Assert.True(result[Ids[0]] == Products[0].CadId), + () => Assert.True(result[Ids[1]] == Products[1].CadId) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs index 3be90e4f9..e7800471a 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/BatchPriceById/Tests.cs @@ -10,44 +10,43 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.Batch public class Tests : Data.Products.BaseUnitTests { private readonly BatchGetProductPriceByIdHandler handler; + private readonly BatchGetProductPriceByIdQuery request = new(Ids); + private readonly Mock reads = new(); - private readonly ProductId[] ids = [ValidId, ValidId, ValidId]; - private readonly ProductQuery query; - private readonly Result result; - private readonly Product[] products = [ + private static readonly Product[] Products = [ CreateProduct(MinValidName, MinValidDescription, MinValidPrice, id: ProductId.New()), CreateProduct(MaxValidName, MaxValidDescription, MaxValidPrice, id: ProductId.New()), ]; + private static readonly ProductId[] Ids = [.. Products.Select(x => x.Id)]; + private static readonly ProductQuery Query = new( + Ids: Ids, + Pagination: new(Limit: Ids.Length) + ); + private static readonly Result Result = new( + Count: Products.Length, + Items: Products + ); public Tests() { handler = new(reads.Object); - query = new( - Ids: ids, - Pagination: new(Limit: ids.Length) - ); - result = new( - Count: products.Length, - Items: products - ); - reads.Setup(x => x.AllAsync(query, false, ct)) - .ReturnsAsync(result); + reads.Setup(x => x.AllAsync(Query, false, ct)) + .ReturnsAsync(Result); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - BatchGetProductPriceByIdQuery query = new(ids); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(this.query, false, ct), + x => x.AllAsync(Query, false, ct), Times.Once() ); } @@ -56,15 +55,14 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - BatchGetProductPriceByIdQuery query = new(ids); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Multiple( - () => Assert.True(result.ElementAt(0).Value == MinValidPrice), - () => Assert.True(result.ElementAt(1).Value == MaxValidPrice) + () => Assert.True(result[Ids[0]] == Products[0].Price), + () => Assert.True(result[Ids[1]] == Products[1].Price) ); } } diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs index c22214294..3a9db0a4b 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Shared/GetExists/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Products.Queries.Shared.GetEx public class Tests : Data.Products.BaseUnitTests { private readonly GetProductExistsByIdHandler handler; + private readonly GetProductExistsByIdQuery request = new(ValidId); + private readonly Mock reads = new(); public Tests() @@ -21,10 +23,9 @@ public async Task Handle_ShouldQueryDatabase() { // Arrange reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)).ReturnsAsync(true); - GetProductExistsByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -40,10 +41,9 @@ public async Task Handle_ShouldReturnResult(bool exists) { // Arrange reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)).ReturnsAsync(exists); - GetProductExistsByIdQuery query = new(ValidId); // Act - bool result = await handler.Handle(query, ct); + bool result = await handler.Handle(request, ct); // Assert Assert.Equal(exists, result); diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs index a92e09a75..c6d26d383 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Create/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Commands.Internal.Create public class Tests : Data.Tags.BaseUnitTests { private readonly CreateTagHandler handler; + private readonly CreateTagCommand request = new(MaxValidName); + private readonly Mock writes = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -29,10 +31,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateTagCommand command = new(MaxValidName); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -52,10 +53,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - CreateTagCommand command = new(MaxValidName); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -68,10 +68,9 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldReturnResult() { // Arrange - CreateTagCommand command = new(MaxValidName); // Act - TagId id = await handler.Handle(command, ct); + TagId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs index 3b47fa8f8..4df98a090 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Delete/Tests.cs @@ -11,12 +11,14 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Commands.Internal.Delete public class Tests : Data.Tags.BaseUnitTests { private readonly DeleteTagHandler handler; + private readonly DeleteTagCommand request = new(ValidId); + private readonly Mock uow = new(); private readonly Mock writes = new(); private readonly Mock reads = new(); private readonly Mock> cache = new(); - private static readonly Tag tag = CreateTag(); + private readonly Tag tag = CreateTag(); public Tests() { @@ -30,10 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DeleteTagCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - DeleteTagCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -62,10 +62,9 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DeleteTagCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -84,12 +83,11 @@ public async Task Handle_ShouldThrowException_WhenTagNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Tag); - DeleteTagCommand command = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs index 207d17e79..58513317e 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Commands/Internal/Edit/Tests.cs @@ -10,6 +10,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Commands.Internal.Edit; public class Tests : Data.Tags.BaseUnitTests { private readonly EditTagHandler handler; + private readonly EditTagCommand request = new(ValidId, MaxValidName); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -28,10 +30,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - EditTagCommand command = new(ValidId, MaxValidName); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -44,10 +45,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - EditTagCommand command = new(ValidId, MaxValidName); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -60,10 +60,9 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldPersistToDatabase() { // Arrange - EditTagCommand command = new(ValidId, MaxValidName); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -83,12 +82,11 @@ public async Task Handle_ShouldThrowException_WhenTagNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Tag); - EditTagCommand command = new(ValidId, MaxValidName); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/Tests.cs index c7088451c..7753660ab 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetAll/Tests.cs @@ -9,10 +9,12 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Queries.Internal.GetAll; public class Tests : Data.Tags.BaseUnitTests { private readonly GetAllTagsHandler handler; + private readonly GetAllTagsQuery request = new(); + private readonly Mock reads = new(); private readonly Mock> cache = new(); - private readonly Tag[] tags = [ + private static readonly Tag[] Tags = [ CreateTag(MinValidName), CreateTag(MaxValidName) ]; @@ -23,17 +25,16 @@ public Tests() cache.Setup(x => x.GetOrCreateAsync( It.IsAny>>>() - )).ReturnsAsync(tags); + )).ReturnsAsync(Tags); } [Fact] public async Task Handle_ShouldReadCache() { // Arrange - GetAllTagsQuery query = new(); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -46,15 +47,14 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - GetAllTagsQuery query = new(); // Act - TagDto[] tags = await handler.Handle(query, ct); + TagDto[] tags = await handler.Handle(request, ct); // Assert Assert.Multiple( - () => Assert.Equal(tags.Select(r => r.Id), this.tags.Select(r => r.Id)), - () => Assert.Equal(tags.Select(r => r.Name), this.tags.Select(r => r.Name)) + () => Assert.Equal(tags.Select(r => r.Id), Tags.Select(r => r.Id)), + () => Assert.Equal(tags.Select(r => r.Name), Tags.Select(r => r.Name)) ); } } diff --git a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs index 79d0a8205..3b073b3e7 100644 --- a/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Tags/Queries/Internal/GetById/Tests.cs @@ -8,6 +8,8 @@ namespace CustomCADs.UnitTests.Catalog.Application.Tags.Queries.Internal.GetById public class Tests : Data.Tags.BaseUnitTests { private readonly GetTagByIdHandler handler; + private readonly GetTagByIdQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock> cache = new(); @@ -25,10 +27,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - GetTagByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -41,12 +42,11 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldReturnResult() { // Arrange - GetTagByIdQuery query = new(ValidId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert - Assert.Equal(Data.Tags.TestData.ValidId, result.Id); + Assert.Equal(ValidId, result.Id); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs index c3634df61..9afc30a1a 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/Remove/Tests.cs @@ -14,6 +14,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Adm public class Tests : Data.Customs.BaseUnitTests { private readonly RemoveCustomHandler handler; + private readonly RemoveCustomCommand request = new(ValidId, ValidAdminId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock raiser = new(); @@ -33,13 +35,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - RemoveCustomCommand command = new( - Id: ValidId, - CallerId: ValidAdminId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -52,13 +50,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - RemoveCustomCommand command = new( - Id: ValidId, - CallerId: ValidAdminId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -71,13 +65,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - RemoveCustomCommand command = new( - Id: ValidId, - CallerId: ValidAdminId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -92,13 +82,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldPopulateProperties() { // Arrange - RemoveCustomCommand command = new( - Id: ValidId, - CallerId: ValidAdminId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Equal(CustomStatus.Removed, custom.CustomStatus); @@ -111,15 +97,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - RemoveCustomCommand command = new( - Id: ValidId, - CallerId: ValidAdminId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs index 0ddf16bd7..ca9652582 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Admin/SetCategory/Tests.cs @@ -11,6 +11,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Adm public class Tests : Data.Customs.BaseUnitTests { private readonly AdminSetCustomCategoryHandler handler; + private readonly AdminSetCustomCategoryCommand request = new(ValidId, ValidCategoryId); + private readonly Mock reads = new(); private readonly Mock uow = new(); @@ -28,13 +30,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - AdminSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -47,13 +45,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - AdminSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -66,13 +60,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldPopulateProperties() { // Arrange - AdminSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -88,15 +78,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - AdminSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs index 9446cb142..6637a5d61 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Create/Tests.cs @@ -14,6 +14,15 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Cus public class Tests : Data.Customs.BaseUnitTests { private readonly CreateCustomHandler handler; + private readonly CreateCustomCommand request = new( + Name: MaxValidName, + Description: MaxValidDescription, + ForDelivery: true, + CallerId: ValidBuyerId, + CategoryId: ValidCategoryId + ); + + private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -48,16 +57,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateCustomCommand command = new( - Name: MaxValidName, - Description: MaxValidDescription, - ForDelivery: true, - CallerId: ValidBuyerId, - CategoryId: ValidCategoryId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -82,16 +84,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CreateCustomCommand command = new( - Name: MaxValidName, - Description: MaxValidDescription, - ForDelivery: true, - CallerId: ValidBuyerId, - CategoryId: ValidCategoryId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -114,16 +109,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - CreateCustomCommand command = new( - Name: MaxValidName, - Description: MaxValidDescription, - ForDelivery: true, - CallerId: ValidBuyerId, - CategoryId: ValidCategoryId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -138,16 +126,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldReturnResult() { // Arrange - CreateCustomCommand command = new( - Name: MaxValidName, - Description: MaxValidDescription, - ForDelivery: true, - CallerId: ValidBuyerId, - CategoryId: ValidCategoryId - ); // Act - CustomId id = await handler.Handle(command, ct); + CustomId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); @@ -162,18 +143,10 @@ public async Task Handle_ShouldThrowException_WhenBuyerNotFound() ct )).ReturnsAsync(false); - CreateCustomCommand command = new( - Name: MaxValidName, - Description: MaxValidDescription, - ForDelivery: true, - CallerId: ValidBuyerId, - CategoryId: ValidCategoryId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs index 205d58c0b..227df79be 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Delete/Tests.cs @@ -13,6 +13,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Cus public class Tests : Data.Customs.BaseUnitTests { private readonly DeleteCustomHandler handler; + private readonly DeleteCustomCommand request = new(ValidId, ValidBuyerId); + private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); @@ -32,13 +34,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DeleteCustomCommand command = new( - Id: ValidId, - CallerId: ValidBuyerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -51,13 +49,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DeleteCustomCommand command = new( - Id: ValidId, - CallerId: ValidBuyerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -78,18 +72,10 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents(bool isPending) { // Arrange - if (!isPending) - { - custom.Accept(ValidDesignerId); - } - - DeleteCustomCommand command = new( - Id: ValidId, - CallerId: ValidBuyerId - ); + if (!isPending) custom.Accept(ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs index 443af6a06..f220c7ae3 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Edit/Tests.cs @@ -4,7 +4,6 @@ using CustomCADs.Shared.Application.Abstractions.Events; using CustomCADs.Shared.Application.Dtos.Notifications; using CustomCADs.Shared.Application.Events.Notifications; -using CustomCADs.Shared.Domain.TypedIds.Accounts; namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Customer.Edit; @@ -13,6 +12,14 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Cus public class Tests : Data.Customs.BaseUnitTests { private readonly EditCustomHandler handler; + private readonly EditCustomCommand request = new( + Id: ValidId, + Name: MaxValidName, + Description: MaxValidDescription, + CategoryId: ValidCategoryId, + CallerId: ValidBuyerId + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock raiser = new(); @@ -31,16 +38,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - EditCustomCommand command = new( - Id: ValidId, - Name: MaxValidName, - Description: MaxValidDescription, - CategoryId: ValidCategoryId, - CallerId: ValidBuyerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -53,16 +53,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - EditCustomCommand command = new( - Id: ValidId, - Name: MaxValidName, - Description: MaxValidDescription, - CategoryId: ValidCategoryId, - CallerId: ValidBuyerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -77,21 +70,10 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents(bool isPending) { // Arrange - if (!isPending) - { - custom.Accept(ValidDesignerId); - } - - EditCustomCommand command = new( - Id: ValidId, - Name: MaxValidName, - Description: MaxValidDescription, - CategoryId: ValidCategoryId, - CallerId: ValidBuyerId - ); + if (!isPending) custom.Accept(ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs index f827b3d02..824bed882 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/Normal/Tests.cs @@ -18,6 +18,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Cus public class Tests : Data.Customs.BaseUnitTests { private readonly PurchaseCustomHandler handler; + private readonly PurchaseCustomCommand request = new(ValidId, PaymentMethodId, ValidBuyerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -45,10 +47,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - PurchaseCustomCommand command = new(ValidId, PaymentMethodId, ValidBuyerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -61,10 +62,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - PurchaseCustomCommand command = new(ValidId, PaymentMethodId, ValidBuyerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -80,10 +80,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - PurchaseCustomCommand command = new(ValidId, PaymentMethodId, ValidBuyerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -104,10 +103,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldCallPayment() { // Arrange - PurchaseCustomCommand command = new(ValidId, PaymentMethodId, ValidBuyerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert payment.Verify( @@ -136,10 +134,9 @@ public async Task Handle_ShouldReturnResult() It.Is<(string, string Name, string)>(x => x.Name == custom.Name), ct )).ReturnsAsync(expected); - PurchaseCustomCommand command = new(ValidId, PaymentMethodId, ValidBuyerId); // Act - PaymentDto actual = await handler.Handle(command, ct); + PaymentDto actual = await handler.Handle(request, ct); // Assert Assert.Equal(expected, actual); @@ -149,12 +146,11 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange - PurchaseCustomCommand command = new(ValidId, string.Empty, AccountId.New()); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { CallerId = new() }, ct) ); } @@ -165,12 +161,11 @@ public async Task Handle_ShouldThrowException_WhenNotAccepted() var custom = CreateCustom(buyerId: ValidBuyerId); reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(custom); - PurchaseCustomCommand command = new(ValidId, PaymentMethodId, ValidBuyerId); // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -182,12 +177,11 @@ public async Task Handle_ShouldThrowException_WhenNotFinished() custom.Accept(ValidDesignerId); reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(custom); - PurchaseCustomCommand command = new(ValidId, PaymentMethodId, ValidBuyerId); // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -198,12 +192,11 @@ public async Task Handle_ShouldThrowException_WhenForDelivery() var custom = CreateCustom(buyerId: ValidBuyerId, forDelivery: true); reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(custom); - PurchaseCustomCommand command = new(ValidId, PaymentMethodId, ValidBuyerId); // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -213,12 +206,11 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Custom); - PurchaseCustomCommand command = new(ValidId, PaymentMethodId, ValidBuyerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs index bac69e0e3..1a8970c77 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Tests.cs @@ -21,14 +21,25 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Cus public class Tests : Data.Customs.BaseUnitTests { private readonly PurchaseCustomWithDeliveryHandler handler; + private readonly PurchaseCustomWithDeliveryCommand request = new( + Id: ValidId, + Count: 1, + CustomizationId: ValidCustomizationId, + PaymentMethodId: string.Empty, + ShipmentService: string.Empty, + CallerId: ValidBuyerId, + Address: Address, + Contact: Contact + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); private readonly Mock payment = new(); private readonly Mock raiser = new(); - private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); - private static readonly ContactDto contact = new(null, null); + private static readonly AddressDto Address = new("Bulgaria", "Burgas", "Slivnitsa"); + private static readonly ContactDto Contact = new(null, null); private readonly Custom custom = CreateCustom(forDelivery: true); public Tests() @@ -57,19 +68,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -82,19 +83,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -124,19 +115,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldCallPayment() { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert payment.Verify( @@ -156,19 +137,9 @@ public async Task Handle_ShouldCallPayment() public async Task Handle_ShouldRaiseEvents() { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -205,19 +176,8 @@ public async Task Handle_ShouldReturnResult() ct )).ReturnsAsync(expected); - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); - // Act - PaymentDto actual = await handler.Handle(command, ct); + PaymentDto actual = await handler.Handle(request, ct); // Assert Assert.Equal(expected, actual); @@ -227,21 +187,11 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: AccountId.New(), - Address: address, - Contact: contact - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { CallerId = new() }, ct) ); } @@ -253,21 +203,10 @@ public async Task Handle_ShouldThrowException_WhenNotAccepted() reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(custom); - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); - // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -280,21 +219,10 @@ public async Task Handle_ShouldThrowException_WhenNotFinished() reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(custom); - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); - // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -305,21 +233,10 @@ public async Task Handle_ShouldThrowException_WhenNoForDelivery() reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(CreateCustom(buyerId: ValidBuyerId, forDelivery: false)); - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); - // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -330,21 +247,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Custom); - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - Count: 1, - CustomizationId: ValidCustomizationId, - PaymentMethodId: string.Empty, - ShipmentService: string.Empty, - CallerId: ValidBuyerId, - Address: address, - Contact: contact - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs index de37a70f6..1302ddf8f 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/Purchase/WithDelivery/Validator.cs @@ -8,25 +8,29 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Cus public class Validator : Data.Customs.BaseUnitTests { private readonly PurchaseCustomWithDeliveryValidator validator = new(); - - [Theory] - [ClassData(typeof(ValidData))] - public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) - { - // Arrange - PurchaseCustomWithDeliveryCommand command = new( + private static PurchaseCustomWithDeliveryCommand Request(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) + => new( Id: ValidId, - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - CustomizationId: ValidCustomizationId, Count: count, + CustomizationId: ValidCustomizationId, + PaymentMethodId: paymentMethodId, ShipmentService: shipmentService, + CallerId: ValidBuyerId, Address: new(country, city, street), Contact: new(phone, email) ); + [Theory] + [ClassData(typeof(ValidData))] + public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) + { + // Arrange + // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, count, shipmentService, country, city, street, phone, email), + cancellationToken: ct + ); // Assert Assert.True(result.IsValid); @@ -41,19 +45,12 @@ public async Task Validate_ShouldBeValid_WhenCartIsValid(string paymentMethodId, public async Task Validate_ShouldBeInvalid_WhenCartIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - CustomizationId: ValidCustomizationId, - Count: count, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, count, shipmentService, country, city, street, phone, email), + cancellationToken: ct + ); // Assert Assert.False(result.IsValid); @@ -64,19 +61,12 @@ public async Task Validate_ShouldBeInvalid_WhenCartIsNotValid(string paymentMeth public async Task Validate_ShouldReturnProperErrors_WhenShipmentServiceIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - CustomizationId: ValidCustomizationId, - Count: count, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, count, shipmentService, country, city, street, phone, email), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.ShipmentService); @@ -87,19 +77,12 @@ public async Task Validate_ShouldReturnProperErrors_WhenShipmentServiceIsNotVali public async Task Validate_ShouldReturnProperErrors_WhenCountryIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - CustomizationId: ValidCustomizationId, - Count: count, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, count, shipmentService, country, city, street, phone, email), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.Address.Country); @@ -110,19 +93,12 @@ public async Task Validate_ShouldReturnProperErrors_WhenCountryIsNotValid(string public async Task Validate_ShouldReturnProperErrors_WhenCityIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - CustomizationId: ValidCustomizationId, - Count: count, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, count, shipmentService, country, city, street, phone, email), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.Address.City); @@ -133,19 +109,12 @@ public async Task Validate_ShouldReturnProperErrors_WhenCityIsNotValid(string pa public async Task Validate_ShouldReturnProperErrors_WhenPhoneIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - CustomizationId: ValidCustomizationId, - Count: count, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, count, shipmentService, country, city, street, phone, email), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.Contact.Phone); @@ -156,19 +125,12 @@ public async Task Validate_ShouldReturnProperErrors_WhenPhoneIsNotValid(string p public async Task Validate_ShouldReturnProperErrors_WhenEmailIsNotValid(string paymentMethodId, int count, string shipmentService, string country, string city, string street, string? phone, string? email) { // Arrange - PurchaseCustomWithDeliveryCommand command = new( - Id: ValidId, - PaymentMethodId: paymentMethodId, - CallerId: ValidBuyerId, - CustomizationId: ValidCustomizationId, - Count: count, - ShipmentService: shipmentService, - Address: new(country, city, street), - Contact: new(phone, email) - ); // Act - var result = await validator.TestValidateAsync(command, cancellationToken: ct); + var result = await validator.TestValidateAsync( + Request(paymentMethodId, count, shipmentService, country, city, street, phone, email), + cancellationToken: ct + ); // Assert result.ShouldHaveValidationErrorFor(x => x.Contact.Email); diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs index 3d522895f..648617d15 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Customer/SetDelivery/Tests.cs @@ -13,6 +13,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Cus public class Tests : Data.Customs.BaseUnitTests { private readonly SetCustomDeliveryHandler handler; + private readonly SetCustomDeliveryCommand request = new(ValidId, NewValue, ValidBuyerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock raiser = new(); @@ -32,14 +34,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - SetCustomDeliveryCommand command = new( - Id: ValidId, - Value: NewValue, - BuyerId: ValidBuyerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -52,14 +49,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - SetCustomDeliveryCommand command = new( - Id: ValidId, - Value: NewValue, - BuyerId: ValidBuyerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -74,19 +66,10 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents(bool isPending) { // Arrange - if (!isPending) - { - custom.Accept(ValidDesignerId); - } - - SetCustomDeliveryCommand command = new( - Id: ValidId, - Value: NewValue, - BuyerId: ValidBuyerId - ); + if (!isPending) custom.Accept(ValidDesignerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -101,14 +84,9 @@ public async Task Handle_ShouldRaiseEvents(bool isPending) public async Task Handle_ShouldPopulateProperties() { // Arrange - SetCustomDeliveryCommand command = new( - Id: ValidId, - Value: NewValue, - BuyerId: ValidBuyerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Equal(NewValue, custom.ForDelivery); @@ -121,16 +99,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - SetCustomDeliveryCommand command = new( - Id: ValidId, - Value: NewValue, - BuyerId: ValidBuyerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs index 059c97883..759efeee0 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Accept/Tests.cs @@ -16,6 +16,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Des public class Tests : Data.Customs.BaseUnitTests { private readonly AcceptCustomHandler handler; + private readonly AcceptCustomCommand request = new(ValidId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -40,13 +42,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - AcceptCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -59,13 +57,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - AcceptCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -78,13 +72,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - AcceptCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -107,13 +97,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - AcceptCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -128,13 +114,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldPopulateProperties() { // Arrange - AcceptCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -152,15 +134,10 @@ public async Task Handle_ShouldThrowException_WhenDesignerNotFound() ct )).ReturnsAsync(false); - AcceptCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -171,15 +148,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - AcceptCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs index 28329d09c..255547cbf 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Begin/Tests.cs @@ -15,6 +15,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Des public class Tests : Data.Customs.BaseUnitTests { private readonly BeginCustomHandler handler; + private readonly BeginCustomCommand request = new(ValidId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock raiser = new(); @@ -34,13 +36,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - BeginCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -53,13 +51,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - BeginCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -72,13 +66,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - BeginCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -93,13 +83,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldPopulateProperties() { // Arrange - BeginCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -117,15 +103,10 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); - BeginCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -136,15 +117,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - BeginCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs index 8c6963dee..62539efaf 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Cancel/Tests.cs @@ -15,6 +15,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Des public class Tests : Data.Customs.BaseUnitTests { private readonly CancelCustomHandler handler; + private readonly CancelCustomCommand request = new(ValidId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock raiser = new(); @@ -34,13 +36,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CancelCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -53,13 +51,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CancelCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -72,13 +66,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldRaiseEvents() { // Arrange - CancelCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -93,13 +83,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldPopulateProperties() { // Arrange - CancelCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -117,15 +103,10 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); - CancelCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -136,15 +117,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - CancelCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs index f7036d571..eac7601a8 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Finish/Tests.cs @@ -17,6 +17,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Des public class Tests : Data.Customs.BaseUnitTests { private readonly FinishCustomHandler handler; + private readonly FinishCustomCommand request = new(ValidId, ValidPrice, ValidCadId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -43,15 +45,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - FinishCustomCommand command = new( - Id: ValidId, - CadId: ValidCadId, - Price: ValidPrice, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -64,15 +60,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - FinishCustomCommand command = new( - Id: ValidId, - CadId: ValidCadId, - Price: ValidPrice, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -85,15 +75,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - FinishCustomCommand command = new( - Id: ValidId, - CadId: ValidCadId, - Price: ValidPrice, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -109,15 +93,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - FinishCustomCommand command = new( - Id: ValidId, - CadId: ValidCadId, - Price: ValidPrice, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -132,15 +110,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldPopulateProperties() { // Arrange - FinishCustomCommand command = new( - Id: ValidId, - CadId: ValidCadId, - Price: ValidPrice, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -158,17 +130,10 @@ public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); - FinishCustomCommand command = new( - Id: ValidId, - CadId: ValidCadId, - Price: ValidPrice, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -179,17 +144,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - FinishCustomCommand command = new( - Id: ValidId, - CadId: ValidCadId, - Price: ValidPrice, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs index ca969067d..ebc083859 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/Report/Tests.cs @@ -8,7 +8,6 @@ using CustomCADs.Shared.Application.Events.Notifications; using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; -using CustomCADs.Shared.Domain.TypedIds.Accounts; namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Designer.Report; @@ -17,6 +16,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Des public class Tests : Data.Customs.BaseUnitTests { private readonly ReportCustomHandler handler; + private readonly ReportCustomCommand request = new(ValidId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -37,13 +38,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ReportCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -56,13 +53,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ReportCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -75,13 +68,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - ReportCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -97,13 +86,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - ReportCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( @@ -118,13 +103,9 @@ public async Task Handle_ShouldRaiseEvents() public async Task Handle_ShouldPopulateProperties() { // Arrange - ReportCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -137,15 +118,11 @@ public async Task Handle_ShouldPopulateProperties() public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange - ReportCustomCommand command = new( - Id: ValidId, - CallerId: AccountId.New() - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { CallerId = new() }, ct) ); } @@ -154,14 +131,14 @@ public async Task Handle_ShouldNotThrowException_WhenUnauthorizedAccessButPendin { // Arrange custom.Cancel(); - ReportCustomCommand command = new( - Id: ValidId, - CallerId: AccountId.New() + + // Act + Exception? ex = await Record.ExceptionAsync( + () => handler.Handle(request with { CallerId = new() }, ct) ); // Assert - // Act - await handler.Handle(command, ct); + Assert.Null(ex); } [Fact] @@ -171,15 +148,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - ReportCustomCommand command = new( - Id: ValidId, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs index c4017cb1c..e0a0d58b6 100644 --- a/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Commands/Internal/Designer/SetCategory/Tests.cs @@ -12,6 +12,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Commands.Internal.Des public class Tests : Data.Customs.BaseUnitTests { private readonly DesignerSetCustomCategoryHandler handler; + private readonly DesignerSetCustomCategoryCommand request = new(ValidId, ValidCategoryId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); @@ -30,14 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DesignerSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -50,14 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DesignerSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -70,14 +62,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldPopulateProperties() { // Arrange - DesignerSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId, - CallerId: ValidDesignerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -90,16 +77,11 @@ public async Task Handle_ShouldPopulateProperties() public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange - DesignerSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId, - CallerId: AccountId.New() - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { CallerId = new() }, ct) ); } @@ -108,15 +90,14 @@ public async Task Handle_ShouldNotThrowException_WhenUnauthorizedAccessButPendin { // Arrange custom.Cancel(); - DesignerSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId, - CallerId: AccountId.New() - ); // Act + Exception? ex = await Record.ExceptionAsync( + () => handler.Handle(request with { CallerId = new() }, ct) + ); + // Assert - await handler.Handle(command, ct); + Assert.Null(ex); } [Fact] @@ -126,16 +107,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - DesignerSetCustomCategoryCommand command = new( - Id: ValidId, - CategoryId: ValidCategoryId, - CallerId: ValidDesignerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs index 35e642ee1..a15086bb6 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/DeliveryRequested/Tests.cs @@ -13,7 +13,17 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Events.Application.De public class Tests : Data.Customs.BaseUnitTests { - private readonly CustomDeliveryRequestedApplicationEventHandler handler; + private readonly CustomDeliveryRequestedHandler handler; + private readonly CustomDeliveryRequestedApplicationEvent request = new( + CustomId: ValidId, + ShipmentService: ShipmentService, + Weight: Weight, + Count: Count, + Address: Address, + Contact: Contact + ); + + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -21,8 +31,8 @@ public class Tests : Data.Customs.BaseUnitTests private const string ShipmentService = "shipment-service"; private const double Weight = 5.2; private const int Count = 3; - private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); - private static readonly ContactDto contact = new("0123456789", null); + private static readonly AddressDto Address = new("Bulgaria", "Burgas", "Slivnitsa"); + private static readonly ContactDto Contact = new("0123456789", null); private readonly Custom custom = CreateCustom(forDelivery: true); public Tests() @@ -52,17 +62,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CustomDeliveryRequestedApplicationEvent @event = new( - CustomId: ValidId, - ShipmentService: ShipmentService, - Weight: Weight, - Count: Count, - Address: address, - Contact: contact - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -75,17 +77,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CustomDeliveryRequestedApplicationEvent @event = new( - CustomId: ValidId, - ShipmentService: ShipmentService, - Weight: Weight, - Count: Count, - Address: address, - Contact: contact - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert uow.Verify( @@ -98,17 +92,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CustomDeliveryRequestedApplicationEvent @event = new( - CustomId: ValidId, - ShipmentService: ShipmentService, - Weight: Weight, - Count: Count, - Address: address, - Contact: contact - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert sender.Verify( @@ -131,17 +117,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldPopulateProperties() { // Arrange - CustomDeliveryRequestedApplicationEvent @event = new( - CustomId: ValidId, - ShipmentService: ShipmentService, - Weight: Weight, - Count: Count, - Address: address, - Contact: contact - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert Assert.Equal(ValidShipmentId, custom.CompletedCustom?.ShipmentId); @@ -154,19 +132,10 @@ public async Task Handle_ShouldThrowException_WhenCustomNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Custom); - CustomDeliveryRequestedApplicationEvent @event = new( - CustomId: ValidId, - ShipmentService: ShipmentService, - Weight: Weight, - Count: Count, - Address: address, - Contact: contact - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.HandleAsync(@event) + () => handler.HandleAsync(request) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs index 0c3eec8ce..fe991dd5c 100644 --- a/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Events/Application/PaymentCompleted/Tests.cs @@ -15,7 +15,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Events.Application.Pa public class Tests : Data.Customs.BaseUnitTests { - private CustomPaymentCompletedApplicationEventHandler handler; + private readonly CustomPaymentCompletedHandler handler; + private readonly CustomPaymentCompletedApplicationEvent request = new(ValidId, ValidBuyerId); private readonly Mock reads = new(); private readonly Mock uow = new(); @@ -49,10 +50,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -65,10 +65,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert uow.Verify( @@ -81,10 +80,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert sender.Verify( @@ -107,10 +105,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldSendEmail() { // Arrange - CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert email.Verify( @@ -137,10 +134,8 @@ public async Task Handle_ShouldGrantShipment_WhenForDelivery() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(custom); - CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); - // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert sender.Verify( @@ -165,12 +160,11 @@ public async Task Handle_ShouldThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Custom); - CustomPaymentCompletedApplicationEvent @event = new(ValidId, ValidBuyerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.HandleAsync(@event) + () => handler.HandleAsync(request) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs index 9506c566c..f73eb122d 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/CalculateShipment/Tests.cs @@ -12,11 +12,13 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Cust public class Tests : Data.Customs.BaseUnitTests { private readonly CalculateCustomShipmentHandler handler; + private readonly CalculateCustomShipmentQuery request = new(ValidId, 0, Address, ValidCustomizationId); + private readonly Mock reads = new(); private readonly Mock sender = new(); - private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); - private static readonly CalculateShipmentDto[] calculations = [ + private static readonly AddressDto Address = new("Bulgaria", "Burgas", "Slivnitsa"); + private static readonly CalculateShipmentDto[] Calculations = [ new(default, string.Empty, string.Empty, default, default) ]; @@ -35,17 +37,16 @@ public Tests() sender.Setup(x => x.SendQueryAsync( It.IsAny(), ct - )).ReturnsAsync(calculations); + )).ReturnsAsync(Calculations); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - CalculateCustomShipmentQuery query = new(ValidId, 0, address, ValidCustomizationId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -58,10 +59,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CalculateCustomShipmentQuery query = new(ValidId, 0, address, ValidCustomizationId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -73,7 +73,7 @@ public async Task Handle_ShouldSendRequests() ); sender.Verify( x => x.SendQueryAsync( - It.Is(x => x.Address == address), + It.Is(x => x.Address == Address), ct ), Times.Once() @@ -84,12 +84,11 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - CalculateCustomShipmentQuery query = new(ValidId, 0, address, ValidCustomizationId); // Act - CalculateShipmentDto[] result = await handler.Handle(query, ct); + CalculateShipmentDto[] result = await handler.Handle(request, ct); // Assert - Assert.Equal(calculations, result); + Assert.Equal(Calculations, result); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs index a123c2d36..e50076614 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/Count/Tests.cs @@ -9,9 +9,11 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Cust public class Tests : Data.Customs.BaseUnitTests { private readonly CountCustomsHandler handler; + private readonly CountCustomsQuery request = new(ValidBuyerId); + private readonly Mock reads = new(); - private readonly static Dictionary expected = new() + private static readonly Dictionary Expected = new() { [CustomStatus.Pending] = 1, [CustomStatus.Accepted] = 2, @@ -26,17 +28,16 @@ public Tests() handler = new(reads.Object); reads.Setup(x => x.CountAsync(ValidBuyerId, ct)) - .ReturnsAsync(expected); + .ReturnsAsync(Expected); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - CountCustomsQuery query = new(ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -49,19 +50,18 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - CountCustomsQuery query = new(ValidBuyerId); // Act - CountCustomsDto counts = await handler.Handle(query, ct); + CountCustomsDto counts = await handler.Handle(request, ct); // Assert Assert.Multiple( - () => Assert.Equal(expected[CustomStatus.Pending], counts.Pending), - () => Assert.Equal(expected[CustomStatus.Accepted], counts.Accepted), - () => Assert.Equal(expected[CustomStatus.Begun], counts.Begun), - () => Assert.Equal(expected[CustomStatus.Finished], counts.Finished), - () => Assert.Equal(expected[CustomStatus.Completed], counts.Completed), - () => Assert.Equal(expected[CustomStatus.Reported], counts.Reported) + () => Assert.Equal(Expected[CustomStatus.Pending], counts.Pending), + () => Assert.Equal(Expected[CustomStatus.Accepted], counts.Accepted), + () => Assert.Equal(Expected[CustomStatus.Begun], counts.Begun), + () => Assert.Equal(Expected[CustomStatus.Finished], counts.Finished), + () => Assert.Equal(Expected[CustomStatus.Completed], counts.Completed), + () => Assert.Equal(Expected[CustomStatus.Reported], counts.Reported) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs index bbc06d97c..60efd30ff 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Customers/GetById/Tests.cs @@ -13,6 +13,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Cust public class Tests : Data.Customs.BaseUnitTests { private readonly CustomerGetCustomByIdHandler handler; + private readonly CustomerGetCustomByIdQuery request = new(ValidId, ValidBuyerId); + private readonly Mock reads = new(); private readonly Mock sender = new(); @@ -32,10 +34,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CustomerGetCustomByIdQuery query = new(ValidId, ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -49,10 +50,9 @@ public async Task Handle_ShouldSendRequests_WhenAccepted() { // Arrange custom.SetCategory(null); - CustomerGetCustomByIdQuery query = new(ValidId, ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -76,10 +76,9 @@ public async Task Handle_ShouldSendRequests_WhenHasCategory() { // Arrange custom.Cancel(); - CustomerGetCustomByIdQuery query = new(ValidId, ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -102,10 +101,9 @@ public async Task Handle_ShouldSendRequests_WhenHasCategory() public async Task Handle_ShouldReturnResult() { // Arrange - CustomerGetCustomByIdQuery query = new(ValidId, ValidBuyerId); // Act - CustomerGetCustomByIdDto custom = await handler.Handle(query, ct); + CustomerGetCustomByIdDto custom = await handler.Handle(request, ct); // Assert Assert.Equal(this.custom.Id, custom.Id); @@ -116,25 +114,23 @@ public async Task Handle_ShouldThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Custom); - CustomerGetCustomByIdQuery query = new(ValidId, ValidBuyerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } [Fact] - public async Task Handle_ShouldThrowException_WhenUnauthorized() + public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange - CustomerGetCustomByIdQuery query = new(ValidId, AccountId.New()); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request with { CallerId = new() }, ct) ); } } diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs index f456bf0ac..e0910d176 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Designers/GetById/Tests.cs @@ -4,7 +4,6 @@ using CustomCADs.Shared.Application.Exceptions; using CustomCADs.Shared.Application.UseCases.Accounts.Queries; using CustomCADs.Shared.Application.UseCases.Categories.Queries; -using CustomCADs.Shared.Domain.TypedIds.Accounts; namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Designers.GetById; @@ -13,6 +12,8 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Desi public class Tests : Data.Customs.BaseUnitTests { private readonly DesignerGetCustomByIdHandler handler; + private readonly DesignerGetCustomByIdQuery request = new(ValidId, ValidDesignerId); + private readonly Mock reads = new(); private readonly Mock sender = new(); @@ -30,10 +31,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DesignerGetCustomByIdQuery query = new(ValidId, ValidDesignerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -47,10 +47,9 @@ public async Task Handle_ShouldSendRequests() { // Arrange custom.SetCategory(null); - DesignerGetCustomByIdQuery query = new(ValidId, ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -73,10 +72,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldSendRequests_WhenHasCategory() { // Arrange - DesignerGetCustomByIdQuery query = new(ValidId, ValidBuyerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request with { CallerId = ValidBuyerId }, ct); // Assert sender.Verify( @@ -92,13 +90,12 @@ public async Task Handle_ShouldSendRequests_WhenHasCategory() public async Task Handle_ShouldReturnResult() { // Arrange - DesignerGetCustomByIdQuery query = new(ValidId, ValidDesignerId); // Act - DesignerGetCustomByIdDto custom = await handler.Handle(query, ct); + DesignerGetCustomByIdDto custom = await handler.Handle(request, ct); // Assert - Assert.Equal(this.custom.Id, custom.Id); + Assert.Equal(ValidId, custom.Id); } [Fact] @@ -106,38 +103,35 @@ public async Task Handle_ShouldThrowException_WhenNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Custom); - DesignerGetCustomByIdQuery query = new(ValidId, ValidDesignerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } [Fact] - public async Task Handle_ShouldThrowException_WhenUnauthorized() + public async Task Handle_ShouldThrowException_WhenUnauthorizedAccess() { // Arrange custom.Accept(ValidDesignerId); - DesignerGetCustomByIdQuery query = new(ValidId, AccountId.New()); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request with { CallerId = new() }, ct) ); } [Fact] - public async Task Handle_ShouldNotThrowException_WhenPending() + public async Task Handle_ShouldNotThrowException_WhenUnauthorizedAccessButPending() { // Arrange - DesignerGetCustomByIdQuery query = new(ValidId, AccountId.New()); // Act Exception? ex = await Record.ExceptionAsync( - () => handler.Handle(query, ct) + () => handler.Handle(request with { CallerId = new() }, ct) ); // Assert diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs index 8df758d9b..d43c01515 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs @@ -16,13 +16,18 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Shar public class Tests : Data.Customs.BaseUnitTests { private readonly GetAllCustomsHandler handler; + private readonly GetAllCustomsQuery request = new(Query.Pagination); + private readonly Mock reads = new(); private readonly Mock sender = new(); - private readonly Custom[] customs = [ + private static readonly Custom[] Customs = [ CreateCustom(id: ValidId), CreateCustom(id: ValidId), ]; + private static readonly CustomQuery Query = new( + Pagination: new(1, Customs.Length) + ); private readonly Dictionary customers = new() { [ValidBuyerId] = CustomerUsername, @@ -35,21 +40,17 @@ public class Tests : Data.Customs.BaseUnitTests { [ValidCategoryId] = "Category123", }; - private readonly CustomQuery query; public Tests() { handler = new(reads.Object, sender.Object); - query = new( - Pagination: new(1, customs.Length) - ); - customs.First().Accept(ValidDesignerId); + Customs.First().Accept(ValidDesignerId); - reads.Setup(x => x.AllAsync(query, false, ct)) + reads.Setup(x => x.AllAsync(Query, false, ct)) .ReturnsAsync(new Result( - customs.Length, - customs + Customs.Length, + Customs )); sender.Setup(x => x.SendQueryAsync( @@ -72,14 +73,13 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAllCustomsQuery query = new(this.query.Pagination); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(this.query, false, ct), + x => x.AllAsync(Query, false, ct), Times.Once() ); } @@ -88,10 +88,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - GetAllCustomsQuery query = new(this.query.Pagination); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -121,14 +120,13 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - GetAllCustomsQuery query = new(this.query.Pagination); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert - int expectedCount = customs.Length, actualCount = result.Count; - CustomId[] expectedIds = [.. customs.Select(x => x.Id)], + int expectedCount = Customs.Length, actualCount = result.Count; + CustomId[] expectedIds = [.. Customs.Select(x => x.Id)], actualIds = [.. result.Items.Select(x => x.Id)]; Assert.Multiple( diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/Tests.cs index 8cfb3dee1..6613290bb 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetPaymentStatuses/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Shar public class Tests : Data.Customs.BaseUnitTests { private readonly GetCustomPaymentStatusesHandler handler = new(); + private readonly GetCustomPaymentStatusesQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetCustomPaymentStatusesQuery query = new(); // Act - PaymentStatus[] sortings = await handler.Handle(query, ct); + PaymentStatus[] sortings = await handler.Handle(request, ct); // Assert Assert.Equal(sortings, Enum.GetValues()); diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/Tests.cs index 9f8841393..efd08628a 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetSortings/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Shar public class Tests : Data.Customs.BaseUnitTests { private readonly GetCustomSortingsHandler handler = new(); + private readonly GetCustomSortingsQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetCustomSortingsQuery query = new(); // Act - CustomSortingType[] sortings = await handler.Handle(query, ct); + CustomSortingType[] sortings = await handler.Handle(request, ct); // Assert Assert.Equal(sortings, Enum.GetValues()); diff --git a/tests/UnitTests/Customs/Data/Customs/BaseUnitTests.cs b/tests/UnitTests/Customs/Data/Customs/BaseUnitTests.cs index 7cbcd85d1..b31268ca9 100644 --- a/tests/UnitTests/Customs/Data/Customs/BaseUnitTests.cs +++ b/tests/UnitTests/Customs/Data/Customs/BaseUnitTests.cs @@ -12,6 +12,9 @@ public class BaseUnitTests { public static readonly CancellationToken ct = CancellationToken.None; + protected static readonly Func ExpectValidationException + = Xunit.Assert.Throws; + public static Custom CreateCustom( string? name = null, string? description = null, diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Accept/Tests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Accept/Tests.cs index a6654846b..c17b4664b 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Accept/Tests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Accept/Tests.cs @@ -6,9 +6,6 @@ namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Accept; public class Tests : Data.Customs.BaseUnitTests { - private static readonly Func expectValidationException - = Assert.Throws; - [Fact] public void Accept_ShouldSucceed_WhenPending() { @@ -25,7 +22,7 @@ public void Accept_ShouldSucceed_WhenPending() [Fact] public void Accept_ShouldFail_WhenAccepted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -37,7 +34,7 @@ public void Accept_ShouldFail_WhenAccepted() [Fact] public void Accept_ShouldFail_WhenBegun() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -50,7 +47,7 @@ public void Accept_ShouldFail_WhenBegun() [Fact] public void Accept_ShouldFail_WhenReported() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -63,7 +60,7 @@ public void Accept_ShouldFail_WhenReported() [Fact] public void Accept_ShouldFail_WhenFinished() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -77,7 +74,7 @@ public void Accept_ShouldFail_WhenFinished() [Fact] public void Accept_ShouldFail_WhenCompleted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -91,7 +88,7 @@ public void Accept_ShouldFail_WhenCompleted() [Fact] public void Accept_ShouldFail_WhenRemoved() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Report(); diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Begin/Tests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Begin/Tests.cs index 0e421f8f1..32eb1c6a7 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Begin/Tests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Begin/Tests.cs @@ -6,9 +6,6 @@ namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Begin; public class Tests : Data.Customs.BaseUnitTests { - private static readonly Func expectValidationException - = Assert.Throws; - [Fact] public void Begin_ShouldSucceed_WhenAccepted() { @@ -26,7 +23,7 @@ public void Begin_ShouldSucceed_WhenAccepted() [Fact] public void Begin_ShouldFail_WhenPending() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); @@ -37,7 +34,7 @@ public void Begin_ShouldFail_WhenPending() [Fact] public void Begin_ShouldFail_WhenBegun() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -50,7 +47,7 @@ public void Begin_ShouldFail_WhenBegun() [Fact] public void Begin_ShouldFail_WhenReported() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -63,7 +60,7 @@ public void Begin_ShouldFail_WhenReported() [Fact] public void Begin_ShouldFail_WhenFinished() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -77,7 +74,7 @@ public void Begin_ShouldFail_WhenFinished() [Fact] public void Begin_ShouldFail_WhenCompleted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -91,7 +88,7 @@ public void Begin_ShouldFail_WhenCompleted() [Fact] public void Begin_ShouldFail_WhenRemoved() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Report(); diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Cancel/Tests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Cancel/Tests.cs index 9ce851a21..1365d439e 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Cancel/Tests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Cancel/Tests.cs @@ -6,9 +6,6 @@ namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Cancel; public class Tests : Data.Customs.BaseUnitTests { - private static readonly Func expectValidationException - = Assert.Throws; - [Fact] public void Cancel_ShouldSucceed_WhenAccepted() { @@ -56,7 +53,7 @@ public void Cancel_ShouldSucceed_WhenReported() [Fact] public void Cancel_ShouldFail_WhenPending() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); @@ -67,7 +64,7 @@ public void Cancel_ShouldFail_WhenPending() [Fact] public void Cancel_ShouldFail_WhenFinished() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -81,7 +78,7 @@ public void Cancel_ShouldFail_WhenFinished() [Fact] public void Cancel_ShouldFail_WhenCompleted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -95,7 +92,7 @@ public void Cancel_ShouldFail_WhenCompleted() [Fact] public void Cancel_ShouldFail_WhenRemoved() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Report(); diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Complete/Tests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Complete/Tests.cs index cbd3e0975..2059ec660 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Complete/Tests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Complete/Tests.cs @@ -6,9 +6,6 @@ namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Complet public class Tests : Data.Customs.BaseUnitTests { - private static readonly Func expectValidationException - = Assert.Throws; - [Fact] public void Complete_ShouldSucceed_WhenFinished() { @@ -31,7 +28,7 @@ public void Complete_ShouldSucceed_WhenFinished() [Fact] public void Complete_ShouldFail_WhenPending() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); @@ -42,7 +39,7 @@ public void Complete_ShouldFail_WhenPending() [Fact] public void Complete_ShouldFail_WhenAccepted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -54,7 +51,7 @@ public void Complete_ShouldFail_WhenAccepted() [Fact] public void Complete_ShouldFail_WhenBegun() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -67,7 +64,7 @@ public void Complete_ShouldFail_WhenBegun() [Fact] public void Complete_ShouldFail_WhenReported() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -80,7 +77,7 @@ public void Complete_ShouldFail_WhenReported() [Fact] public void Complete_ShouldFail_WhenCompleted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -95,7 +92,7 @@ public void Complete_ShouldFail_WhenCompleted() [Fact] public void Complete_ShouldFail_WhenRemoved() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Report(); diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Finish/Tests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Finish/Tests.cs index 639e0079c..04a51c8b7 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Finish/Tests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Finish/Tests.cs @@ -8,9 +8,6 @@ namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Finish; public class Tests : Data.Customs.BaseUnitTests { - private static readonly Func expectValidationException - = Assert.Throws; - [Fact] public void Finish_ShouldSucceed_WhenBegun() { @@ -44,7 +41,7 @@ public void Finish_ShouldFail_WhenInvalidPrice() [Fact] public void Finish_ShouldFail_WhenPending() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); @@ -55,7 +52,7 @@ public void Finish_ShouldFail_WhenPending() [Fact] public void Finish_ShouldFail_WhenAccepted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -67,7 +64,7 @@ public void Finish_ShouldFail_WhenAccepted() [Fact] public void Finish_ShouldFail_WhenReported() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -80,7 +77,7 @@ public void Finish_ShouldFail_WhenReported() [Fact] public void Finish_ShouldFail_WhenFinished() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -94,7 +91,7 @@ public void Finish_ShouldFail_WhenFinished() [Fact] public void Finish_ShouldFail_WhenCompleted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -109,7 +106,7 @@ public void Finish_ShouldFail_WhenCompleted() [Fact] public void Finish_ShouldFail_WhenRemoved() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Report(); diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Remove/Tests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Remove/Tests.cs index 227f6a574..71375da37 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Remove/Tests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Remove/Tests.cs @@ -6,9 +6,6 @@ namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Remove; public class Tests : Data.Customs.BaseUnitTests { - private static readonly Func expectValidationException - = Assert.Throws; - [Fact] public void Remove_ShouldSucceed_WhenReported() { @@ -23,7 +20,7 @@ public void Remove_ShouldSucceed_WhenReported() [Fact] public void Remove_ShouldFail_WhenPending() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); @@ -34,7 +31,7 @@ public void Remove_ShouldFail_WhenPending() [Fact] public void Remove_ShouldFail_WhenAccepted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -46,7 +43,7 @@ public void Remove_ShouldFail_WhenAccepted() [Fact] public void Remove_ShouldFail_WhenBegun() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -59,7 +56,7 @@ public void Remove_ShouldFail_WhenBegun() [Fact] public void Remove_ShouldFail_WhenFinished() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -73,7 +70,7 @@ public void Remove_ShouldFail_WhenFinished() [Fact] public void Remove_ShouldFail_WhenCompleted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); diff --git a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Report/Tests.cs b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Report/Tests.cs index 88433fa9f..43be530d1 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Report/Tests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Behaviors/Statuses/Report/Tests.cs @@ -6,9 +6,6 @@ namespace CustomCADs.UnitTests.Customs.Domain.Customs.Behaviors.Statuses.Report; public class Tests : Data.Customs.BaseUnitTests { - private static readonly Func expectValidationException - = Assert.Throws; - [Fact] public void Report_ShouldSucceed_WhenPending() { @@ -51,7 +48,7 @@ public void Report_ShouldSucceed_WhenBegun() [Fact] public void Report_ShouldFail_WhenReported() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -64,7 +61,7 @@ public void Report_ShouldFail_WhenReported() [Fact] public void Report_ShouldFail_WhenFinished() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -78,7 +75,7 @@ public void Report_ShouldFail_WhenFinished() [Fact] public void Report_ShouldFail_WhenCompleted() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Accept(ValidDesignerId); @@ -92,7 +89,7 @@ public void Report_ShouldFail_WhenCompleted() [Fact] public void Report_ShouldFail_WhenRemoved() { - expectValidationException(() => + ExpectValidationException(() => { Custom custom = CreateCustom(); custom.Report(); diff --git a/tests/UnitTests/Customs/Domain/Customs/Create/WithId/Tests.cs b/tests/UnitTests/Customs/Domain/Customs/Create/WithId/Tests.cs index 82620f126..5e14fe11f 100644 --- a/tests/UnitTests/Customs/Domain/Customs/Create/WithId/Tests.cs +++ b/tests/UnitTests/Customs/Domain/Customs/Create/WithId/Tests.cs @@ -32,9 +32,9 @@ public void Create_ShouldPopulateProperties(string name, string description, boo [ClassData(typeof(InvalidData))] public void Create_ShouldThrowException_WhenCustomIsInvalid(string name, string description, bool delivery) { - Assert.Throws>((Action)(() => + Assert.Throws>(() => { - Data.Customs.BaseUnitTests.CreateCustom(name, description, (bool?)delivery, ValidBuyerId); - })); + CreateCustom(name, description, (bool?)delivery, ValidBuyerId); + }); } } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs index aae99f6ba..186f15e8a 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Commands/Internal/Cancel/Tests.cs @@ -12,6 +12,8 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Commands.Internal. public class Tests : Data.Shipments.BaseUnitTests { private readonly CancelShipmentHandler handler; + private readonly CancelShipmentCommand request = new(ValidId, Comment); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock delivery = new(); @@ -30,10 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CancelShipmentCommand command = new(ValidId, Comment); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CancelShipmentCommand command = new(ValidId, Comment); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -62,10 +62,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldCallDelivery() { // Arrange - CancelShipmentCommand command = new(ValidId, Comment); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert delivery.Verify( @@ -82,12 +81,10 @@ public async Task Handle_ShouldThrowException_WhenShipmentStatusInvalid() CreateShipment().Activate(ValidReferenceId).Deliver() ); - CancelShipmentCommand command = new(ValidId, Comment); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -96,12 +93,11 @@ public async Task Handle_ShouldThrowException_WhenShipmentNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Shipment); - CancelShipmentCommand command = new(ValidId, Comment); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs index 5475e4b8e..74d82f925 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Commands/Shared/Create/Tests.cs @@ -13,6 +13,14 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Commands.Shared.Cr public class Tests : Data.Shipments.BaseUnitTests { private readonly CreateShipmentHandler handler; + private readonly CreateShipmentCommand request = new( + Service: ValidService, + Info: new(MaxValidCount, MaxValidWeight, ValidRecipient), + Address: new(ValidCountry, ValidCity, ValidStreet), + Contact: new(ValidPhone, ValidEmail), + BuyerId: ValidBuyerId + ); + private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -40,16 +48,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateShipmentCommand command = new( - Service: ValidService, - Info: new(MaxValidCount, MaxValidWeight, ValidRecipient), - Address: new(ValidCountry, ValidCity, ValidStreet), - Contact: new(ValidPhone, ValidEmail), - BuyerId: ValidBuyerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -69,16 +70,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - CreateShipmentCommand command = new( - Service: ValidService, - Info: new(MaxValidCount, MaxValidWeight, ValidRecipient), - Address: new(ValidCountry, ValidCity, ValidStreet), - Contact: new(ValidPhone, ValidEmail), - BuyerId: ValidBuyerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -94,16 +88,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - CreateShipmentCommand command = new( - Service: ValidService, - Info: new(MaxValidCount, MaxValidWeight, ValidRecipient), - Address: new(ValidCountry, ValidCity, ValidStreet), - Contact: new(ValidPhone, ValidEmail), - BuyerId: ValidBuyerId - ); // Act - ShipmentId id = await handler.Handle(command, ct); + ShipmentId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); @@ -116,18 +103,10 @@ public async Task Handle_ShouldThrowException_WhenDeliveryDetailsInvalid() delivery.Setup(x => x.ValidateAsync(ValidCountry, ValidCity, ValidStreet, ValidPhone, ct)) .ReturnsAsync(false); - CreateShipmentCommand command = new( - Service: ValidService, - Info: new(MaxValidCount, MaxValidWeight, ValidRecipient), - Address: new(ValidCountry, ValidCity, ValidStreet), - Contact: new(ValidPhone, ValidEmail), - BuyerId: ValidBuyerId - ); - // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -140,18 +119,10 @@ public async Task Handle_ShouldThrowException_WhenDesignerNotFound() ct )).ReturnsAsync(false); - CreateShipmentCommand command = new( - Service: ValidService, - Info: new(MaxValidCount, MaxValidWeight, ValidRecipient), - Address: new(ValidCountry, ValidCity, ValidStreet), - Contact: new(ValidPhone, ValidEmail), - BuyerId: ValidBuyerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/Tests.cs index b2bc4eeb1..1023532e1 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetAll/Tests.cs @@ -8,40 +8,37 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Internal.G public class Tests : Data.Shipments.BaseUnitTests { private readonly GetAllShipmentsHandler handler; + private readonly GetAllShipmentsQuery request = new(new(), null, null); + private readonly Mock reads = new(); - private static readonly Shipment[] shipments = [ + private static readonly Shipment[] Shipments = [ CreateShipment(), CreateShipment(), CreateShipment(), CreateShipment(), ]; - private readonly ShipmentQuery shipmentQuery = new(new(), null, null); + private static readonly ShipmentQuery Query = new(new(), null, null); public Tests() { handler = new(reads.Object); - reads.Setup(x => x.AllAsync(shipmentQuery, false, ct)) - .ReturnsAsync(new Result(shipments.Length, shipments)); + reads.Setup(x => x.AllAsync(Query, false, ct)) + .ReturnsAsync(new Result(Shipments.Length, Shipments)); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAllShipmentsQuery query = new( - Pagination: new(), - CallerId: null, - Sorting: null - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(shipmentQuery, false, ct), + x => x.AllAsync(Query, false, ct), Times.Once() ); } @@ -50,16 +47,11 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetAllShipmentsQuery query = new( - Pagination: new(), - CallerId: null, - Sorting: null - ); // Act - Result result = await handler.Handle(query, ct); + Result result = await handler.Handle(request, ct); // Assert - Assert.Equal(result.Items.Select(r => r.Address), shipments.Select(r => r.Address)); + Assert.Equal(result.Items.Select(r => r.Address), Shipments.Select(r => r.Address)); } } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/Tests.cs index ec753e42f..cd95d6782 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetSortings/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Internal.G public class Tests : Data.Shipments.BaseUnitTests { private readonly GetShipmentSortingsHandler handler = new(); + private readonly GetShipmentSortingsQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetShipmentSortingsQuery query = new(); // Act - ShipmentSortingType[] sortings = await handler.Handle(query, ct); + ShipmentSortingType[] sortings = await handler.Handle(request, ct); // Assert Assert.Equal(sortings, Enum.GetValues()); diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs index f1139a240..87f72b1a3 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetTrack/Tests.cs @@ -11,10 +11,12 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Internal.G public class Tests : Data.Shipments.BaseUnitTests { private readonly GetShipmentTracksHandler handler; + private readonly GetShipmentTracksQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock delivery = new(); - private static readonly ShipmentTrackDto[] statuses = CreateShipmentTracksDtos(); + private static readonly ShipmentTrackDto[] Statuses = CreateShipmentTracksDtos(); public Tests() { @@ -23,17 +25,16 @@ public Tests() reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(CreateShipment().Activate(ValidReferenceId)); - delivery.Setup(x => x.TrackAsync(ValidReferenceId, ct)).ReturnsAsync(statuses); + delivery.Setup(x => x.TrackAsync(ValidReferenceId, ct)).ReturnsAsync(Statuses); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - GetShipmentTracksQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldCallDelivery() { // Arrange - GetShipmentTracksQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert delivery.Verify( @@ -62,13 +62,12 @@ public async Task Handle_ShouldCallDelivery() public async Task Handle_ShouldReturnResult() { // Arrange - GetShipmentTracksQuery query = new(ValidId); // Act - Dictionary tracks = await handler.Handle(query, ct); + Dictionary tracks = await handler.Handle(request, ct); // Assert - Assert.Equal(tracks, statuses.ToDictionary(x => x.DateTime, x => new GetShipmentTracksDto(x.Message, x.Place))); + Assert.Equal(tracks, Statuses.ToDictionary(x => x.DateTime, x => new GetShipmentTracksDto(x.Message, x.Place))); } [Fact] @@ -77,12 +76,11 @@ public async Task Handle_ShouldThrowException_WhenShipmentStatusInvalid() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(CreateShipment()); - GetShipmentTracksQuery query = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } @@ -91,12 +89,11 @@ public async Task Handle_ShouldThrowException_WhenShipmentNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Shipment); - GetShipmentTracksQuery query = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs index cd9b72e75..4b9941191 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Internal/GetWaybill/Tests.cs @@ -12,10 +12,12 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Internal.G public class Tests : Data.Shipments.BaseUnitTests { private readonly GetShipmentWaybillHandler handler; + private readonly GetShipmentWaybillQuery request = new(ValidId, HeadDesignerAccountId); + private readonly Mock reads = new(); private readonly Mock delivery = new(); - private static readonly byte[] bytes = [1, 2, 3, 4, 5, 6]; + private static readonly byte[] Bytes = [1, 2, 3, 4, 5, 6]; public Tests() { @@ -24,17 +26,16 @@ public Tests() reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(CreateShipment().Activate(ValidReferenceId)); - delivery.Setup(x => x.PrintAsync(ValidReferenceId, ct)).ReturnsAsync(bytes); + delivery.Setup(x => x.PrintAsync(ValidReferenceId, ct)).ReturnsAsync(Bytes); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - GetShipmentWaybillQuery query = new(ValidId, HeadDesignerAccountId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -47,10 +48,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldCallDelivery() { // Arrange - GetShipmentWaybillQuery query = new(ValidId, HeadDesignerAccountId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert delivery.Verify( @@ -63,25 +63,23 @@ public async Task Handle_ShouldCallDelivery() public async Task Handle_ShouldReturnResult() { // Arrange - GetShipmentWaybillQuery query = new(ValidId, HeadDesignerAccountId); // Act - byte[] result = await handler.Handle(query, ct); + byte[] result = await handler.Handle(request, ct); // Assert - Assert.Equal(result, bytes); + Assert.Equal(result, Bytes); } [Fact] public async Task Handle_ShouldThrowException_WhenCallerNotHeadDesigner() { // Arrange - GetShipmentWaybillQuery query = new(ValidId, ValidBuyerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request with { CallerId = ValidBuyerId }, ct) ); } @@ -90,12 +88,11 @@ public async Task Handle_ShouldThrowException_WhenShipmentStatusInvalid() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(CreateShipment()); - GetShipmentWaybillQuery query = new(ValidId, HeadDesignerAccountId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } @@ -104,12 +101,11 @@ public async Task Handle_ShouldThrowException_WhenShipmentNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)).ReturnsAsync(null as Shipment); - GetShipmentWaybillQuery query = new(ValidId, ValidBuyerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs index 5baac12b4..c81c35bd6 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Tests.cs @@ -9,13 +9,15 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Shared.Cal public class Tests : Data.Shipments.BaseUnitTests { private readonly CalculateShipmentHandler handler; + private readonly CalculateShipmentQuery request = new(Weights, Address); + private readonly Mock delivery = new(); - private static readonly CalculationDto[] calculations = [ + private static readonly CalculationDto[] Calculations = [ new(string.Empty, new(default, default, default, string.Empty), default, default) ]; - private static readonly double[] weights = [0, 1, 2, 3, 4, 5, 6]; - private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); + private static readonly double[] Weights = [0, 1, 2, 3, 4, 5, 6]; + private static readonly AddressDto Address = new("Bulgaria", "Burgas", "Slivnitsa"); public Tests() { @@ -23,32 +25,31 @@ public Tests() delivery.Setup(x => x.CalculateAsync( It.Is(x => - x.Country == address.Country - && x.City == address.City - && x.Street == address.Street - && x.Weights.Length == weights.Length + x.Country == Address.Country + && x.City == Address.City + && x.Street == Address.Street + && x.Weights.Length == Weights.Length ), ct - )).ReturnsAsync(calculations); + )).ReturnsAsync(Calculations); } [Fact] public async Task Handle_ShouldCallDelivery() { // Arrange - CalculateShipmentQuery query = new(weights, address); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert delivery.Verify( x => x.CalculateAsync( It.Is(x => - x.Country == address.Country - && x.City == address.City - && x.Street == address.Street - && x.Weights.Length == weights.Length + x.Country == Address.Country + && x.City == Address.City + && x.Street == Address.Street + && x.Weights.Length == Weights.Length ), ct ), @@ -60,12 +61,11 @@ public async Task Handle_ShouldCallDelivery() public async Task Handle_ShouldReturnResult() { // Arrange - CalculateShipmentQuery query = new(weights, address); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert - Assert.Equal(calculations.Length, result.Length); + Assert.Equal(Calculations.Length, result.Length); } } diff --git a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Validator.cs b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Validator.cs index 5990d6355..09fc4652c 100644 --- a/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Validator.cs +++ b/tests/UnitTests/Delivery/Application/Shipments/Queries/Shared/Calculate/Validator.cs @@ -8,18 +8,18 @@ namespace CustomCADs.UnitTests.Delivery.Application.Shipments.Queries.Shared.Cal public class Validator : Data.Shipments.BaseUnitTests { private readonly CalculateShipmentValidator validator = new(); + private readonly CalculateShipmentQuery request = new(Weights, Address); - private static readonly double[] weights = [0, 1, 2, 3, 4, 5, 6]; - private static readonly AddressDto address = new("Bulgaria", "Burgas", "Slivnitsa"); + private static readonly double[] Weights = [0, 1, 2, 3, 4, 5, 6]; + private static readonly AddressDto Address = new("Bulgaria", "Burgas", "Slivnitsa"); [Fact] public async Task Validate_ShouldBeValid_WhenAddressIsValid() { // Arrange - CalculateShipmentQuery query = new(weights, address); // Act - var result = await validator.TestValidateAsync(query); + var result = await validator.TestValidateAsync(request); // Assert Assert.True(result.IsValid); @@ -30,10 +30,9 @@ public async Task Validate_ShouldBeValid_WhenAddressIsValid() public async Task Validate_ShouldBeInvalid_WhenAddressIsInvalid(string country, string city, string street) { // Arrange - CalculateShipmentQuery query = new(weights, Address: new(country, city, street)); // Act - var result = await validator.TestValidateAsync(query); + var result = await validator.TestValidateAsync(request with { Address = new(country, city, street) }); // Assert Assert.False(result.IsValid); diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs index 8d9c30a57..6bc0438d1 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Create/Tests.cs @@ -8,6 +8,8 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Internal.Create; public class Tests : Data.Cads.BaseUnitTests { private readonly CreateCadHandler handler; + private readonly CreateCadCommand request = new(ValidKey, ValidContentType, ValidVolume, ValidOwnerId); + private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -26,10 +28,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateCadCommand command = new(ValidKey, ValidContentType, ValidVolume, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -49,10 +50,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - CreateCadCommand command = new(ValidKey, ValidContentType, ValidVolume, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -68,10 +68,9 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldReturnResult() { // Arrange - CreateCadCommand command = new(ValidKey, ValidContentType, ValidVolume, ValidOwnerId); // Act - CadId id = await handler.Handle(command, ct); + CadId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs index 18f9a2ffc..f6ad9f731 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/Edit/Tests.cs @@ -10,6 +10,8 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Internal.Edit; public class Tests : Data.Cads.BaseUnitTests { private readonly EditCadHandler handler; + private readonly EditCadCommand request = new(ValidId, ValidContentType, ValidVolume, ValidOwnerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -28,10 +30,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - EditCadCommand command = new(ValidId, ValidContentType, ValidVolume, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -44,10 +45,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - EditCadCommand command = new(ValidId, ValidContentType, ValidVolume, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -60,10 +60,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - EditCadCommand command = new(ValidId, ValidContentType, ValidVolume, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -76,10 +75,9 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldModifyCad() { // Arrange - EditCadCommand command = new(ValidId, ValidContentType, ValidVolume, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -94,12 +92,11 @@ public async Task Handle_ShouldThrowException_WhenCadNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Cad); - EditCadCommand command = new(ValidId, ValidContentType, ValidVolume, ValidOwnerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs index 2d6da6377..a329db696 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Internal/SetCoords/Tests.cs @@ -11,12 +11,19 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Internal.SetCoord public class Tests : Data.Cads.BaseUnitTests { private readonly SetCadCoordsHandler handler; + private readonly SetCadCoordsCommand request = new( + Id: ValidId, + CamCoordinates: CamCoords, + PanCoordinates: PanCoords, + CallerId: ValidOwnerId + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); - private static readonly CoordinatesDto camCoords = new(MinValidCoord, MinValidCoord, MinValidCoord); - private static readonly CoordinatesDto panCoords = new(MaxValidCoord, MaxValidCoord, MaxValidCoord); + private static readonly CoordinatesDto CamCoords = new(MinValidCoord, MinValidCoord, MinValidCoord); + private static readonly CoordinatesDto PanCoords = new(MaxValidCoord, MaxValidCoord, MaxValidCoord); private readonly Cad cad = CreateCad(); public Tests() @@ -30,15 +37,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - SetCadCoordsCommand command = new( - Id: ValidId, - CamCoordinates: camCoords, - PanCoordinates: panCoords, - CallerId: ValidOwnerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -51,15 +52,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - SetCadCoordsCommand command = new( - Id: ValidId, - CamCoordinates: camCoords, - PanCoordinates: panCoords, - CallerId: ValidOwnerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -72,15 +67,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - SetCadCoordsCommand command = new( - Id: ValidId, - CamCoordinates: camCoords, - PanCoordinates: panCoords, - CallerId: ValidOwnerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -93,24 +82,18 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldModifyCad() { // Arrange - SetCadCoordsCommand command = new( - Id: ValidId, - CamCoordinates: camCoords, - PanCoordinates: panCoords, - CallerId: ValidOwnerId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( - () => Assert.Equal(camCoords.X, cad.CamCoordinates.X), - () => Assert.Equal(camCoords.Y, cad.CamCoordinates.Y), - () => Assert.Equal(camCoords.Z, cad.CamCoordinates.Z), - () => Assert.Equal(panCoords.X, cad.PanCoordinates.X), - () => Assert.Equal(panCoords.Y, cad.PanCoordinates.Y), - () => Assert.Equal(panCoords.Z, cad.PanCoordinates.Z) + () => Assert.Equal(CamCoords.X, cad.CamCoordinates.X), + () => Assert.Equal(CamCoords.Y, cad.CamCoordinates.Y), + () => Assert.Equal(CamCoords.Z, cad.CamCoordinates.Z), + () => Assert.Equal(PanCoords.X, cad.PanCoordinates.X), + () => Assert.Equal(PanCoords.Y, cad.PanCoordinates.Y), + () => Assert.Equal(PanCoords.Z, cad.PanCoordinates.Z) ); } @@ -121,17 +104,10 @@ public async Task Handle_ShouldThrowException_WhenCadNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Cad); - SetCadCoordsCommand command = new( - Id: ValidId, - CamCoordinates: camCoords, - PanCoordinates: panCoords, - CallerId: ValidOwnerId - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs b/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs index d3dc23dbd..d76e14787 100644 --- a/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Commands/Shared/BatchDuplicateById/Tests.cs @@ -11,41 +11,39 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Commands.Shared.BatchDupli public class Tests : Data.Cads.BaseUnitTests { private readonly BatchDuplicateCadByIdHandler handler; + private readonly BatchDuplicateCadByIdCommand request = new(Ids, ValidOwnerId); + private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); - private readonly Cad[] cads = [ + private static readonly Cad[] Cads = [ CreateCad(), ]; - private readonly CadId[] Ids = [ValidId]; - private readonly CadQuery query; - private readonly Result result; + private static readonly CadId[] Ids = [ValidId]; + private static readonly CadQuery Query = new(new(1, Ids.Length), null, Ids); + private static readonly Result Result = new(Cads.Length, Cads); public Tests() { handler = new(reads.Object, writes.Object, uow.Object, cache.Object); - query = new(new(1, Ids.Length), null, Ids); - result = new Result(cads.Length, cads); - - reads.Setup(x => x.AllAsync(query, false, ct)) - .ReturnsAsync(result); + reads.Setup(x => x.AllAsync(Query, false, ct)) + .ReturnsAsync(Result); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - BatchDuplicateCadByIdCommand command = new(Ids, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(query, false, ct), + x => x.AllAsync(Query, false, ct), Times.Once() ); } @@ -54,14 +52,13 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - BatchDuplicateCadByIdCommand command = new(Ids, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( - x => x.AddRangeAsync(It.Is>(x => x.Count == result.Count), ct), + x => x.AddRangeAsync(It.Is>(x => x.Count == Result.Count), ct), Times.Once() ); uow.Verify( @@ -74,18 +71,17 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - BatchDuplicateCadByIdCommand command = new(Ids, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( x => x.UpdateAsync( CadId.New(Guid.Empty), - It.Is(x => cads.Any(c => x.Key == c.Key)) + It.Is(x => Cads.Any(c => x.Key == c.Key)) ), - Times.Exactly(cads.Length) + Times.Exactly(Cads.Length) ); } @@ -93,12 +89,11 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldReturnResult() { // Arrange - BatchDuplicateCadByIdCommand command = new(Ids, ValidOwnerId); // Act - var result = await handler.Handle(command, ct); + var result = await handler.Handle(request, ct); // Assert - Assert.Equal(cads.Select(x => x.Id), result.Select(x => x.Key)); + Assert.Equal(Cads.Select(x => x.Id), result.Select(x => x.Key)); } } diff --git a/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs b/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs index f64a13ec9..80265baa7 100644 --- a/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Events/Application/Tests.cs @@ -12,13 +12,15 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Events.Application; public class Tests : Data.Cads.BaseUnitTests { private readonly ProductDeletedHandler handler; + private readonly ProductDeletedApplicationEvent request = new(default, default, ValidId); + private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock storage = new(); private readonly Mock> cache = new(); - private static readonly Cad cad = CreateCad(); + private readonly Cad cad = CreateCad(); public Tests() { @@ -30,14 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ProductDeletedApplicationEvent @event = new( - Id: default, - CadId: ValidId, - ImageId: default - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -50,14 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductDeletedApplicationEvent @event = new( - Id: default, - CadId: ValidId, - ImageId: default - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert writes.Verify( @@ -74,14 +66,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - ProductDeletedApplicationEvent @event = new( - Id: default, - CadId: ValidId, - ImageId: default - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert cache.Verify( @@ -94,18 +81,13 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldCallStorage() { // Arrange - ProductDeletedApplicationEvent @event = new( - Id: default, - CadId: ValidId, - ImageId: default - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert storage.Verify( - x => x.DeleteFileAsync(cad.Key, ct), + x => x.DeleteFileAsync(ValidKey, ct), Times.Once() ); } @@ -117,16 +99,10 @@ public async Task Handle_ShouldThrowException_WhenCadNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Cad); - ProductDeletedApplicationEvent @event = new( - Id: default, - CadId: ValidId, - ImageId: default - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.HandleAsync(@event) + () => handler.HandleAsync(request) ); } } diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs index 960c6aa2e..1a3274749 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Get/Tests.cs @@ -10,11 +10,13 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Internal.Presigned public class Tests : Data.Cads.BaseUnitTests { private readonly GetCadPresignedUrlGetHandler handler; + private readonly GetCadPresignedUrlGetQuery request = new(ValidId, Type, ValidOwnerId); + private readonly Mock reads = new(); private readonly Mock storage = new(); private readonly Mock> cache = new(); - private static readonly Cad cad = CreateCad(); + private readonly Cad cad = CreateCad(); private const FileContextType Type = FileContextType.Product; private const string PresignedUrl = "PresignedUrl"; @@ -35,10 +37,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - GetCadPresignedUrlGetQuery query = new(ValidId, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -51,10 +52,9 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldCallStorage() { // Arrange - GetCadPresignedUrlGetQuery query = new(ValidId, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert storage.Verify( @@ -67,10 +67,9 @@ public async Task Handle_ShouldCallStorage() public async Task Handle_ShouldReturnResult() { // Arrange - GetCadPresignedUrlGetQuery query = new(ValidId, Type, ValidOwnerId); // Act - var (Url, ContentType) = await handler.Handle(query, ct); + var (Url, ContentType) = await handler.Handle(request, ct); // Assert Assert.Multiple( diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs index 35420d6de..431f0ff0c 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Post/Tests.cs @@ -10,33 +10,36 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Internal.Presigned public class Tests : Data.Cads.BaseUnitTests { private readonly GetCadPresignedUrlPostHandler handler; + private readonly GetCadPresignedUrlPostQuery request = new(Name, Upload.Request, Type, ValidOwnerId); + private readonly Mock storage = new(); public const string Name = "CustomCAD"; private const FileContextType Type = FileContextType.Product; - public static readonly UploadFileRequest req = new("content-type", "file-name"); - public static readonly UploadFileResponse res = new("generated-key", "presigned-url"); + public static readonly (UploadFileRequest Request, UploadFileResponse Response) Upload = ( + new("content-type", "file-name"), + new("generated-key", "presigned-url") + ); public Tests() { handler = new(storage.Object, policies: [new PolicyMock()]); - storage.Setup(x => x.GetPresignedPostUrlAsync(Name, req)) - .ReturnsAsync(res); + storage.Setup(x => x.GetPresignedPostUrlAsync(Name, Upload.Request)) + .ReturnsAsync(Upload.Response); } [Fact] public async Task Handle_ShouldCallStorage() { // Arrange - GetCadPresignedUrlPostQuery query = new(Name, req, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert storage.Verify( - x => x.GetPresignedPostUrlAsync(Name, req), + x => x.GetPresignedPostUrlAsync(Name, Upload.Request), Times.Once() ); } @@ -45,12 +48,11 @@ public async Task Handle_ShouldCallStorage() public async Task Handle_ShouldReturnResult() { // Arrange - GetCadPresignedUrlPostQuery query = new(Name, req, Type, ValidOwnerId); // Act - UploadFileResponse result = await handler.Handle(query, ct); + UploadFileResponse result = await handler.Handle(request, ct); // Assert - Assert.Equal(res, result); + Assert.Equal(Upload.Response, result); } } diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs index b09047fd5..359a17021 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Internal/PresignedUrls/Put/Tests.cs @@ -11,14 +11,15 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Internal.Presigned public class Tests : Data.Cads.BaseUnitTests { private readonly GetCadPresignedUrlPutHandler handler; + private readonly GetCadPresignedUrlPutQuery request = new(ValidId, UploadRequest, Type, ValidOwnerId); + private readonly Mock reads = new(); private readonly Mock storage = new(); private readonly Mock> cache = new(); private const string PresignedUrl = "presigned-url"; private const FileContextType Type = FileContextType.Product; - private static readonly Cad cad = CreateCad(); - private static readonly UploadFileRequest req = new(ValidContentType, "Batman.glb"); + private static readonly UploadFileRequest UploadRequest = new(ValidContentType, "Batman.glb"); public Tests() { @@ -29,17 +30,16 @@ public Tests() It.IsAny>>() )).ReturnsAsync(CreateCad()); - storage.Setup(x => x.GetPresignedPutUrlAsync(cad.Key, req)).ReturnsAsync(PresignedUrl); + storage.Setup(x => x.GetPresignedPutUrlAsync(ValidKey, UploadRequest)).ReturnsAsync(PresignedUrl); } [Fact] public async Task Handle_ShouldReadCache() { // Arrange - GetCadPresignedUrlPutQuery query = new(ValidId, req, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -52,14 +52,13 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldCallStorage() { // Arrange - GetCadPresignedUrlPutQuery query = new(ValidId, req, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert storage.Verify( - x => x.GetPresignedPutUrlAsync(cad.Key, req), + x => x.GetPresignedPutUrlAsync(ValidKey, UploadRequest), Times.Once() ); } @@ -68,10 +67,9 @@ public async Task Handle_ShouldCallStorage() public async Task Handle_ShouldReturnResult() { // Arrange - GetCadPresignedUrlPutQuery query = new(ValidId, req, Type, ValidOwnerId); // Act - string url = await handler.Handle(query, ct); + string url = await handler.Handle(request, ct); // Assert Assert.Equal(PresignedUrl, url); diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs index cc8ae01ad..c62028569 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Shared/Exists/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Shared.Exists; public class Tests : Data.Cads.BaseUnitTests { private readonly CadExistsByIdHandler handler; + private readonly CadExistsByIdQuery request = new(ValidId); + private readonly Mock reads = new(); public Tests() @@ -21,10 +23,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CadExistsByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -40,10 +41,9 @@ public async Task Handle_ShouldReturnResult(bool exists) { // Arrange reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)).ReturnsAsync(exists); - CadExistsByIdQuery query = new(ValidId); // Act - bool result = await handler.Handle(query, ct); + bool result = await handler.Handle(request, ct); // Assert Assert.Equal(exists, result); diff --git a/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs b/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs index e16d6c84a..2ddc5a3fe 100644 --- a/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs +++ b/tests/UnitTests/Files/Application/Cads/Queries/Shared/IsPrintable/Tests.cs @@ -10,6 +10,8 @@ namespace CustomCADs.UnitTests.Files.Application.Cads.Queries.Shared.IsPrintable public class Tests : Data.Cads.BaseUnitTests { private readonly IsCadPrintableByIdHandler handler; + private readonly IsCadPrintableByIdQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock> cache = new(); @@ -28,10 +30,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - IsCadPrintableByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -53,10 +54,9 @@ public async Task Handle_ShouldReturnResult(bool exists) { Cad.SetContentType(ApplicationConstants.Cads.PrintableContentTypes.First()); } - IsCadPrintableByIdQuery query = new(ValidId); // Act - bool result = await handler.Handle(query, ct); + bool result = await handler.Handle(request, ct); // Assert Assert.Equal(exists, result); diff --git a/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs index 4e6932cdf..16e12e9d4 100644 --- a/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Commands/Internal/Create/Tests.cs @@ -8,6 +8,8 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Commands.Internal.Create public class Tests : Data.Images.BaseUnitTests { private readonly CreateImageHandler handler; + private readonly CreateImageCommand request = new(ValidKey, ValidContentType, ValidOwnerId); + private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -26,10 +28,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateImageCommand command = new(ValidKey, ValidContentType, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -49,10 +50,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - CreateImageCommand command = new(ValidKey, ValidContentType, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -68,10 +68,9 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldReturnResult() { // Arrange - CreateImageCommand command = new(ValidKey, ValidContentType, ValidOwnerId); // Act - ImageId id = await handler.Handle(command, ct); + ImageId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); diff --git a/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs index 4cf5571a4..d9d618882 100644 --- a/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Commands/Internal/Edit/Tests.cs @@ -10,6 +10,8 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Commands.Internal.Edit; public class Tests : Data.Images.BaseUnitTests { private readonly EditImageHandler handler; + private readonly EditImageCommand request = new(ValidId, ValidContentType, ValidOwnerId); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -28,10 +30,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - EditImageCommand command = new(ValidId, ValidContentType, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -44,10 +45,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - EditImageCommand command = new(ValidId, ValidContentType, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -60,10 +60,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - EditImageCommand command = new(ValidId, ValidContentType, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -76,10 +75,9 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldModifyImage() { // Arrange - EditImageCommand command = new(ValidId, ValidContentType, ValidOwnerId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert Assert.Multiple( @@ -94,12 +92,11 @@ public async Task Handle_ShouldThrowException_WhenImageNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Image); - EditImageCommand command = new(ValidId, ValidContentType, ValidOwnerId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs b/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs index d0d328a98..638895bcc 100644 --- a/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Events/Application/Tests.cs @@ -12,13 +12,15 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Events.Application; public class Tests : Data.Images.BaseUnitTests { private readonly ProductDeletedHandler handler; + private readonly ProductDeletedApplicationEvent request = new(default, ValidId, default); + private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock storage = new(); private readonly Mock> cache = new(); - private static readonly Image image = CreateImage(); + private readonly Image image = CreateImage(); public Tests() { @@ -30,14 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ProductDeletedApplicationEvent ie = new( - Id: default, - ImageId: ValidId, - CadId: default - ); // Act - await handler.HandleAsync(ie); + await handler.HandleAsync(request); // Assert reads.Verify( @@ -50,14 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ProductDeletedApplicationEvent ie = new( - Id: default, - ImageId: ValidId, - CadId: default - ); // Act - await handler.HandleAsync(ie); + await handler.HandleAsync(request); // Assert writes.Verify( @@ -74,14 +66,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldWriteToCache() { // Arrange - ProductDeletedApplicationEvent ie = new( - Id: default, - ImageId: ValidId, - CadId: default - ); // Act - await handler.HandleAsync(ie); + await handler.HandleAsync(request); // Assert cache.Verify( @@ -94,14 +81,9 @@ public async Task Handle_ShouldWriteToCache() public async Task Handle_ShouldCallStorage() { // Arrange - ProductDeletedApplicationEvent ie = new( - Id: default, - ImageId: ValidId, - CadId: default - ); // Act - await handler.HandleAsync(ie); + await handler.HandleAsync(request); // Assert storage.Verify( @@ -117,16 +99,10 @@ public async Task Handle_ShouldThrowException_WhenImageNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)) .ReturnsAsync(null as Image); - ProductDeletedApplicationEvent ie = new( - Id: default, - ImageId: ValidId, - CadId: default - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.HandleAsync(ie) + () => handler.HandleAsync(request) ); } } diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs index 5c6151338..687955b05 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Get/Tests.cs @@ -10,11 +10,13 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.Presign public class Tests : Data.Images.BaseUnitTests { private readonly GetImagePresignedUrlGetHandler handler; + private readonly GetImagePresignedUrlGetQuery request = new(ValidId, Type, ValidOwnerId); + private readonly Mock reads = new(); private readonly Mock storage = new(); private readonly Mock> cache = new(); - private static readonly Image image = CreateImage(); + private readonly Image image = CreateImage(); private const FileContextType Type = FileContextType.Product; private const string PresignedUrl = "PresignedUrl"; @@ -35,10 +37,9 @@ public Tests() public async Task Handle_ShouldReadCache() { // Arrange - GetImagePresignedUrlGetQuery query = new(ValidId, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -51,10 +52,9 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldCallStorage() { // Arrange - GetImagePresignedUrlGetQuery query = new(ValidId, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert storage.Verify( @@ -67,10 +67,9 @@ public async Task Handle_ShouldCallStorage() public async Task Handle_ShouldReturnResult() { // Arrange - GetImagePresignedUrlGetQuery query = new(ValidId, Type, ValidOwnerId); // Act - var (Url, ContentType) = await handler.Handle(query, ct); + var (Url, ContentType) = await handler.Handle(request, ct); // Assert Assert.Multiple( diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs index 33068329d..e3fe9a471 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Post/Tests.cs @@ -2,7 +2,6 @@ using CustomCADs.Modules.Files.Application.Images.Storage; using CustomCADs.Shared.Application.Dtos.Files; using CustomCADs.Shared.Application.Policies; -using CustomCADs.UnitTests.Files.Application.Cads; namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.PresignedUrls.Post; @@ -11,33 +10,36 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.Presign public class Tests : Data.Cads.BaseUnitTests { private readonly GetImagePresignedUrlPostHandler handler; + private readonly GetImagePresignedUrlPostQuery request = new(Name, Upload.Request, Type, ValidOwnerId); + private readonly Mock storage = new(); public const string Name = "CustomCAD"; private const FileContextType Type = FileContextType.Product; - public static readonly UploadFileRequest req = new("content-type", "file-name"); - public static readonly UploadFileResponse res = new("generated-key", "presigned-url"); + public static readonly (UploadFileRequest Request, UploadFileResponse Response) Upload = ( + Request: new("content-type", "file-name"), + Response: new("generated-key", "presigned-url") + ); public Tests() { handler = new(storage.Object, policies: [new PolicyMock()]); - storage.Setup(x => x.GetPresignedPostUrlAsync(Name, req)) - .ReturnsAsync(res); + storage.Setup(x => x.GetPresignedPostUrlAsync(Name, Upload.Request)) + .ReturnsAsync(Upload.Response); } [Fact] public async Task Handle_ShouldCallStorage() { // Arrange - GetImagePresignedUrlPostQuery query = new(Name, req, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert storage.Verify( - x => x.GetPresignedPostUrlAsync(Name, req), + x => x.GetPresignedPostUrlAsync(Name, Upload.Request), Times.Once() ); } @@ -46,12 +48,11 @@ public async Task Handle_ShouldCallStorage() public async Task Handle_ShouldReturnResult() { // Arrange - GetImagePresignedUrlPostQuery query = new(Name, req, Type, ValidOwnerId); // Act - UploadFileResponse result = await handler.Handle(query, ct); + UploadFileResponse result = await handler.Handle(request, ct); // Assert - Assert.Equal(res, result); + Assert.Equal(Upload.Response, result); } } diff --git a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs index 1a72caa86..820219d38 100644 --- a/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs +++ b/tests/UnitTests/Files/Application/Images/Queries/Internal/PresignedUrls/Put/Tests.cs @@ -11,14 +11,15 @@ namespace CustomCADs.UnitTests.Files.Application.Images.Queries.Internal.Presign public class Tests : Data.Images.BaseUnitTests { private readonly GetImagePresignedUrlPutHandler handler; + private readonly GetImagePresignedUrlPutQuery request = new(ValidId, UploadRequest, Type, ValidOwnerId); + private readonly Mock reads = new(); private readonly Mock storage = new(); private readonly Mock> cache = new(); private const string PresignedUrl = "presigned-url"; private const FileContextType Type = FileContextType.Product; - private static readonly Image image = CreateImage(); - private static readonly UploadFileRequest req = new(ValidContentType, "Batman.glb"); + private static readonly UploadFileRequest UploadRequest = new(ValidContentType, "Batman.glb"); public Tests() { @@ -29,17 +30,16 @@ public Tests() It.IsAny>>() )).ReturnsAsync(CreateImage()); - storage.Setup(x => x.GetPresignedPutUrlAsync(image.Key, req)).ReturnsAsync(PresignedUrl); + storage.Setup(x => x.GetPresignedPutUrlAsync(ValidKey, UploadRequest)).ReturnsAsync(PresignedUrl); } [Fact] public async Task Handle_ShouldReadCache() { // Arrange - GetImagePresignedUrlPutQuery query = new(ValidId, req, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -52,14 +52,13 @@ public async Task Handle_ShouldReadCache() public async Task Handle_ShouldCallStorage() { // Arrange - GetImagePresignedUrlPutQuery query = new(ValidId, req, Type, ValidOwnerId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert storage.Verify( - x => x.GetPresignedPutUrlAsync(image.Key, req), + x => x.GetPresignedPutUrlAsync(ValidKey, UploadRequest), Times.Once() ); } @@ -68,10 +67,9 @@ public async Task Handle_ShouldCallStorage() public async Task Handle_ShouldReturnResult() { // Arrange - GetImagePresignedUrlPutQuery query = new(ValidId, req, Type, ValidOwnerId); // Act - string url = await handler.Handle(query, ct); + string url = await handler.Handle(request, ct); // Assert Assert.Equal(PresignedUrl, url); diff --git a/tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/Tests.cs b/tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/Tests.cs index a1a34637f..53dc74da5 100644 --- a/tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/Tests.cs +++ b/tests/UnitTests/Files/Domain/Cads/Behaviors/CamCoordinates/Tests.cs @@ -7,14 +7,14 @@ namespace CustomCADs.UnitTests.Files.Domain.Cads.Behaviors.CamCoordinates; public class Tests : Data.Cads.BaseUnitTests { - private static readonly Coordinates coords = new(MinValidCoord, MinValidCoord, MinValidCoord); + private static readonly Coordinates Coords = new(MinValidCoord, MinValidCoord, MinValidCoord); [Fact] public void SetCamCoordinates_ShouldNotThrowException_WhenCoordinatesAreValid() { var cad = CreateCad(); - cad.SetCamCoordinates(coords); + cad.SetCamCoordinates(Coords); } [Fact] @@ -22,9 +22,9 @@ public void SetCamCoordinates_ShouldPopulateProperties_WhenCoordinatesAreValid() { var cad = CreateCad(); - cad.SetCamCoordinates(coords); + cad.SetCamCoordinates(Coords); - Assert.Equal(coords, cad.CamCoordinates); + Assert.Equal(Coords, cad.CamCoordinates); } [Fact] @@ -33,7 +33,7 @@ public void SetCamCoordinates_ShouldThrowException_WhenCoordinatesIsInvalid() var cad = CreateCad(); Assert.Throws>( - () => cad.SetCamCoordinates(coords with { X = MinInvalidCoord }) + () => cad.SetCamCoordinates(Coords with { X = MinInvalidCoord }) ); } } diff --git a/tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/Tests.cs b/tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/Tests.cs index 19e99b2f7..e4104f711 100644 --- a/tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/Tests.cs +++ b/tests/UnitTests/Files/Domain/Cads/Behaviors/PanCoordinates/Tests.cs @@ -7,14 +7,14 @@ namespace CustomCADs.UnitTests.Files.Domain.Cads.Behaviors.PanCoordinates; public class Tests : Data.Cads.BaseUnitTests { - private static readonly Coordinates coords = new(MinValidCoord, MinValidCoord, MinValidCoord); + private static readonly Coordinates Coords = new(MinValidCoord, MinValidCoord, MinValidCoord); [Fact] public void SetPanCoordinates_ShouldNotThrowException_WhenCoordinatesAreValid() { var cad = CreateCad(); - cad.SetPanCoordinates(coords); + cad.SetPanCoordinates(Coords); } [Fact] @@ -22,9 +22,9 @@ public void SetPanCoordinates_ShouldPopulateProperties_WhenCoordinatesAreValid() { var cad = CreateCad(); - cad.SetPanCoordinates(coords); + cad.SetPanCoordinates(Coords); - Assert.Equal(coords, cad.PanCoordinates); + Assert.Equal(Coords, cad.PanCoordinates); } [Fact] @@ -33,7 +33,7 @@ public void SetPanCoordinates_ShouldThrowException_WhenCoordinatesIsInvalid() var cad = CreateCad(); Assert.Throws>( - () => cad.SetPanCoordinates(coords with { X = MaxInvalidCoord }) + () => cad.SetPanCoordinates(Coords with { X = MaxInvalidCoord }) ); } } diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs index e6beb9586..725a0a1d3 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Complete/Tests.cs @@ -10,6 +10,13 @@ namespace CustomCADs.UnitTests.Idempotency.Application.IdempotencyKeys.Commands. public class Tests : Data.IdempotencyKeys.BaseUnitTests { private readonly CompleteIdempotencyKeyHandler handler; + private readonly CompleteIdempotencyKeyCommand request = new( + Id: ValidId, + RequestHash: ValidRequestHash, + ResponseBody: ValidResponseBody, + StatusCode: MaxValidStatusCode + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); @@ -29,15 +36,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CompleteIdempotencyKeyCommand command = new( - Id: ValidId, - RequestHash: ValidRequestHash, - ResponseBody: ValidResponseBody, - StatusCode: MaxValidStatusCode - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -55,15 +56,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CompleteIdempotencyKeyCommand command = new( - Id: ValidId, - RequestHash: ValidRequestHash, - ResponseBody: ValidResponseBody, - StatusCode: MaxValidStatusCode - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -78,17 +73,10 @@ public async Task Handle_ShouldThrowException_WhenIdempotencyKeyNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, ValidRequestHash, true, ct)).ReturnsAsync(null as IdempotencyKey); - CompleteIdempotencyKeyCommand command = new( - Id: ValidId, - RequestHash: ValidRequestHash, - ResponseBody: ValidResponseBody, - StatusCode: MaxValidStatusCode - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs index e58a64285..4be73742d 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Create/Tests.cs @@ -9,6 +9,11 @@ namespace CustomCADs.UnitTests.Idempotency.Application.IdempotencyKeys.Commands. public class Tests : Data.IdempotencyKeys.BaseUnitTests { private readonly CreateIdempotencyKeyHandler handler; + private readonly CreateIdempotencyKeyCommand request = new( + IdempotencyKey: ValidId.Value, + RequestHash: ValidRequestHash + ); + private readonly Mock> writes = new(); private readonly Mock uow = new(); @@ -29,13 +34,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateIdempotencyKeyCommand command = new( - IdempotencyKey: ValidId.Value, - RequestHash: ValidRequestHash - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -58,13 +59,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - CreateIdempotencyKeyCommand command = new( - IdempotencyKey: ValidId.Value, - RequestHash: ValidRequestHash - ); // Act - IdempotencyKeyId id = await handler.Handle(command, ct); + IdempotencyKeyId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs index 509d63cee..3c53a1758 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Commands/Internal/Delete/Tests.cs @@ -10,6 +10,11 @@ namespace CustomCADs.UnitTests.Idempotency.Application.IdempotencyKeys.Commands. public class Tests : Data.IdempotencyKeys.BaseUnitTests { private readonly DeleteIdempotencyKeyHandler handler; + private readonly DeleteIdempotencyKeyCommand request = new( + IdempotencyKey: ValidId.Value, + RequestHash: ValidRequestHash + ); + private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); @@ -30,13 +35,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DeleteIdempotencyKeyCommand command = new( - IdempotencyKey: ValidId.Value, - RequestHash: ValidRequestHash - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -54,13 +55,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DeleteIdempotencyKeyCommand command = new( - IdempotencyKey: ValidId.Value, - RequestHash: ValidRequestHash - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -79,15 +76,10 @@ public async Task Handle_ShouldThrowException_WhenIdempotencyKeyNotFound() // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, ValidRequestHash, true, ct)).ReturnsAsync(null as IdempotencyKey); - DeleteIdempotencyKeyCommand command = new( - IdempotencyKey: ValidId.Value, - RequestHash: ValidRequestHash - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs index e5c5d3650..cb632e8e4 100644 --- a/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs +++ b/tests/UnitTests/Idempotency/Application/IdempotencyKeys/Queries/Internal/Get/Tests.cs @@ -9,9 +9,11 @@ namespace CustomCADs.UnitTests.Idempotency.Application.IdempotencyKeys.Queries.I public class Tests : Data.IdempotencyKeys.BaseUnitTests { private readonly GetIdempotencyKeyHandler handler; + private readonly GetIdempotencyKeyQuery request = new(ValidId.Value, ValidRequestHash); + private readonly Mock reads = new(); - private static readonly IdempotencyKey idempotencyKey = CreateIdempotencyKey(); + private readonly IdempotencyKey idempotencyKey = CreateIdempotencyKey(); public Tests() { @@ -25,13 +27,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetIdempotencyKeyQuery query = new( - IdempotencyKey: ValidId.Value, - RequestHash: ValidRequestHash - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -57,13 +55,8 @@ public async Task Handle_ShouldReturnResult(bool isIdempotencyKeyCompleted) idempotencyKey.SetStatusCode(MaxValidStatusCode); } - GetIdempotencyKeyQuery query = new( - IdempotencyKey: ValidId.Value, - RequestHash: ValidRequestHash - ); - // Act - GetIdempotencyKeyDto? result = await handler.Handle(query, ct); + GetIdempotencyKeyDto? result = await handler.Handle(request, ct); // Assert if (isIdempotencyKeyCompleted) @@ -84,15 +77,11 @@ public async Task Handle_ShouldThrowException_WhenIdempotencyKeyNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, ValidRequestHash, false, ct)).ReturnsAsync(null as IdempotencyKey); - GetIdempotencyKeyQuery query = new( - IdempotencyKey: ValidId.Value, - RequestHash: ValidRequestHash - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs index 63ae39260..54daaf028 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ChangeUsername/Tests.cs @@ -10,39 +10,39 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Chan public class Tests : Data.Users.BaseUnitTests { private readonly ChangeUsernameHandler handler; + private readonly ChangeUsernameCommand request = new( + Id: ValidAccountId, + Username: MinValidUsername, + FirstName: null, + LastName: null + ); + private readonly Mock service = new(); private readonly Mock raiser = new(); - private readonly User user = CreateUser(); - public Tests() { handler = new(service.Object, raiser.Object); - service.Setup(x => x.GetByAccountIdAsync(user.AccountId)).ReturnsAsync(user); + service.Setup(x => x.GetByAccountIdAsync(ValidAccountId)) + .ReturnsAsync(CreateUser()); } [Fact] public async Task Handle_ShouldCallService() { // Arrange - ChangeUsernameCommand command = new( - Id: user.AccountId, - Username: MinValidUsername, - FirstName: null, - LastName: null - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( - x => x.GetByAccountIdAsync(user.AccountId), + x => x.GetByAccountIdAsync(ValidAccountId), Times.Once() ); service.Verify( - x => x.UpdateUsernameAsync(user.Id, MinValidUsername), + x => x.UpdateUsernameAsync(ValidId, MinValidUsername), Times.Once() ); } @@ -51,22 +51,16 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldRaiseEvents() { // Arrange - ChangeUsernameCommand command = new( - Id: user.AccountId, - Username: MinValidUsername, - FirstName: null, - LastName: null - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( x => x.RaiseApplicationEventAsync( It.Is(x => - x.Username == user.Username - && x.Id == user.AccountId + x.Username == MinValidUsername + && x.Id == ValidAccountId ) ), Times.Once() diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs index 0cf05505a..976fb9cd3 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Delete/Tests.cs @@ -10,11 +10,11 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Dele public class Tests : Data.Users.BaseUnitTests { private readonly DeleteUserHandler handler; + private readonly DeleteUserCommand request = new(ValidAccountId); + private readonly Mock service = new(); private readonly Mock raiser = new(); - private readonly User user = CreateUser(username: MaxValidUsername); - public Tests() { handler = new(service.Object, raiser.Object); @@ -24,14 +24,13 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - DeleteUserCommand command = new(user.AccountId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( - x => x.DeleteAsync(user.AccountId), + x => x.DeleteAsync(ValidAccountId), Times.Once() ); } @@ -40,15 +39,14 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldRaiseEvents() { // Arrange - DeleteUserCommand command = new(user.AccountId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( x => x.RaiseApplicationEventAsync( - It.Is(x => x.Id == user.AccountId) + It.Is(x => x.Id == ValidAccountId) ), Times.Once() ); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs index 4c76d3718..5a9ea694a 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Login/Tests.cs @@ -11,6 +11,13 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Logi public class Tests : Data.Users.BaseUnitTests { private readonly LoginUserHandler handler; + private readonly LoginUserCommand request = new( + Username: MaxValidUsername, + Password: MinValidPassword, + LongerExpireTime: false, + Fingerprint: ValidFingerprint + ); + private readonly Mock service = new(); private readonly Mock tokenService = new(); @@ -40,15 +47,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - LoginUserCommand command = new( - Username: User.Username, - Password: MinValidPassword, - LongerExpireTime: false, - Fingerprint: ValidFingerprint - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( @@ -69,15 +70,9 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldIssueTokens() { // Arrange - LoginUserCommand command = new( - Username: User.Username, - Password: MinValidPassword, - LongerExpireTime: false, - Fingerprint: ValidFingerprint - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert tokenService.Verify( @@ -96,15 +91,9 @@ public async Task Handle_ShouldIssueTokens() public async Task Handle_ShouldReturnResult() { // Arrange - LoginUserCommand command = new( - Username: User.Username, - Password: MinValidPassword, - LongerExpireTime: false, - Fingerprint: ValidFingerprint - ); // Act - TokensDto tokens = await handler.Handle(command, ct); + TokensDto tokens = await handler.Handle(request, ct); // Assert Assert.Equal(Tokens, tokens); @@ -116,17 +105,10 @@ public async Task Handle_ShouldThrowException_WhenPasswordIncorrect() // Arrange service.Setup(x => x.CheckPasswordAsync(User.Username, MinValidPassword)).ReturnsAsync(false); - LoginUserCommand command = new( - Username: User.Username, - Password: MinValidPassword, - LongerExpireTime: false, - Fingerprint: ValidFingerprint - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -136,17 +118,10 @@ public async Task Handle_ShouldThrowException_WhenUserLockedOut() // Arrange service.Setup(x => x.GetIsLockedOutAsync(User.Username)).ReturnsAsync(DateTimeOffset.UtcNow); - LoginUserCommand command = new( - Username: User.Username, - Password: MinValidPassword, - LongerExpireTime: false, - Fingerprint: ValidFingerprint - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -157,17 +132,10 @@ public async Task Handle_ShouldThrowException_WhenUserNotVerified() User unverifiedUser = CreateUser(email: ValidEmail, isVerified: false); service.Setup(x => x.GetByUsernameAsync(unverifiedUser.Username)).ReturnsAsync(unverifiedUser); - LoginUserCommand command = new( - Username: unverifiedUser.Username, - Password: MinValidPassword, - LongerExpireTime: false, - Fingerprint: ValidFingerprint - ); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { Username = unverifiedUser.Username }, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs index fceef5d67..d731cb2a8 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Logout/Tests.cs @@ -10,32 +10,31 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Logo public class Tests : Data.Users.BaseUnitTests { private readonly LogoutUserHandler handler; + private readonly LogoutUserCommand request = new("refresh-token"); + private readonly Mock service = new(); - private static readonly RefreshToken token = RefreshToken.Create("refresh-token", ValidFingerprint, ValidId, longerSession: false); + private static readonly RefreshToken Token = RefreshToken.Create("refresh-token", ValidFingerprint, ValidId, longerSession: false); private readonly User user = CreateUser(username: MaxValidUsername); public Tests() { handler = new(service.Object); - service.Setup(x => x.GetByRefreshTokenAsync(token.Value)).ReturnsAsync((user, token)); + service.Setup(x => x.GetByRefreshTokenAsync(Token.Value)).ReturnsAsync((user, Token)); } [Fact] public async Task Handle_ShouldCallService() { // Arrange - LogoutUserCommand command = new( - RefreshToken: token.Value - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( - x => x.RevokeRefreshTokenAsync(token.Value), + x => x.RevokeRefreshTokenAsync(Token.Value), Times.Once() ); } @@ -44,12 +43,11 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldThrowException_WhenMissingToken() { // Arrange - LogoutUserCommand command = new(RefreshToken: null); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { RefreshToken = null }, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs index 2dc1dbcc4..3de114c43 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Refresh/Tests.cs @@ -12,6 +12,8 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Refr public class Tests : Data.Users.BaseUnitTests { private readonly RefreshUserHandler handler; + private readonly RefreshUserCommand request = new(RefreshToken.Value, ValidFingerprint); + private readonly Mock service = new(); private readonly Mock tokenService = new(); @@ -37,10 +39,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - RefreshUserCommand command = new(RefreshToken.Value, ValidFingerprint); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( @@ -53,10 +54,9 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldIssueTokens() { // Arrange - RefreshUserCommand command = new(RefreshToken.Value, ValidFingerprint); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert tokenService.Verify( @@ -69,10 +69,9 @@ public async Task Handle_ShouldIssueTokens() public async Task Handle_ShouldReturnResult() { // Arrange - RefreshUserCommand command = new(RefreshToken.Value, ValidFingerprint); // Act - TokensDto tokens = await handler.Handle(command, ct); + TokensDto tokens = await handler.Handle(request, ct); // Assert Assert.Equal(Tokens, tokens); @@ -82,12 +81,11 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldThrowException_WhenMissingToken() { // Arrange - RefreshUserCommand command = new(Token: null, ValidFingerprint); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { Token = null }, ct) ); } @@ -106,12 +104,10 @@ public async Task Handle_ShouldThrowException_WhenTokenExpired() ); service.Setup(x => x.GetByRefreshTokenAsync(token.Value)).ReturnsAsync((User, token)); - RefreshUserCommand command = new(token.Value, ValidFingerprint); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { Token = token.Value }, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs index 96bc558d8..cf14b0b3f 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/Register/Tests.cs @@ -11,6 +11,15 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Regi public class Tests : Data.Users.BaseUnitTests { private readonly RegisterUserHandler handler; + private readonly RegisterUserCommand request = new( + Role: ValidRole, + Username: MaxValidUsername, + Email: ValidEmail, + Password: MinValidPassword, + FirstName: null, + LastName: null + ); + private readonly Mock service = new(); private readonly Mock sender = new(); @@ -28,26 +37,18 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - RegisterUserCommand command = new( - Role: ValidRole, - Username: MaxValidUsername, - Email: ValidEmail, - Password: MinValidPassword, - FirstName: null, - LastName: null - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( x => x.CreateAsync( It.Is(x => - x.Username == command.Username + x.Username == request.Username && x.AccountId == ValidAccountId ), - command.Password + request.Password ), Times.Once() ); @@ -57,27 +58,19 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldSendRequests() { // Arrange - RegisterUserCommand command = new( - Role: ValidRole, - Username: MaxValidUsername, - Email: ValidEmail, - Password: MinValidPassword, - FirstName: null, - LastName: null - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( x => x.SendCommandAsync( It.Is(x => - x.Role == command.Role - && x.Username == command.Username - && x.Email == command.Email - && x.FirstName == command.FirstName - && x.LastName == command.LastName + x.Role == request.Role + && x.Username == request.Username + && x.Email == request.Email + && x.FirstName == request.FirstName + && x.LastName == request.LastName ), ct ), @@ -94,19 +87,10 @@ public async Task Handle_ShouldThrowException_WhenRegisterUnsuccessfuly() MinValidPassword )).ThrowsAsync(new CustomException("CreationErrorMessage")); - RegisterUserCommand command = new( - Role: ValidRole, - Username: MaxValidUsername, - Email: ValidEmail, - Password: MinValidPassword, - FirstName: null, - LastName: null - ); - // Assert await Assert.ThrowsAsync( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs index 9e3dff83d..7957fc316 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPassword/Tests.cs @@ -8,6 +8,12 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Rese public class Tests : Data.Users.BaseUnitTests { private readonly ResetUserPasswordHandler handler; + private readonly ResetUserPasswordCommand request = new( + Email: ValidEmail, + Token: Token, + NewPassword: MinValidPassword + ); + private readonly Mock service = new(); private const string Token = "email-token"; @@ -22,14 +28,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - ResetUserPasswordCommand command = new( - Email: user.Email.Value, - Token: Token, - NewPassword: MinValidPassword - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs index 5ba0e1479..2f438bc63 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ResetPasswordEmail/Tests.cs @@ -7,9 +7,13 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.ResetPasswordEmail; +using static Data.Users.TestData; + public class Tests : Data.Users.BaseUnitTests { private readonly ResetPasswordEmailHandler handler; + private readonly ResetPasswordEmailCommand request = new(ValidEmail); + private readonly Mock service = new(); private readonly Mock raiser = new(); private readonly Mock> settings = new(); @@ -30,10 +34,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - ResetPasswordEmailCommand command = new(user.Email.Value); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( @@ -46,10 +49,9 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldRaiseEvents() { // Arrange - ResetPasswordEmailCommand command = new(user.Email.Value); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs index 3ffa7be98..ab6b97793 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/SSO/Tests.cs @@ -12,12 +12,22 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.SSO; public class Tests : Data.Users.BaseUnitTests { private readonly SingleSignOnUserHandler handler; + private readonly SingleSignOnUserCommand request = new( + Role: ValidRole, + FirstName: null, + LastName: null, + Username: MaxValidUsername, + Email: ValidEmail, + Provider: Provider, + Fingerprint: ValidFingerprint + ); + private readonly Mock service = new(); private readonly Mock tokenService = new(); private readonly Mock sender = new(); private const string Provider = "Google"; - private readonly User User = CreateUser(username: MaxValidUsername); + private readonly User user = CreateUser(username: MaxValidUsername); private static readonly RefreshToken RefreshToken = RefreshToken.Create("refresh-token", ValidFingerprint, ValidId, false); private static readonly TokensDto Tokens = new( Role: "role", @@ -33,10 +43,10 @@ public Tests() tokenService.Setup(x => x.IssueRefreshToken( It.IsAny>()) ).Returns(RefreshToken); - tokenService.Setup(x => x.IssueTokens(User, RefreshToken)).Returns(Tokens); + tokenService.Setup(x => x.IssueTokens(user, RefreshToken)).Returns(Tokens); - service.Setup(x => x.GetExistsByUsernameAsync(User.Username)).ReturnsAsync(true); - service.Setup(x => x.GetByUsernameAsync(User.Username)).ReturnsAsync(User); + service.Setup(x => x.GetExistsByUsernameAsync(user.Username)).ReturnsAsync(true); + service.Setup(x => x.GetByUsernameAsync(user.Username)).ReturnsAsync(user); sender.Setup(x => x.SendCommandAsync( It.Is(x => x.Username == MaxValidUsername), @@ -48,35 +58,26 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - SingleSignOnUserCommand command = new( - Role: User.Role, - FirstName: null, - LastName: null, - Username: User.Username, - Email: User.Email.Value, - Provider: Provider, - Fingerprint: ValidFingerprint - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( - x => x.GetExistsByUsernameAsync(User.Username), + x => x.GetExistsByUsernameAsync(user.Username), Times.Once() ); service.Verify( - x => x.GetExistsByEmailAsync(User.Email.Value), + x => x.GetExistsByEmailAsync(user.Email.Value), Times.Once() ); service.Verify( - x => x.SaveRefreshTokensAsync(User), + x => x.SaveRefreshTokensAsync(user), Times.Once() ); service.Verify( - x => x.GetByUsernameAsync(User.Username), + x => x.GetByUsernameAsync(user.Username), Times.Once() ); } @@ -85,26 +86,16 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldCallGetByEmail_WhenUsernameDoesNotExist() { // Arrange - service.Setup(x => x.GetExistsByUsernameAsync(User.Username)).ReturnsAsync(false); - service.Setup(x => x.GetExistsByEmailAsync(User.Email.Value)).ReturnsAsync(true); - service.Setup(x => x.GetByEmailAsync(User.Email.Value)).ReturnsAsync(User); - - SingleSignOnUserCommand command = new( - Role: User.Role, - FirstName: null, - LastName: null, - Username: User.Username, - Email: User.Email.Value, - Provider: Provider, - Fingerprint: ValidFingerprint - ); + service.Setup(x => x.GetExistsByUsernameAsync(user.Username)).ReturnsAsync(false); + service.Setup(x => x.GetExistsByEmailAsync(user.Email.Value)).ReturnsAsync(true); + service.Setup(x => x.GetByEmailAsync(user.Email.Value)).ReturnsAsync(user); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( - x => x.GetByEmailAsync(User.Email.Value), + x => x.GetByEmailAsync(user.Email.Value), Times.Once() ); } @@ -113,29 +104,19 @@ public async Task Handle_ShouldCallGetByEmail_WhenUsernameDoesNotExist() public async Task Handle_ShouldCallCreateUser_WhenUsernameAndEmailDoNotExist() { // Arrange - service.Setup(x => x.GetExistsByUsernameAsync(User.Username)).ReturnsAsync(false); - service.Setup(x => x.GetExistsByEmailAsync(User.Email.Value)).ReturnsAsync(false); - - SingleSignOnUserCommand command = new( - Role: User.Role, - FirstName: null, - LastName: null, - Username: User.Username, - Email: User.Email.Value, - Provider: Provider, - Fingerprint: ValidFingerprint - ); + service.Setup(x => x.GetExistsByUsernameAsync(user.Username)).ReturnsAsync(false); + service.Setup(x => x.GetExistsByEmailAsync(user.Email.Value)).ReturnsAsync(false); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( x => x.SendCommandAsync( It.Is(x => - x.Role == command.Role - && x.Username == command.Username - && x.Email == command.Email + x.Role == request.Role + && x.Username == request.Username + && x.Email == request.Email ), ct ), @@ -144,7 +125,7 @@ public async Task Handle_ShouldCallCreateUser_WhenUsernameAndEmailDoNotExist() service.Verify( x => x.CreateSSOAsync( It.Is(x => - x.Username == command.Username + x.Username == request.Username && x.AccountId == ValidAccountId ), Provider @@ -152,7 +133,7 @@ public async Task Handle_ShouldCallCreateUser_WhenUsernameAndEmailDoNotExist() Times.Once() ); service.Verify( - x => x.GetByUsernameAsync(User.Username), + x => x.GetByUsernameAsync(user.Username), Times.Once() ); } @@ -161,18 +142,9 @@ public async Task Handle_ShouldCallCreateUser_WhenUsernameAndEmailDoNotExist() public async Task Handle_ShouldIssueTokens() { // Arrange - SingleSignOnUserCommand command = new( - Role: User.Role, - FirstName: null, - LastName: null, - Username: User.Username, - Email: User.Email.Value, - Provider: Provider, - Fingerprint: ValidFingerprint - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert tokenService.Verify( @@ -182,7 +154,7 @@ public async Task Handle_ShouldIssueTokens() Times.Once() ); tokenService.Verify( - x => x.IssueTokens(User, RefreshToken), + x => x.IssueTokens(user, RefreshToken), Times.Once() ); } @@ -191,18 +163,9 @@ public async Task Handle_ShouldIssueTokens() public async Task Handle_ShouldReturnResult() { // Arrange - SingleSignOnUserCommand command = new( - Role: User.Role, - FirstName: null, - LastName: null, - Username: User.Username, - Email: User.Email.Value, - Provider: Provider, - Fingerprint: ValidFingerprint - ); // Act - TokensDto tokens = await handler.Handle(command, ct); + TokensDto tokens = await handler.Handle(request, ct); // Assert Assert.Equal(Tokens, tokens); diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs index 27b2cdb05..912b9cd74 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/ToggleViewedProductsTracking/Tests.cs @@ -12,6 +12,8 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Togg public class Tests : Data.Users.BaseUnitTests { private readonly ToggleViewedProductsTrackingHandler handler; + private readonly ToggleViewedProductsTrackingCommand request = new(MaxValidUsername, ValidAccountId); + private readonly Mock sender = new(); private readonly Mock raiser = new(); @@ -31,10 +33,9 @@ public Tests() public async Task Handle_ShouldSendRequests() { // Arrange - ToggleViewedProductsTrackingCommand command = new(MaxValidUsername, ValidAccountId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -50,10 +51,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldRaiseEvents() { // Arrange - ToggleViewedProductsTrackingCommand command = new(MaxValidUsername, ValidAccountId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs index f65fe678e..f656447a2 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs @@ -7,9 +7,13 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.VerificationEmail; +using static Data.Users.TestData; + public class Tests : Data.Users.BaseUnitTests { private readonly VerificationEmailHandler handler; + private readonly VerificationEmailCommand request = new(MaxValidUsername); + private readonly Mock service = new(); private readonly Mock raiser = new(); private readonly Mock> settings = new(); @@ -30,10 +34,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - VerificationEmailCommand command = new(user.Username); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( @@ -50,10 +53,9 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldRaiseEvents() { // Arrange - VerificationEmailCommand command = new(user.Username); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert raiser.Verify( diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs index 00b29f45b..b19db36d6 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerifyEmail/Tests.cs @@ -11,11 +11,13 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Commands.Internal.Veri public class Tests : Data.Users.BaseUnitTests { private readonly VerifyUserEmailHandler handler; + private readonly VerifyUserEmailCommand request = new(MinValidUsername, Token, ValidFingerprint); + private readonly Mock service = new(); private readonly Mock tokenService = new(); private const string Token = "email-token"; - private readonly User User = CreateUser(email: ValidEmail, isVerified: false); + private readonly User User = CreateUser(isVerified: false); private static readonly RefreshToken RefreshToken = RefreshToken.Create(Token, ValidFingerprint, ValidId, false); private static readonly TokensDto Tokens = new( Role: "role", @@ -40,10 +42,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - VerifyUserEmailCommand command = new(User.Username, Token, ValidFingerprint); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert service.Verify( @@ -60,10 +61,9 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldIssueTokens() { // Arrange - VerifyUserEmailCommand command = new(User.Username, Token, ValidFingerprint); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert tokenService.Verify( @@ -82,10 +82,9 @@ public async Task Handle_ShouldIssueTokens() public async Task Handle_ShouldReturnResult() { // Arrange - VerifyUserEmailCommand command = new(User.Username, Token, ValidFingerprint); // Act - TokensDto tokens = await handler.Handle(command, ct); + TokensDto tokens = await handler.Handle(request, ct); // Assert Assert.Equal(Tokens, tokens); @@ -98,12 +97,10 @@ public async Task Handle_ShouldThrowException_WhenEmailVerified() User verifiedUser = CreateUser(email: ValidEmail, isVerified: true); service.Setup(x => x.GetByUsernameAsync(verifiedUser.Username)).ReturnsAsync(verifiedUser); - VerifyUserEmailCommand command = new(verifiedUser.Username, Token, ValidFingerprint); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request with { Username = verifiedUser.Username }, ct) ); } } diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs index 62e3e6350..7ec13dbec 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/EmailVerification/Tests.cs @@ -6,6 +6,8 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Ema public class Tests : Data.Users.BaseUnitTests { private readonly EmailVerificationRequestedEventHandler handler; + private readonly EmailVerificationRequestedApplicationEvent request = new(Email, Endpoint); + private readonly Mock email = new(); private const string Email = "recipient@gmail.com"; @@ -20,10 +22,9 @@ public Tests() public async Task Handle_ShouldSendEmails() { // Arrange - EmailVerificationRequestedApplicationEvent @event = new(Email, Endpoint); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert email.Verify( diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs index acc6589bd..5a0a3b981 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Emails/PasswordReset/Tests.cs @@ -6,6 +6,8 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Ema public class Tests : Data.Users.BaseUnitTests { private readonly PasswordResetRequestedEventHandler handler; + private readonly PasswordResetRequestedApplicationEvent request = new(Email, Endpoint); + private readonly Mock email = new(); private const string Email = "recipient@gmail.com"; @@ -20,10 +22,9 @@ public Tests() public async Task Handle_ShouldSendEmails() { // Arrange - PasswordResetRequestedApplicationEvent @event = new(Email, Endpoint); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert email.Verify( diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs index 682791e3f..02c4704fb 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Created/Tests.cs @@ -9,6 +9,11 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Rol public class Tests : Data.Users.BaseUnitTests { private readonly RoleCreatedHandler handler; + private readonly RoleCreatedApplicationEvent request = new( + Name: ValidRole, + Description: string.Empty + ); + private readonly Mock service = new(); public Tests() @@ -20,13 +25,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - RoleCreatedApplicationEvent @event = new( - Name: ValidRole, - Description: string.Empty - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert service.Verify( diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs index 86c08066c..ed5b9ce33 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Roles/Deleted/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Rol public class Tests : Data.Users.BaseUnitTests { private readonly RoleDeletedHandler handler; + private readonly RoleDeletedApplicationEvent request = new(ValidRole); + private readonly Mock service = new(); public Tests() @@ -20,10 +22,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - RoleDeletedApplicationEvent @event = new(ValidRole); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert service.Verify( diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs index c1a69e28c..527591d94 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Created/Tests.cs @@ -9,9 +9,15 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Use public class Tests : Data.Users.BaseUnitTests { private readonly AccountCreatedHandler handler; - private readonly Mock service = new(); + private readonly AccountCreatedApplicationEvent request = new( + Id: ValidAccountId, + Role: ValidRole, + Username: MinValidUsername, + Email: ValidEmail, + Password: MinValidPassword + ); - private readonly User user = CreateUser(); + private readonly Mock service = new(); public Tests() { @@ -22,27 +28,20 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - AccountCreatedApplicationEvent @event = new( - Id: user.AccountId, - Role: user.Role, - Username: user.Username, - Email: user.Email.Value, - Password: MinValidPassword - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert service.Verify( x => x.CreateAsync( It.Is(x => - x.Role == @event.Role - && x.Username == @event.Username - && x.Email.Value == @event.Email - && x.AccountId == @event.Id + x.Role == request.Role + && x.Username == request.Username + && x.Email.Value == request.Email + && x.AccountId == request.Id ), - @event.Password + request.Password ), Times.Once() ); diff --git a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs index cc8c6ca55..3604ed8bc 100644 --- a/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Events/Application/Users/Deleted/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Events.Application.Use public class Tests : Data.Users.BaseUnitTests { private readonly AccountDeletedHandler handler; + private readonly AccountDeletedApplicationEvent request = new(ValidAccountId); + private readonly Mock service = new(); public Tests() @@ -20,10 +22,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - AccountDeletedApplicationEvent @event = new(ValidAccountId); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert service.Verify( diff --git a/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs b/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs index ac2148ac5..5598d88a6 100644 --- a/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Queries/Internal/GetByUsername/Tests.cs @@ -10,13 +10,16 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Queries.Internal.GetBy public class Tests : Data.Users.BaseUnitTests { private readonly GetUserByUsernameHandler handler; + private readonly GetUserByUsernameQuery request = new(ValidAccountId, "refresh-token"); + private readonly Mock service = new(); private readonly Mock sender = new(); + private readonly User user = CreateUser(); public Tests() { - user.AddRefreshToken("refresh-token", ValidFingerprint, false); + user.AddRefreshToken(request.RefreshToken!, ValidFingerprint, false); handler = new(service.Object, sender.Object); @@ -33,10 +36,9 @@ public Tests() public async Task Handle_ShouldCallService() { // Arrange - GetUserByUsernameQuery query = new(user.AccountId, "refresh-token"); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert service.Verify( @@ -49,10 +51,9 @@ public async Task Handle_ShouldCallService() public async Task Handle_ShouldSendRequests() { // Arrange - GetUserByUsernameQuery query = new(user.AccountId, "refresh-token"); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -75,10 +76,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - GetUserByUsernameQuery query = new(user.AccountId, "refresh-token"); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, result.Id); diff --git a/tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/Tests.cs b/tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/Tests.cs index 178eed329..b72166288 100644 --- a/tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Queries/Shared/ClientUrl/Tests.cs @@ -8,6 +8,8 @@ namespace CustomCADs.UnitTests.Identity.Application.Users.Queries.Shared.ClientU public class Tests : Data.Users.BaseUnitTests { private readonly GetClientUrlHandler handler; + private readonly GetClientUrlQuery request = new(); + private readonly Mock> settings = new(); private const string All = "preferred-url.com,www.preferred-url.com,app.preferred-url.com"; @@ -24,10 +26,9 @@ public Tests() public async Task Handle_ShouldReturnResult() { // Arrange - GetClientUrlQuery query = new(); // Act - string actual = await handler.Handle(query, ct); + string actual = await handler.Handle(request, ct); // Assert Assert.Equal(Preferred, actual); diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/Tests.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/Tests.cs index 2fc13476c..d7faee45a 100644 --- a/tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/Tests.cs +++ b/tests/UnitTests/Identity/Domain/Users/Behaviors/AddRefreshToken/Tests.cs @@ -6,7 +6,7 @@ namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.AddRefreshToken; public class Tests : Data.Users.BaseUnitTests { private const string Value = "refresh-token"; - private static readonly User user = CreateUser(); + private readonly User user = CreateUser(); [Fact] public void AddRefreshToken_ShouldNotThrowException() diff --git a/tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/Tests.cs b/tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/Tests.cs index 119f38254..53faaf9ef 100644 --- a/tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/Tests.cs +++ b/tests/UnitTests/Identity/Domain/Users/Behaviors/RemoveRefreshToken/Tests.cs @@ -4,7 +4,7 @@ namespace CustomCADs.UnitTests.Identity.Domain.Users.Behaviors.RemoveRefreshToke public class Tests : Data.Users.BaseUnitTests { - private static readonly User user = CreateUser(); + private readonly User user = CreateUser(); private readonly RefreshToken rt; public Tests() diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs index 4cf5174e8..e5472b2a6 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Hide/Tests.cs @@ -11,6 +11,8 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Commands. public class Tests : Data.Notifications.BaseUnitTests { private readonly HideNotificationHandler handler; + private readonly HideNotificationCommand request = new(ValidId, ValidReceiverId); + private readonly Mock reads = new(); private readonly Mock uow = new(); @@ -26,10 +28,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - HideNotificationCommand command = new(ValidId, ValidReceiverId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -42,10 +43,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - HideNotificationCommand command = new(ValidId, ValidReceiverId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -55,16 +55,15 @@ public async Task Handle_ShouldPersistToDatabase() } [Fact] - public async Task Handle_ShouldThrow_WhenCallerUnauthorized() + public async Task Handle_ShouldThrow_WhenCallerUnauthorizedAccess() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(CreateNotification(receiverId: AccountId.New())); - HideNotificationCommand command = new(ValidId, ValidReceiverId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -73,12 +72,11 @@ public async Task Handle_ShouldThrow_WhenNotificationNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Notification); - HideNotificationCommand command = new(ValidId, ValidReceiverId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs index 630431eb6..10df9277d 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Open/Tests.cs @@ -11,6 +11,8 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Commands. public class Tests : Data.Notifications.BaseUnitTests { private readonly OpenNotificationHandler handler; + private readonly OpenNotificationCommand request = new(ValidId, ValidReceiverId); + private readonly Mock reads = new(); private readonly Mock uow = new(); @@ -26,10 +28,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - OpenNotificationCommand command = new(ValidId, ValidReceiverId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -42,10 +43,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - OpenNotificationCommand command = new(ValidId, ValidReceiverId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -55,16 +55,15 @@ public async Task Handle_ShouldPersistToDatabase() } [Fact] - public async Task Handle_ShouldThrow_WhenCallerUnauthorized() + public async Task Handle_ShouldThrow_WhenCallerUnauthorizedAccess() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(CreateNotification(receiverId: AccountId.New())); - OpenNotificationCommand command = new(ValidId, ValidReceiverId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -73,12 +72,11 @@ public async Task Handle_ShouldThrow_WhenNotificationNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Notification); - OpenNotificationCommand command = new(ValidId, ValidReceiverId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs index d6eff8d01..7b09d1434 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Commands/Internal/Read/Tests.cs @@ -11,6 +11,8 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Commands. public class Tests : Data.Notifications.BaseUnitTests { private readonly ReadNotificationHandler handler; + private readonly ReadNotificationCommand request = new(ValidId, ValidReceiverId); + private readonly Mock reads = new(); private readonly Mock uow = new(); @@ -26,10 +28,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - ReadNotificationCommand command = new(ValidId, ValidReceiverId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -42,10 +43,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - ReadNotificationCommand command = new(ValidId, ValidReceiverId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -55,16 +55,15 @@ public async Task Handle_ShouldPersistToDatabase() } [Fact] - public async Task Handle_ShouldThrow_WhenCallerUnauthorized() + public async Task Handle_ShouldThrow_WhenCallerUnauthorizedAccess() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(CreateNotification(receiverId: AccountId.New())); - ReadNotificationCommand command = new(ValidId, ValidReceiverId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } @@ -73,12 +72,11 @@ public async Task Handle_ShouldThrow_WhenNotificationNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Notification); - ReadNotificationCommand command = new(ValidId, ValidReceiverId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/Tests.cs index 1bd104131..cbc291c6d 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Events/NotificationRequested/Tests.cs @@ -14,6 +14,14 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Events.No public class Tests : Data.Notifications.BaseUnitTests { private readonly NotificationRequestedHandler handler; + private readonly NotificationRequestedEvent request = new( + Type: NotificationType.Unkown, + Description: MinValidDescription, + Link: ValidLink, + AuthorId: ValidAuthorId, + ReceiverIds: [] + ); + private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock sender = new(); @@ -43,25 +51,18 @@ public Tests() public async Task Handle_ShouldPersistToDatabase_WhenSingleReceiver() { // Arrange - NotificationRequestedEvent @event = new( - Type: NotificationType.Unkown, - Description: MinValidDescription, - Link: ValidLink, - AuthorId: ValidAuthorId, - ReceiverIds: [ValidReceiverId] - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request with { ReceiverIds = [ValidReceiverId] }); // Assert writes.Verify( x => x.AddAsync( It.Is(x => - x.Type == @event.Type.ToString() - && x.Content == new NotificationContent(@event.Description, @event.Link) - && x.AuthorId == @event.AuthorId - && x.ReceiverId == @event.ReceiverIds.First() + x.Type == request.Type.ToString() + && x.Content == new NotificationContent(request.Description, request.Link) + && x.AuthorId == request.AuthorId + && x.ReceiverId == ValidReceiverId ), ct ), @@ -77,16 +78,9 @@ public async Task Handle_ShouldPersistToDatabase_WhenSingleReceiver() public async Task Handle_ShouldBulkInsert_WhenMultipleReceivers() { // Arrange - NotificationRequestedEvent @event = new( - Type: NotificationType.Unkown, - Description: MinValidDescription, - Link: ValidLink, - AuthorId: ValidAuthorId, - ReceiverIds: [ValidReceiverId, ValidAuthorId] - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request with { ReceiverIds = [ValidReceiverId, ValidAuthorId] }); // Assert uow.Verify( @@ -102,16 +96,9 @@ public async Task Handle_ShouldBulkInsert_WhenMultipleReceivers() public async Task Handle_ShouldSendRequests() { // Arrange - NotificationRequestedEvent @event = new( - Type: NotificationType.Unkown, - Description: MinValidDescription, - Link: ValidLink, - AuthorId: ValidAuthorId, - ReceiverIds: [ValidReceiverId, ValidAuthorId] - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert sender.Verify( @@ -127,21 +114,14 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldNotifySubscribers() { // Arrange - NotificationRequestedEvent @event = new( - Type: NotificationType.Unkown, - Description: MinValidDescription, - Link: ValidLink, - AuthorId: ValidAuthorId, - ReceiverIds: [ValidReceiverId, ValidAuthorId] - ); // Act - await handler.HandleAsync(@event); + await handler.HandleAsync(request); // Assert notifier.Verify( x => x.NotifyUsersAsync( - @event.ReceiverIds, + request.ReceiverIds, It.IsAny(), It.IsAny(), ct diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs index 338c3cdc7..6df285999 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/Count/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Queries.I public class Tests : Data.Notifications.BaseUnitTests { private readonly CountNotificationsHandler handler; + private readonly CountNotificationsQuery request = new(ValidReceiverId); + private readonly Mock reads = new(); private readonly static Dictionary expected = new() @@ -31,10 +33,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - CountNotificationsQuery query = new(ValidReceiverId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -47,10 +48,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - CountNotificationsQuery query = new(ValidReceiverId); // Act - CountNotificationsDto counts = await handler.Handle(query, ct); + CountNotificationsDto counts = await handler.Handle(request, ct); // Assert Assert.Multiple( diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs index 3a0692056..0d2d861d9 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetAll/Tests.cs @@ -12,51 +12,49 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Queries.I public class Tests : Data.Notifications.BaseUnitTests { private readonly GetAllNotificationsHandler handler; + private readonly GetAllNotificationsQuery request = new( + Pagination: Query.Pagination, + CallerId: ValidReceiverId, + Sorting: Query.Sorting + ); + private readonly Mock reads = new(); private readonly Mock sender = new(); - private readonly Notification[] notifications = [ + private static readonly Notification[] Notifications = [ CreateNotification(id: ValidId, authorId: AccountId.New()), CreateNotification(id: ValidId, authorId: AccountId.New()) ]; - private readonly NotificationQuery query; - private readonly Result result; + private static readonly NotificationQuery Query = new( + Pagination: new(1, Notifications.Length) + ); + private static readonly Result Result = new( + Count: Notifications.Length, + Items: Notifications + ); public Tests() { handler = new(reads.Object, sender.Object); - query = new( - Pagination: new(1, notifications.Length) - ); - result = new( - Count: notifications.Length, - Items: notifications - ); - reads.Setup(x => x.AllAsync( It.IsAny(), false, ct - )).ReturnsAsync(result); + )).ReturnsAsync(Result); sender.Setup(x => x.SendQueryAsync( - It.Is(x => x.Ids.Length == notifications.Length), + It.Is(x => x.Ids.Length == Notifications.Length), ct - )).ReturnsAsync(notifications.ToDictionary(x => x.AuthorId, x => "Username123")); + )).ReturnsAsync(Notifications.ToDictionary(x => x.AuthorId, x => "Username123")); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAllNotificationsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidReceiverId, - Sorting: this.query.Sorting - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -73,19 +71,14 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldSendRequests() { // Arrange - GetAllNotificationsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidReceiverId, - Sorting: this.query.Sorting - ); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert sender.Verify( x => x.SendQueryAsync( - It.Is(x => x.Ids.Length == notifications.Length), + It.Is(x => x.Ids.Length == Notifications.Length), ct ), Times.Once() @@ -96,19 +89,14 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldReturnResult() { // Arrange - GetAllNotificationsQuery query = new( - Pagination: this.query.Pagination, - CallerId: ValidReceiverId, - Sorting: this.query.Sorting - ); // Act - Result result = await handler.Handle(query, ct); + Result res = await handler.Handle(request, ct); // Assert Assert.Multiple( - () => Assert.Equal(result.Items.Select(r => r.Id), this.result.Items.Select(r => r.Id)), - () => Assert.Equal(result.Count, this.result.Count) + () => Assert.Equal(res.Items.Select(r => r.Id), Result.Items.Select(r => r.Id)), + () => Assert.Equal(res.Count, Result.Count) ); } } diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/Tests.cs index d23961047..f1cfed8f3 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetSortings/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Queries.I public class Tests : Data.Notifications.BaseUnitTests { private readonly GetNotificationSortingsHandler handler = new(); + private readonly GetNotificationSortingsQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetNotificationSortingsQuery query = new(); // Act - NotificationSortingType[] sortings = await handler.Handle(query, ct); + NotificationSortingType[] sortings = await handler.Handle(request, ct); // Assert Assert.Equal(sortings, Enum.GetValues()); diff --git a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/Tests.cs b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/Tests.cs index 3b38f97c2..834dfe197 100644 --- a/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/Tests.cs +++ b/tests/UnitTests/Notifications/Application/Notifications/Queries/Internal/GetStatuses/Tests.cs @@ -6,15 +6,15 @@ namespace CustomCADs.UnitTests.Notifications.Application.Notifications.Queries.I public class Tests : Data.Notifications.BaseUnitTests { private readonly GetNotificationStatusesHandler handler = new(); + private readonly GetNotificationStatusesQuery request = new(); [Fact] public async Task Handle_ShouldReturnResult() { // Arrange - GetNotificationStatusesQuery query = new(); // Act - NotificationStatus[] statuses = await handler.Handle(query, ct); + NotificationStatus[] statuses = await handler.Handle(request, ct); // Assert Assert.Equal(statuses, Enum.GetValues()); diff --git a/tests/UnitTests/Notifications/Data/Notifications/BaseUnitTests.cs b/tests/UnitTests/Notifications/Data/Notifications/BaseUnitTests.cs index 617a685f0..f7f2780c5 100644 --- a/tests/UnitTests/Notifications/Data/Notifications/BaseUnitTests.cs +++ b/tests/UnitTests/Notifications/Data/Notifications/BaseUnitTests.cs @@ -1,4 +1,5 @@ using CustomCADs.Modules.Notifications.Domain.Notifications; +using CustomCADs.Shared.Domain.Exceptions; using CustomCADs.Shared.Domain.TypedIds.Accounts; using CustomCADs.Shared.Domain.TypedIds.Notifications; @@ -10,6 +11,9 @@ public class BaseUnitTests { public static readonly CancellationToken ct = CancellationToken.None; + protected static readonly Func> ExpectValidationException + = Xunit.Assert.Throws>; + public static Notification CreateNotification( string? type = null, string? description = null, diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Hide/Tests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Hide/Tests.cs index b3ca8f1bc..66dfee866 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Hide/Tests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Hide/Tests.cs @@ -4,9 +4,6 @@ namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Stat public class Tests : Data.Notifications.BaseUnitTests { - private static readonly Func> expectValidationException - = Assert.Throws>; - [Fact] public void Hide_ShouldSucceed_WhenUnread() { @@ -43,13 +40,13 @@ public void Hide_ShouldSucceed_WhenOpened() [Fact] public void Hide_ShouldFail_WhenHidden() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Read(); notification.Hide(); notification.Hide(); - })); + }); } } diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Open/Tests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Open/Tests.cs index 2201ce474..16ce81ec8 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Open/Tests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Open/Tests.cs @@ -4,9 +4,6 @@ namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Stat public class Tests : Data.Notifications.BaseUnitTests { - private static readonly Func> expectValidationException - = Assert.Throws>; - [Fact] public void Open_ShouldSucceed_WhenRead() { @@ -21,37 +18,37 @@ public void Open_ShouldSucceed_WhenRead() [Fact] public void Open_ShouldFail_WhenUnread() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Open(); - })); + }); } [Fact] public void Open_ShouldFail_WhenOpened() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Read(); notification.Open(); notification.Open(); - })); + }); } [Fact] public void Open_ShouldFail_WhenHidden() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Read(); notification.Hide(); notification.Open(); - })); + }); } } diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Read/Tests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Read/Tests.cs index f1b197e02..5794d4dec 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Read/Tests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Read/Tests.cs @@ -4,9 +4,6 @@ namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Stat public class Tests : Data.Notifications.BaseUnitTests { - private static readonly Func> expectValidationException - = Assert.Throws>; - [Fact] public void Read_ShouldSucceed_WhenUnread() { @@ -18,38 +15,38 @@ public void Read_ShouldSucceed_WhenUnread() [Fact] public void Read_ShouldFail_WhenRead() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Read(); notification.Read(); - })); + }); } [Fact] public void Read_ShouldFail_WhenOpened() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Read(); notification.Open(); notification.Read(); - })); + }); } [Fact] public void Read_ShouldFail_WhenHidden() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Read(); notification.Hide(); notification.Read(); - })); + }); } } diff --git a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Unhide/Tests.cs b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Unhide/Tests.cs index 06ebeddc4..37c403006 100644 --- a/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Unhide/Tests.cs +++ b/tests/UnitTests/Notifications/Domain/Notifications/Behaviors/Statuses/Unhide/Tests.cs @@ -4,9 +4,6 @@ namespace CustomCADs.UnitTests.Notifications.Domain.Notifications.Behaviors.Stat public class Tests : Data.Notifications.BaseUnitTests { - private static readonly Func> expectValidationException - = Assert.Throws>; - [Fact] public void Hide_ShouldSucceed_WhenHidden() { @@ -22,36 +19,36 @@ public void Hide_ShouldSucceed_WhenHidden() [Fact] public void Hide_ShouldFail_WhenUnread() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Unhide(); - })); + }); } [Fact] public void Hide_ShouldFail_WhenRead() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Read(); notification.Unhide(); - })); + }); } [Fact] public void Hide_ShouldFail_WhenOpened() { - expectValidationException((Action)(() => + ExpectValidationException(() => { - Notification notification = Data.Notifications.BaseUnitTests.CreateNotification(); + Notification notification = CreateNotification(); notification.Read(); notification.Open(); notification.Unhide(); - })); + }); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs index 6dd3dd7d5..f38c380b9 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Create/Tests.cs @@ -9,6 +9,14 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Commands.Inte public class Tests : Data.Customizations.BaseUnitTests { private readonly CreateCustomizationHandler handler; + private readonly CreateCustomizationCommand request = new( + Scale: MaxValidScale, + Infill: MaxValidInfill, + Volume: MaxValidVolume, + Color: ValidColor, + MaterialId: ValidMaterialId + ); + private readonly Mock> writes = new(); private readonly Mock uow = new(); @@ -32,16 +40,9 @@ public Tests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateCustomizationCommand command = new( - Scale: MaxValidScale, - Infill: MaxValidInfill, - Volume: MaxValidVolume, - Color: ValidColor, - MaterialId: ValidMaterialId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -67,16 +68,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - CreateCustomizationCommand command = new( - Scale: MaxValidScale, - Infill: MaxValidInfill, - Volume: MaxValidVolume, - Color: ValidColor, - MaterialId: ValidMaterialId - ); // Act - CustomizationId id = await handler.Handle(command, ct); + CustomizationId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs index dbba9a6b1..0f9d240e6 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Delete/Tests.cs @@ -12,6 +12,8 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Commands.Inte public class Tests : Data.Customizations.BaseUnitTests { private readonly DeleteCustomizationHandler handler; + private readonly DeleteCustomizationByIdCommand request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); @@ -30,10 +32,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DeleteCustomizationByIdCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -46,10 +47,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DeleteCustomizationByIdCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -67,12 +67,11 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Customization); - DeleteCustomizationByIdCommand command = new(ValidId); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs index 55bc3cc2b..b2ce736f6 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Commands/Internal/Edit/Tests.cs @@ -11,6 +11,15 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Commands.Inte public class Tests : Data.Customizations.BaseUnitTests { private readonly EditCustomizationHandler handler; + private readonly EditCustomizationCommand request = new( + Id: ValidId, + Scale: MaxValidScale, + Infill: MaxValidInfill, + Volume: MaxValidVolume, + Color: ValidColor, + MaterialId: ValidMaterialId + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); @@ -28,17 +37,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - EditCustomizationCommand command = new( - Id: ValidId, - Scale: MaxValidScale, - Infill: MaxValidInfill, - Volume: MaxValidVolume, - Color: ValidColor, - MaterialId: ValidMaterialId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -51,17 +52,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - EditCustomizationCommand command = new( - Id: ValidId, - Scale: MaxValidScale, - Infill: MaxValidInfill, - Volume: MaxValidVolume, - Color: ValidColor, - MaterialId: ValidMaterialId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -75,19 +68,11 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() { // Arrange reads.Setup(x => x.SingleByIdAsync(ValidId, true, ct)).ReturnsAsync(null as Customization); - EditCustomizationCommand command = new( - Id: ValidId, - Scale: MaxValidScale, - Infill: MaxValidInfill, - Volume: MaxValidVolume, - Color: ValidColor, - MaterialId: ValidMaterialId - ); // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(command, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs index 71d0eb97c..31222acbe 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Internal/GetById/Tests.cs @@ -12,6 +12,8 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Inter public class Tests : Data.Customizations.BaseUnitTests { private readonly GetCustomizationByIdHandler handler; + private readonly GetCustomizationByIdQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock materialReads = new(); private readonly Mock calculator = new(); @@ -34,10 +36,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetCustomizationByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -54,10 +55,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldCalculateWeightAndCost() { // Arrange - GetCustomizationByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert calculator.Verify( @@ -74,10 +74,9 @@ public async Task Handle_ShouldCalculateWeightAndCost() public async Task Handle_ShouldReturnResult() { // Arrange - GetCustomizationByIdQuery query = new(ValidId); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, result.Id); @@ -90,12 +89,10 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Customization); - GetCustomizationByIdQuery query = new(ValidId); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } @@ -106,12 +103,10 @@ public async Task Handle_ShouldThrowException_WhenMaterialNotFound() materialReads.Setup(x => x.SingleByIdAsync(ValidMaterialId, false, ct)) .ReturnsAsync(null as Material); - GetCustomizationByIdQuery query = new(ValidId); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs index 1dc27b85c..9585d936e 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Batch/Tests.cs @@ -12,15 +12,17 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Share public class Tests : Data.Customizations.BaseUnitTests { private readonly BatchGetCustomizationCostByIdHandler handler; + private readonly BatchGetCustomizationCostByIdQuery request = new(Ids); + private readonly Mock reads = new(); private readonly Mock materialReads = new(); private readonly Mock calculator = new(); private const decimal Cost = 10.5m; - private static readonly CustomizationId[] ids = []; - private static readonly Customization[] customizations = [CreateCustomization()]; - private static readonly MaterialId[] materialIds = [.. customizations.Select(x => x.MaterialId)]; - private static readonly Dictionary materials = new() + private static readonly CustomizationId[] Ids = []; + private static readonly Customization[] Customizations = [CreateCustomization()]; + private static readonly MaterialId[] MaterialIds = [.. Customizations.Select(x => x.MaterialId)]; + private static readonly Dictionary Materials = new() { [ValidMaterialId] = CreateMaterial(), }; @@ -29,11 +31,11 @@ public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); - reads.Setup(x => x.AllAsync(ids, false, ct)) - .ReturnsAsync(customizations); + reads.Setup(x => x.AllAsync(Ids, false, ct)) + .ReturnsAsync(Customizations); - materialReads.Setup(x => x.AllByIdsAsync(materialIds, false, ct)) - .ReturnsAsync(materials); + materialReads.Setup(x => x.AllByIdsAsync(MaterialIds, false, ct)) + .ReturnsAsync(Materials); calculator.Setup(x => x.CalculateCost(It.IsAny(), It.IsAny())) .Returns(Cost); @@ -43,18 +45,17 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - BatchGetCustomizationCostByIdQuery query = new(ids); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(ids, false, ct), + x => x.AllAsync(Ids, false, ct), Times.Once() ); materialReads.Verify( - x => x.AllByIdsAsync(materialIds, false, ct), + x => x.AllByIdsAsync(MaterialIds, false, ct), Times.Once() ); } @@ -63,18 +64,17 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldCalculateCost() { // Arrange - BatchGetCustomizationCostByIdQuery query = new(ids); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert calculator.Verify( x => x.CalculateCost( - It.Is(x => customizations.Contains(x)), - It.Is(x => materials.Values.Contains(x)) + It.Is(x => Customizations.Contains(x)), + It.Is(x => Materials.Values.Contains(x)) ), - Times.Exactly(customizations.Length) + Times.Exactly(Customizations.Length) ); } @@ -82,10 +82,9 @@ public async Task Handle_ShouldCalculateCost() public async Task Handle_ShouldReturnResult() { // Arrange - BatchGetCustomizationCostByIdQuery query = new(ids); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Multiple([.. result.Select( diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs index 1d07514c6..65ecd4b04 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Cost/Single/Tests.cs @@ -13,6 +13,8 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Share public class Tests : Data.Customizations.BaseUnitTests { private readonly GetCustomizationCostByIdHandler handler; + private readonly GetCustomizationCostByIdQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock materialReads = new(); private readonly Mock calculator = new(); @@ -39,10 +41,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetCustomizationCostByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -59,10 +60,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldCalculateCost() { // Arrange - GetCustomizationCostByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert calculator.Verify( @@ -75,10 +75,9 @@ public async Task Handle_ShouldCalculateCost() public async Task Handle_ShouldReturnResult() { // Arrange - GetCustomizationCostByIdQuery query = new(ValidId); // Act - decimal result = await handler.Handle(query, ct); + decimal result = await handler.Handle(request, ct); // Assert Assert.Equal(Cost, result); @@ -91,12 +90,10 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Customization); - GetCustomizationCostByIdQuery query = new(ValidId); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } @@ -107,12 +104,10 @@ public async Task Handle_ShouldThrowException_WhenMaterialNotFound() materialReads.Setup(x => x.SingleByIdAsync(ValidMaterialId, false, ct)) .ReturnsAsync(null as Material); - GetCustomizationCostByIdQuery query = new(ValidId); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs index 3366ed0a1..52e4b9fcc 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Exists/Tests.cs @@ -9,6 +9,8 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Share public class Tests : Data.Customizations.BaseUnitTests { private readonly GetCustomizationExistsByIdHandler handler; + private readonly GetCustomizationExistsByIdQuery request = new(ValidId); + private readonly Mock reads = new(); public Tests() @@ -23,10 +25,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetCustomizationExistsByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -43,10 +44,9 @@ public async Task Handle_ShouldReturnResult(bool exists) // Arrange reads.Setup(x => x.ExistsByIdAsync(ValidId, ct)) .ReturnsAsync(exists); - GetCustomizationExistsByIdQuery query = new(ValidId); // Act - bool result = await handler.Handle(query, ct); + bool result = await handler.Handle(request, ct); // Assert Assert.Equal(exists, result); diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs index d08619007..eb3dc6ee9 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Batch/Tests.cs @@ -12,15 +12,17 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Share public class Tests : Data.Customizations.BaseUnitTests { private readonly BatchGetCustomizationWeightByIdHandler handler; + private readonly BatchGetCustomizationWeightByIdQuery request = new(Ids); + private readonly Mock reads = new(); private readonly Mock materialReads = new(); private readonly Mock calculator = new(); private const double Weight = 10.5; - private static readonly CustomizationId[] ids = []; - private static readonly Customization[] customizations = [CreateCustomization()]; - private static readonly MaterialId[] materialIds = [.. customizations.Select(x => x.MaterialId)]; - private static readonly Dictionary materials = new() + private static readonly CustomizationId[] Ids = []; + private static readonly Customization[] Customizations = [CreateCustomization()]; + private static readonly MaterialId[] MaterialIds = [.. Customizations.Select(x => x.MaterialId)]; + private static readonly Dictionary Materials = new() { [ValidMaterialId] = CreateMaterial(), }; @@ -29,11 +31,11 @@ public Tests() { handler = new(reads.Object, materialReads.Object, calculator.Object); - reads.Setup(x => x.AllAsync(ids, false, ct)) - .ReturnsAsync(customizations); + reads.Setup(x => x.AllAsync(Ids, false, ct)) + .ReturnsAsync(Customizations); - materialReads.Setup(x => x.AllByIdsAsync(materialIds, false, ct)) - .ReturnsAsync(materials); + materialReads.Setup(x => x.AllByIdsAsync(MaterialIds, false, ct)) + .ReturnsAsync(Materials); calculator.Setup(x => x.CalculateWeight(It.IsAny(), It.IsAny())) .Returns((decimal)Weight); @@ -43,18 +45,17 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - BatchGetCustomizationWeightByIdQuery query = new(ids); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( - x => x.AllAsync(ids, false, ct), + x => x.AllAsync(Ids, false, ct), Times.Once() ); materialReads.Verify( - x => x.AllByIdsAsync(materialIds, false, ct), + x => x.AllByIdsAsync(MaterialIds, false, ct), Times.Once() ); } @@ -63,18 +64,17 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldCalculateWeight() { // Arrange - BatchGetCustomizationWeightByIdQuery query = new(ids); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert calculator.Verify( x => x.CalculateWeight( - It.Is(x => customizations.Contains(x)), - It.Is(x => materials.Values.Contains(x)) + It.Is(x => Customizations.Contains(x)), + It.Is(x => Materials.Values.Contains(x)) ), - Times.Exactly(customizations.Length) + Times.Exactly(Customizations.Length) ); } @@ -82,10 +82,9 @@ public async Task Handle_ShouldCalculateWeight() public async Task Handle_ShouldReturnResult() { // Arrange - BatchGetCustomizationWeightByIdQuery query = new(ids); // Act - var result = await handler.Handle(query, ct); + var result = await handler.Handle(request, ct); // Assert Assert.Multiple([.. result.Select( diff --git a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs index ecf54c674..8702b267c 100644 --- a/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs +++ b/tests/UnitTests/Printing/Application/Customizations/Queries/Shared/Weight/Single/Tests.cs @@ -13,6 +13,8 @@ namespace CustomCADs.UnitTests.Printing.Application.Customizations.Queries.Share public class Tests : Data.Customizations.BaseUnitTests { private readonly GetCustomizationWeightByIdHandler handler; + private readonly GetCustomizationWeightByIdQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock materialReads = new(); private readonly Mock calculator = new(); @@ -39,10 +41,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetCustomizationWeightByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -59,10 +60,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldCalculateWeight() { // Arrange - GetCustomizationWeightByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert calculator.Verify( @@ -75,10 +75,9 @@ public async Task Handle_ShouldCalculateWeight() public async Task Handle_ShouldReturnResult() { // Arrange - GetCustomizationWeightByIdQuery query = new(ValidId); // Act - double result = await handler.Handle(query, ct); + double result = await handler.Handle(request, ct); // Assert Assert.Equal(Weight, result); @@ -91,12 +90,10 @@ public async Task Handle_ShouldThrowException_WhenCustomizationNotFound() reads.Setup(x => x.SingleByIdAsync(ValidId, false, ct)) .ReturnsAsync(null as Customization); - GetCustomizationWeightByIdQuery query = new(ValidId); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } @@ -107,12 +104,10 @@ public async Task Handle_ShouldThrowException_WhenMaterialNotFound() materialReads.Setup(x => x.SingleByIdAsync(ValidMaterialId, false, ct)) .ReturnsAsync(null as Material); - GetCustomizationWeightByIdQuery query = new(ValidId); - // Assert await Assert.ThrowsAsync>( // Act - () => handler.Handle(query, ct) + () => handler.Handle(request, ct) ); } } diff --git a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs index 7a5316a5b..725139157 100644 --- a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Create/Tests.cs @@ -12,6 +12,13 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Commands.Internal. public class Tests : Data.Materials.BaseUnitTests { private readonly CreateMaterialHandler handler; + private readonly CreateMaterialCommand request = new( + Name: MaxValidName, + Density: MaxValidDensity, + Cost: MaxValidCost, + TextureId: ValidTextureId + ); + private readonly Mock> writes = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -36,15 +43,9 @@ public Tests() public async Task Handle_ShouldSendRequests() { // Arrange - CreateMaterialCommand command = new( - Name: MaxValidName, - Density: MaxValidDensity, - Cost: MaxValidCost, - TextureId: ValidTextureId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert sender.Verify( @@ -60,15 +61,9 @@ public async Task Handle_ShouldSendRequests() public async Task Handle_ShouldPersistToDatabase() { // Arrange - CreateMaterialCommand command = new( - Name: MaxValidName, - Density: MaxValidDensity, - Cost: MaxValidCost, - TextureId: ValidTextureId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -85,15 +80,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - CreateMaterialCommand command = new( - Name: MaxValidName, - Density: MaxValidDensity, - Cost: MaxValidCost, - TextureId: ValidTextureId - ); // Act - MaterialId id = await handler.Handle(command, ct); + MaterialId id = await handler.Handle(request, ct); // Assert Assert.Equal(ValidId, id); @@ -103,15 +92,9 @@ public async Task Handle_ShouldReturnResult() public async Task Handle_ShouldUpdateCache() { // Arrange - CreateMaterialCommand command = new( - Name: MaxValidName, - Density: MaxValidDensity, - Cost: MaxValidCost, - TextureId: ValidTextureId - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( diff --git a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs index 2a93ee077..db045d01c 100644 --- a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Delete/Tests.cs @@ -11,6 +11,8 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Commands.Internal. public class Tests : Data.Materials.BaseUnitTests { private readonly DeleteMaterialHandler handler; + private readonly DeleteMaterialCommand request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock> writes = new(); private readonly Mock uow = new(); @@ -29,10 +31,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - DeleteMaterialCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -45,10 +46,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - DeleteMaterialCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert writes.Verify( @@ -65,10 +65,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldClearCache() { // Arrange - DeleteMaterialCommand command = new(ValidId); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( diff --git a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs index f24a453a8..78820d857 100644 --- a/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Commands/Internal/Edit/Tests.cs @@ -11,6 +11,13 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Commands.Internal. public class Tests : Data.Materials.BaseUnitTests { private readonly EditMaterialHandler handler; + private readonly EditMaterialCommand request = new( + Id: ValidId, + Name: MaxValidName, + Density: MaxValidDensity, + Cost: MaxValidCost + ); + private readonly Mock reads = new(); private readonly Mock uow = new(); private readonly Mock> cache = new(); @@ -28,15 +35,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - EditMaterialCommand command = new( - Id: ValidId, - Name: MaxValidName, - Density: MaxValidDensity, - Cost: MaxValidCost - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert reads.Verify( @@ -49,15 +50,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldPersistToDatabase() { // Arrange - EditMaterialCommand command = new( - Id: ValidId, - Name: MaxValidName, - Density: MaxValidDensity, - Cost: MaxValidCost - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert uow.Verify( @@ -70,15 +65,9 @@ public async Task Handle_ShouldPersistToDatabase() public async Task Handle_ShouldUpdateCache() { // Arrange - EditMaterialCommand command = new( - Id: ValidId, - Name: MaxValidName, - Density: MaxValidDensity, - Cost: MaxValidCost - ); // Act - await handler.Handle(command, ct); + await handler.Handle(request, ct); // Assert cache.Verify( diff --git a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs index 33ad6cd84..8b9dec21a 100644 --- a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetAll/Tests.cs @@ -9,10 +9,12 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Queries.Internal.G public class Tests : Data.Materials.BaseUnitTests { private readonly GetAllMaterialsHandler handler; + private readonly GetAllMaterialsQuery request = new(); + private readonly Mock reads = new(); private readonly Mock> cache = new(); - private static readonly ICollection materials = [ + private static readonly ICollection Materials = [ CreateMaterial(), CreateMaterial(), CreateMaterial(), @@ -23,17 +25,16 @@ public Tests() handler = new(reads.Object, cache.Object); cache.Setup(x => x.GetOrCreateAsync(It.IsAny>>>())) - .ReturnsAsync(materials); + .ReturnsAsync(Materials); } [Fact] public async Task Handle_ShouldQueryDatabase() { // Arrange - GetAllMaterialsQuery query = new(); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -46,12 +47,11 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetAllMaterialsQuery query = new(); // Act - ICollection response = await handler.Handle(query, ct); + ICollection response = await handler.Handle(request, ct); // Assert - Assert.Equal(materials.Count, response.Count); + Assert.Equal(Materials.Count, response.Count); } } diff --git a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs index 6ee247a07..0618eb12a 100644 --- a/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs +++ b/tests/UnitTests/Printing/Application/Materials/Queries/Internal/GetById/Tests.cs @@ -11,10 +11,12 @@ namespace CustomCADs.UnitTests.Printing.Application.Materials.Queries.Internal.G public class Tests : Data.Materials.BaseUnitTests { private readonly GetMaterialByIdHandler handler; + private readonly GetMaterialByIdQuery request = new(ValidId); + private readonly Mock reads = new(); private readonly Mock> cache = new(); - private static readonly Material material = CreateMaterial(); + private readonly Material material = CreateMaterial(); public Tests() { @@ -28,10 +30,9 @@ public Tests() public async Task Handle_ShouldQueryDatabase() { // Arrange - GetMaterialByIdQuery query = new(ValidId); // Act - await handler.Handle(query, ct); + await handler.Handle(request, ct); // Assert cache.Verify( @@ -44,10 +45,9 @@ public async Task Handle_ShouldQueryDatabase() public async Task Handle_ShouldReturnResult() { // Arrange - GetMaterialByIdQuery query = new(ValidId); // Act - MaterialDto response = await handler.Handle(query, ct); + MaterialDto response = await handler.Handle(request, ct); // Assert Assert.Equal(material.Id, response.Id); diff --git a/tests/UnitTests/Printing/Data/Customizations/BaseUnitTests.cs b/tests/UnitTests/Printing/Data/Customizations/BaseUnitTests.cs index dd797feea..9edca5e74 100644 --- a/tests/UnitTests/Printing/Data/Customizations/BaseUnitTests.cs +++ b/tests/UnitTests/Printing/Data/Customizations/BaseUnitTests.cs @@ -33,5 +33,5 @@ protected static Material CreateMaterial( decimal? cost = null, ImageId? textureId = null, MaterialId? id = null - ) => Data.Materials.BaseUnitTests.CreateMaterial(id, name, density, cost, textureId); + ) => Materials.BaseUnitTests.CreateMaterial(id, name, density, cost, textureId); } From 40cb474eee4b4648e0cfc00291643b9fd5a5c150 Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Thu, 28 May 2026 20:13:08 +0300 Subject: [PATCH 10/15] Shaved off redundant dependencies from SDK --- sdk/js/react/package-lock.json | 39 ++++++++++------------------------ sdk/js/react/package.json | 10 ++++----- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/sdk/js/react/package-lock.json b/sdk/js/react/package-lock.json index 1c601f4df..a8970a046 100644 --- a/sdk/js/react/package-lock.json +++ b/sdk/js/react/package-lock.json @@ -9,13 +9,11 @@ "version": "1.0.0", "dependencies": { "@tanstack/react-query": "^5.100.10", - "axios": "^1.16.0", - "prettier": "^3.8.3", - "react": "^19.2.6", - "uuid": "^14.0.0" + "axios": "^1.16.0" }, "devDependencies": { - "@types/react": "^19.2.2", + "@types/react": "^19.2.15", + "prettier": "^3.8.3", "tsc-alias": "^1.8.16", "typescript": "^5.9.3", "vite-tsconfig-paths": "^5.1.4", @@ -876,13 +874,13 @@ "license": "MIT" }, "node_modules/@types/react": { - "version": "19.2.2", - "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.2.tgz", - "integrity": "sha512-6mDvHUFSjyT2B2yeNx2nUgMxh9LtOWvkhIU3uePn2I2oyNymUAX1NIsdgviM4CH+JSrp2D2hsMvJOkxY+0wNRA==", + "version": "19.2.15", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.15.tgz", + "integrity": "sha512-eRwcGNHve+E8qtEQSSRl6urh+rFop4v8gm6O8rGv25CodbvFdLjA1vVQ1KkiFE0w0UPOnb8tDiFKL5lp0rtY5Q==", "dev": true, "license": "MIT", "dependencies": { - "csstype": "^3.0.2" + "csstype": "^3.2.2" } }, "node_modules/@vitest/expect": { @@ -1157,9 +1155,9 @@ } }, "node_modules/csstype": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.1.3.tgz", - "integrity": "sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==", + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", "dev": true, "license": "MIT" }, @@ -1804,7 +1802,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -1858,6 +1855,7 @@ "version": "3.8.3", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz", "integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==", + "dev": true, "license": "MIT", "bin": { "prettier": "bin/prettier.cjs" @@ -2176,7 +2174,6 @@ "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", "dev": true, "license": "Apache-2.0", - "peer": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -2185,26 +2182,12 @@ "node": ">=14.17" } }, - "node_modules/uuid": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.0.tgz", - "integrity": "sha512-Qo+uWgilfSmAhXCMav1uYFynlQO7fMFiMVZsQqZRMIXp0O7rR7qjkj+cPvBHLgBqi960QCoo/PH2/6ZtVqKvrg==", - "funding": [ - "https://github.com/sponsors/broofa", - "https://github.com/sponsors/ctavan" - ], - "license": "MIT", - "bin": { - "uuid": "dist-node/bin/uuid" - } - }, "node_modules/vite": { "version": "7.1.12", "resolved": "https://registry.npmjs.org/vite/-/vite-7.1.12.tgz", "integrity": "sha512-ZWyE8YXEXqJrrSLvYgrRP7p62OziLW7xI5HYGWFzOvupfAlrLvURSzv/FyGyy0eidogEM3ujU+kUG1zuHgb6Ug==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "esbuild": "^0.25.0", "fdir": "^6.5.0", diff --git a/sdk/js/react/package.json b/sdk/js/react/package.json index 1c813ce76..3deefc977 100644 --- a/sdk/js/react/package.json +++ b/sdk/js/react/package.json @@ -10,18 +10,16 @@ "scripts": { "build": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json", "test": "vitest run", - "test:watch": "vitest", + "test:watch": "vitest watch", "format": "prettier --write ." }, "dependencies": { "@tanstack/react-query": "^5.100.10", - "axios": "^1.16.0", - "prettier": "^3.8.3", - "react": "^19.2.6", - "uuid": "^14.0.0" + "axios": "^1.16.0" }, "devDependencies": { - "@types/react": "^19.2.2", + "@types/react": "^19.2.15", + "prettier": "^3.8.3", "tsc-alias": "^1.8.16", "typescript": "^5.9.3", "vite-tsconfig-paths": "^5.1.4", From de8c6a0965f3d2514bb28f673e2c4e05cd25bdad Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Thu, 28 May 2026 23:28:18 +0300 Subject: [PATCH 11/15] Improved Quartz DI configs --- .../Infrastructure/DependencyInjection.cs | 11 +++---- .../Infrastructure/DependencyInjection.cs | 11 +++---- .../Infrastructure/DependencyInjection.cs | 11 +++---- .../Infrastructure/DependencyInjection.cs | 31 ++++++++++-------- .../Infrastructure/DependencyInjection.cs | 32 +++++++++++-------- 5 files changed, 48 insertions(+), 48 deletions(-) diff --git a/src/Modules/Catalog/Infrastructure/DependencyInjection.cs b/src/Modules/Catalog/Infrastructure/DependencyInjection.cs index 5f7742137..d26e44fae 100644 --- a/src/Modules/Catalog/Infrastructure/DependencyInjection.cs +++ b/src/Modules/Catalog/Infrastructure/DependencyInjection.cs @@ -12,13 +12,10 @@ public static class DependencyInjection extension(IServiceCollectionQuartzConfigurator configurator) { public void AddCatalogBackgroundJobs() - => configurator.AddTrigger(conf => conf - .ForJob(configurator.AddJobAndReturnKey()) - .WithSimpleSchedule(schedule => - schedule - .WithInterval(TimeSpan.FromDays(ClearTagsIntervalDays)) - .RepeatForever() - ) + => configurator.ScheduleJob( + schedule => schedule + .WithInterval(TimeSpan.FromDays(ClearTagsIntervalDays)) + .RepeatForever() ); } } diff --git a/src/Modules/Delivery/Infrastructure/DependencyInjection.cs b/src/Modules/Delivery/Infrastructure/DependencyInjection.cs index e4e99e1ef..44e5a79a5 100644 --- a/src/Modules/Delivery/Infrastructure/DependencyInjection.cs +++ b/src/Modules/Delivery/Infrastructure/DependencyInjection.cs @@ -43,13 +43,10 @@ public void AddDeliveryService() extension(IServiceCollectionQuartzConfigurator configurator) { public void AddDeliveryBackgroundJobs() - => configurator.AddTrigger(conf => conf - .ForJob(configurator.AddJobAndReturnKey()) - .WithSimpleSchedule(schedule => - schedule - .WithInterval(TimeSpan.FromHours(PollShipmentStatusJob.IntervalHours)) - .RepeatForever() - ) + => configurator.ScheduleJob( + schedule => schedule + .WithInterval(TimeSpan.FromHours(PollShipmentStatusJob.IntervalHours)) + .RepeatForever() ); } diff --git a/src/Modules/Idempotency/Infrastructure/DependencyInjection.cs b/src/Modules/Idempotency/Infrastructure/DependencyInjection.cs index 7b91e9ccc..407d3c15d 100644 --- a/src/Modules/Idempotency/Infrastructure/DependencyInjection.cs +++ b/src/Modules/Idempotency/Infrastructure/DependencyInjection.cs @@ -12,13 +12,10 @@ public static class DependencyInjection extension(IServiceCollectionQuartzConfigurator configurator) { public void AddIdempotencyBackgroundJobs() - => configurator.AddTrigger(conf => conf - .ForJob(configurator.AddJobAndReturnKey()) - .WithSimpleSchedule(schedule => - schedule - .WithInterval(TimeSpan.FromHours(ClearIdempotencyKeysIntervalHours)) - .RepeatForever() - ) + => configurator.ScheduleJob( + schedule => schedule + .WithInterval(TimeSpan.FromHours(ClearIdempotencyKeysIntervalHours)) + .RepeatForever() ); } diff --git a/src/Modules/Identity/Infrastructure/DependencyInjection.cs b/src/Modules/Identity/Infrastructure/DependencyInjection.cs index 1753d329f..2e12fd4c0 100644 --- a/src/Modules/Identity/Infrastructure/DependencyInjection.cs +++ b/src/Modules/Identity/Infrastructure/DependencyInjection.cs @@ -59,24 +59,29 @@ private IServiceCollection AddContext(string connectionString) { public void AddIdentityBackgroundJobs() { - configurator.AddTrigger(conf => conf - .ForJob(configurator.AddJobAndReturnKey()) - .WithSimpleSchedule(schedule => - schedule - .WithInterval(TimeSpan.FromDays(ClearRefreshTokensJob.IntervalDays)) - .RepeatForever() - )); + configurator.ScheduleJob( + schedule => schedule + .WithInterval(TimeSpan.FromDays(ClearRefreshTokensJob.IntervalDays)) + .RepeatForever() + ); } } - extension(IServiceCollectionQuartzConfigurator q) + extension(IServiceCollectionQuartzConfigurator configurator) { - private JobKey AddJobAndReturnKey(string? name = null) - where TJob : IJob + public void ScheduleJob(IScheduleBuilder schedule, string? name = null) where TJob : IJob + { + configurator.ScheduleJob( + trigger => trigger.WithSchedule(schedule), + job => job.WithIdentity(name ?? typeof(TJob).Name) + ); + } + + public void ScheduleJob(Action schedule, string? name = null) where TJob : IJob { - JobKey key = new(name ?? typeof(TJob).Name); - q.AddJob(conf => conf.WithIdentity(key)); - return key; + var builder = SimpleScheduleBuilder.Create(); + schedule(builder); + ScheduleJob(configurator, builder, name); } } diff --git a/src/Shared/Infrastructure/DependencyInjection.cs b/src/Shared/Infrastructure/DependencyInjection.cs index 3beb0500c..22d5c6839 100644 --- a/src/Shared/Infrastructure/DependencyInjection.cs +++ b/src/Shared/Infrastructure/DependencyInjection.cs @@ -113,26 +113,30 @@ public void AddCurrenciesService() { public void AddSharedBackgroundJobs() { - TimeZoneInfo cet = TimeZoneInfo.FindSystemTimeZoneById( - id: RuntimeInformation.IsOSPlatform(OSPlatform.Windows) + string cet = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Central European Standard Time" - : "Europe/Berlin" + : "Europe/Berlin"; + + configurator.ScheduleJob( + schedule: CronScheduleBuilder + .DailyAtHourAndMinute(16, 30) + .InTimeZone(tz: TimeZoneInfo.FindSystemTimeZoneById(cet)) ); + } - configurator.AddTrigger(opts => opts - .ForJob(configurator.AddJobAndReturnKey()) - .WithSchedule( - CronScheduleBuilder - .DailyAtHourAndMinute(16, 30) - .InTimeZone(cet) - )); + public void ScheduleJob(IScheduleBuilder schedule, string? name = null) where TJob : IJob + { + configurator.ScheduleJob( + trigger => trigger.WithSchedule(schedule), + job => job.WithIdentity(name ?? typeof(TJob).Name) + ); } - public JobKey AddJobAndReturnKey(string? name = null) where TJob : IJob + public void ScheduleJob(Action schedule, string? name = null) where TJob : IJob { - JobKey key = new(name ?? typeof(TJob).Name); - configurator.AddJob(conf => conf.WithIdentity(key)); - return key; + var builder = SimpleScheduleBuilder.Create(); + schedule(builder); + ScheduleJob(configurator, builder, name); } } } From b9eb8cea0a990fb43e1e72cafa1632f4d218498b Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Thu, 28 May 2026 23:30:34 +0300 Subject: [PATCH 12/15] Updated NuGet packages --- Directory.Packages.props | 42 ++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index ce530bfea..af70a8b21 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -1,34 +1,34 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + - + - + - + - - - - - - + + + + + + - + @@ -36,23 +36,23 @@ - - - + + + - + - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + From 912cb08b2a1bfaff7b13158d3306a3903bbaebf6 Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Mon, 1 Jun 2026 00:31:38 +0300 Subject: [PATCH 13/15] Refactored Payment and Delivery service code style --- .../Infrastructure/SpeedyDeliveryService.cs | 6 +- src/Shared/Infrastructure/Payment/Messages.cs | 1 - .../Infrastructure/Payment/StripeService.cs | 155 ++++++++---------- 3 files changed, 68 insertions(+), 94 deletions(-) diff --git a/src/Modules/Delivery/Infrastructure/SpeedyDeliveryService.cs b/src/Modules/Delivery/Infrastructure/SpeedyDeliveryService.cs index 8f12e1f5b..f2aaa825b 100644 --- a/src/Modules/Delivery/Infrastructure/SpeedyDeliveryService.cs +++ b/src/Modules/Delivery/Infrastructure/SpeedyDeliveryService.cs @@ -11,14 +11,14 @@ namespace CustomCADs.Modules.Delivery.Infrastructure; internal sealed class SpeedyDeliveryService(ISpeedyClient speedy) : IDeliveryService { - private const Payer Payer = SpeedyNET.Core.Enums.Payer.RECIPIENT; + private const Payer DefaultPayer = Payer.RECIPIENT; private const PaperSize Paper = PaperSize.A4; private const int Count = 1; public async Task CalculateAsync(CalculateRequest req, CancellationToken ct = default) { CalculateModel[] response = await speedy.CalculateAsync( - payer: Payer, + payer: DefaultPayer, weights: req.Weights, country: req.Country, site: req.City, @@ -54,7 +54,7 @@ public async Task ShipAsync( ) { WrittenShipmentModel response = await speedy.CreateShipmentAsync( - payer: Payer, + payer: DefaultPayer, package: req.Package, contents: req.Contents, parcelCount: Count, diff --git a/src/Shared/Infrastructure/Payment/Messages.cs b/src/Shared/Infrastructure/Payment/Messages.cs index a3b857576..ebd2d758a 100644 --- a/src/Shared/Infrastructure/Payment/Messages.cs +++ b/src/Shared/Infrastructure/Payment/Messages.cs @@ -5,7 +5,6 @@ public static class Messages public const string SuccessfulPayment = "Payment was successful."; public const string CanceledPayment = "Payment was canceled. Please try again or use a different payment method."; public const string ProcessingPayment = "Payment is processing. Please wait for confirmation."; - public const string SuccessfulPaymentCapture = "Payment captured successfully."; public const string FailedPaymentCapture = "Failed to capture payment."; public const string FailedPaymentMethod = "Payment failed. Please try another payment method."; public const string FailedPayment = "Payment requires further action."; diff --git a/src/Shared/Infrastructure/Payment/StripeService.cs b/src/Shared/Infrastructure/Payment/StripeService.cs index 3b236dba9..e2a44232a 100644 --- a/src/Shared/Infrastructure/Payment/StripeService.cs +++ b/src/Shared/Infrastructure/Payment/StripeService.cs @@ -11,6 +11,31 @@ namespace CustomCADs.Shared.Infrastructure.Payment; public sealed class StripeService(PaymentIntentService service) : IPaymentService { + private static PaymentIntentCreateOptions CreateOptions( + decimal total, + (string MethodId, string BuyerId) payment, + (string Type, string Id) reward, + string description + ) + => new() + { + Amount = Convert.ToInt64(total * 100), + Currency = "EUR", + PaymentMethod = payment.MethodId, + Description = description, + Confirm = true, + AutomaticPaymentMethods = new() + { + Enabled = true, + AllowRedirects = "never" + }, + Metadata = new() + { + ["buyerId"] = payment.BuyerId, + ["rewardType"] = reward.Type, + ["rewardId"] = reward.Id, + }, + }; public async Task InitializeCartPayment( string paymentMethodId, @@ -19,58 +44,18 @@ public async Task InitializeCartPayment( decimal total, (string Buyer, int ItemsCount) description, CancellationToken ct = default - ) - { - PaymentIntent intent = await service.CreateAsync( - options: new() - { - Amount = Convert.ToInt64(total * 100), - Currency = "EUR", - PaymentMethod = paymentMethodId, - Confirm = true, - Description = $"{description.Buyer} bought {description.ItemsCount} items for a total of {total}€.", - AutomaticPaymentMethods = new() - { - Enabled = true, - AllowRedirects = "never" - }, - Metadata = new() - { - ["buyerId"] = buyerId.ToString(), - ["rewardType"] = "cart", - ["rewardId"] = cartId.ToString(), - }, - }, + ) => await HandleResponseAsync( + intent: await service.CreateAsync( + options: CreateOptions( + total: total, + payment: (MethodId: paymentMethodId, BuyerId: buyerId.ToString()), + reward: (Type: "cart", Id: cartId.ToString()), + description: $"{description.Buyer} bought {description.ItemsCount} items for a total of {total}€." + ), cancellationToken: ct - ).ConfigureAwait(false); - - PaymentDto response = new( - ClientSecret: intent.ClientSecret, - Message: GetMessageFromStatus(intent.Status) - ); - - switch (response.Message) - { - case FailedPaymentCapture: - intent = await service.CaptureAsync(intent.Id, cancellationToken: ct).ConfigureAwait(false); - string message = GetMessageFromStatus(intent.Status); - - if (message == SuccessfulPayment) - { - return response with { Message = SuccessfulPayment }; - } - throw PaymentFailedException.WithClientSecret(intent.ClientSecret, message); - - case ProcessingPayment: - return response; - - case SuccessfulPayment: - return response; - - default: - throw PaymentFailedException.General(response.Message); - } - } + ).ConfigureAwait(false), + ct + ).ConfigureAwait(false); public async Task InitializeCustomPayment( string paymentMethodId, @@ -79,31 +64,21 @@ public async Task InitializeCustomPayment( decimal total, (string Buyer, string Name, string Seller) description, CancellationToken ct = default - ) - { - PaymentIntent intent = await service.CreateAsync( - options: new() - { - Amount = Convert.ToInt64(total * 100), - Currency = "EUR", - PaymentMethod = paymentMethodId, - Confirm = true, - Description = $"{description.Buyer} bought {description.Name} from {description.Seller} for a total of {total}€.", - AutomaticPaymentMethods = new() - { - Enabled = true, - AllowRedirects = "never" - }, - Metadata = new() - { - ["buyerId"] = buyerId.ToString(), - ["rewardType"] = "custom", - ["rewardId"] = customId.ToString(), - }, - }, + ) => await HandleResponseAsync( + intent: await service.CreateAsync( + options: CreateOptions( + total: total, + payment: (MethodId: paymentMethodId, BuyerId: buyerId.ToString()), + reward: (Type: "custom", Id: customId.ToString()), + description: $"{description.Buyer} bought {description.Name} from {description.Seller} for a total of {total}€." + ), cancellationToken: ct - ).ConfigureAwait(false); + ).ConfigureAwait(false), + ct + ).ConfigureAwait(false); + private async Task HandleResponseAsync(PaymentIntent intent, CancellationToken ct) + { PaymentDto response = new( ClientSecret: intent.ClientSecret, Message: GetMessageFromStatus(intent.Status) @@ -113,13 +88,13 @@ public async Task InitializeCustomPayment( { case FailedPaymentCapture: intent = await service.CaptureAsync(intent.Id, cancellationToken: ct).ConfigureAwait(false); - string message = GetMessageFromStatus(intent.Status); + response = response with { Message = GetMessageFromStatus(intent.Status) }; - if (message == SuccessfulPayment) + if (response.Message == SuccessfulPayment) { - return response with { Message = SuccessfulPayment }; + return response; } - throw PaymentFailedException.WithClientSecret(intent.ClientSecret, message); + throw PaymentFailedException.WithClientSecret(intent.ClientSecret, response.Message); case ProcessingPayment: case SuccessfulPayment: @@ -128,17 +103,17 @@ public async Task InitializeCustomPayment( default: throw PaymentFailedException.General(response.Message); } - } - private static string GetMessageFromStatus(string status) - => status switch - { - "succeeded" => SuccessfulPayment, - "processing" => ProcessingPayment, - "canceled" => CanceledPayment, - "requires_payment_method" => FailedPaymentMethod, - "requires_action" => FailedPayment, - "requires_capture" => FailedPaymentCapture, - _ => string.Format(UnhandledPayment, status) - }; + static string GetMessageFromStatus(string status) + => status switch + { + "succeeded" => SuccessfulPayment, + "processing" => ProcessingPayment, + "canceled" => CanceledPayment, + "requires_payment_method" => FailedPaymentMethod, + "requires_action" => FailedPayment, + "requires_capture" => FailedPaymentCapture, + _ => string.Format(UnhandledPayment, status) + }; + } } From 7e5ab53a1ee4be5b5ece75263696a932f4852355 Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Mon, 1 Jun 2026 00:51:07 +0300 Subject: [PATCH 14/15] Improved XML Utilities and added JSON Utilities --- src/Presentation/ExchangeRatesEndpoint.cs | 2 +- .../Currencies/ICurrencyService.cs | 2 +- .../Currencies/UpdateExchangeRatesCacheJob.cs | 2 +- .../Currencies/ECBCurrencyService.cs | 6 ++---- .../Currencies/ResilientCurrencyService.cs | 4 ++-- .../Infrastructure/Utilities/JsonUtilities.cs | 19 +++++++++++++++++++ .../Infrastructure/Utilities/XmlUtilities.cs | 14 ++++++++------ 7 files changed, 34 insertions(+), 15 deletions(-) create mode 100644 src/Shared/Infrastructure/Utilities/JsonUtilities.cs diff --git a/src/Presentation/ExchangeRatesEndpoint.cs b/src/Presentation/ExchangeRatesEndpoint.cs index c7facf9aa..8161b6d32 100644 --- a/src/Presentation/ExchangeRatesEndpoint.cs +++ b/src/Presentation/ExchangeRatesEndpoint.cs @@ -17,7 +17,7 @@ public void MapExchangeRatesEndpoint() => { IReadOnlyCollection rates = await cache.GetOrCreateAsync( key: ICurrencyService.ExchangeRatesCacheKey, - factory: service.GetRatesAsync + factory: () => service.GetRatesAsync(ct) ).ConfigureAwait(false) ?? []; ExchangeRate[] response = [.. rates]; diff --git a/src/Shared/Application/Currencies/ICurrencyService.cs b/src/Shared/Application/Currencies/ICurrencyService.cs index d79e05a85..292ac349a 100644 --- a/src/Shared/Application/Currencies/ICurrencyService.cs +++ b/src/Shared/Application/Currencies/ICurrencyService.cs @@ -4,5 +4,5 @@ public interface ICurrencyService { public const string ExchangeRatesCacheKey = "exchange-rates"; - public Task> GetRatesAsync(); + public Task> GetRatesAsync(CancellationToken ct = default); } diff --git a/src/Shared/Infrastructure/BackgroundJobs/Currencies/UpdateExchangeRatesCacheJob.cs b/src/Shared/Infrastructure/BackgroundJobs/Currencies/UpdateExchangeRatesCacheJob.cs index 3e4eba846..1faef1fb2 100644 --- a/src/Shared/Infrastructure/BackgroundJobs/Currencies/UpdateExchangeRatesCacheJob.cs +++ b/src/Shared/Infrastructure/BackgroundJobs/Currencies/UpdateExchangeRatesCacheJob.cs @@ -10,7 +10,7 @@ public async Task Execute(IJobExecutionContext context) { await cache.SetAsync( key: ICurrencyService.ExchangeRatesCacheKey, - item: await service.GetRatesAsync().ConfigureAwait(false) + item: await service.GetRatesAsync(ct: context.CancellationToken).ConfigureAwait(false) ).ConfigureAwait(false); } } diff --git a/src/Shared/Infrastructure/Currencies/ECBCurrencyService.cs b/src/Shared/Infrastructure/Currencies/ECBCurrencyService.cs index 2bb084cc2..0be1b4884 100644 --- a/src/Shared/Infrastructure/Currencies/ECBCurrencyService.cs +++ b/src/Shared/Infrastructure/Currencies/ECBCurrencyService.cs @@ -5,12 +5,10 @@ namespace CustomCADs.Shared.Infrastructure.Currencies; public class ECBCurrencyService(HttpClient client) : ICurrencyService { - public async Task> GetRatesAsync() + public async Task> GetRatesAsync(CancellationToken ct) { HttpResponseMessage response = await SendRequestAsync().ConfigureAwait(false); - - using Stream stream = await response.Content.ReadAsStreamAsync().ConfigureAwait(false); - Gesmes.Envelope envelope = stream.DeserializeFromXml(); + Gesmes.Envelope envelope = await response.Content.ReadAsXmlAsync(ct).ConfigureAwait(false); return [.. envelope.Cube.TimeCube.ToExchangeRates()]; } diff --git a/src/Shared/Infrastructure/Currencies/ResilientCurrencyService.cs b/src/Shared/Infrastructure/Currencies/ResilientCurrencyService.cs index 52fef0e11..25aedb796 100644 --- a/src/Shared/Infrastructure/Currencies/ResilientCurrencyService.cs +++ b/src/Shared/Infrastructure/Currencies/ResilientCurrencyService.cs @@ -7,6 +7,6 @@ public class ResilientCurrencyService( Polly.IAsyncPolicy policy ) : ICurrencyService { - public Task> GetRatesAsync() - => policy.ExecuteAsync(() => inner.GetRatesAsync()); + public Task> GetRatesAsync(CancellationToken ct) + => policy.ExecuteAsync(() => inner.GetRatesAsync(ct)); } diff --git a/src/Shared/Infrastructure/Utilities/JsonUtilities.cs b/src/Shared/Infrastructure/Utilities/JsonUtilities.cs new file mode 100644 index 000000000..03b7b4baf --- /dev/null +++ b/src/Shared/Infrastructure/Utilities/JsonUtilities.cs @@ -0,0 +1,19 @@ +using Newtonsoft.Json; + +namespace CustomCADs.Shared.Infrastructure.Utilities; + +public static class JsonUtilities +{ + extension(HttpContent content) where TDto : class + { + public async Task ReadAsJsonAsync(CancellationToken cancellationToken) + => JsonConvert.DeserializeObject( + value: await content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false) + ) ?? throw new JsonException($"Couldn't serialize {typeof(TDto).GetType()}"); + } + + extension(TDto dto) where TDto : class + { + public string AsSerializedJson { get => JsonConvert.SerializeObject(dto); } + } +} diff --git a/src/Shared/Infrastructure/Utilities/XmlUtilities.cs b/src/Shared/Infrastructure/Utilities/XmlUtilities.cs index 528a8b65e..5a2f08c95 100644 --- a/src/Shared/Infrastructure/Utilities/XmlUtilities.cs +++ b/src/Shared/Infrastructure/Utilities/XmlUtilities.cs @@ -7,17 +7,19 @@ public static class XmlUtilities { private static XmlSerializer GetSerializer() => new(type: typeof(TDto)); - extension(Stream stream) + extension(HttpContent content) where TDto : class { - public TDto DeserializeFromXml() where TDto : class - => GetSerializer().Deserialize(stream) as TDto - ?? throw new XmlException($"Failed to parse XML to {typeof(TDto).Name}"); + public async Task ReadAsXmlAsync(CancellationToken ct) + { + using Stream stream = await content.ReadAsStreamAsync(ct).ConfigureAwait(false); + + return GetSerializer().Deserialize(stream) as TDto + ?? throw new XmlException($"Failed to parse XML to {typeof(TDto).GetType()}"); + } } extension(TDto dto) where TDto : class { - public void SerializeToXml(Stream stream) => GetSerializer().Serialize(stream, dto); - public string AsSerializedXml { get From ae3115d5f455b5013334adfa0dfe6a6ad8f52a08 Mon Sep 17 00:00:00 2001 From: Ivan Angelov Date: Mon, 1 Jun 2026 03:44:36 +0300 Subject: [PATCH 15/15] Unit Test errors fix --- .../Queries/Internal/Gallery/GetById/Tests.cs | 4 ++-- .../Queries/Internal/Shared/GetAll/Tests.cs | 24 +++++++++---------- .../Internal/VerificationEmail/Tests.cs | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs index 24e6ee30c..d7f85c8a1 100644 --- a/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs +++ b/tests/UnitTests/Catalog/Application/Products/Queries/Internal/Gallery/GetById/Tests.cs @@ -87,14 +87,14 @@ public async Task Handle_ShouldRaiseEvents(bool authenticatedUser, bool viewed) AccountId creatorId = authenticatedUser ? ValidCreatorId : new(); // Act - await handler.Handle(request with { CallerId = creatorId }, ct); + await handler.Handle(request with { CallerId = creatorId, Viewed = viewed }, ct); // Assert raiser.Verify( x => x.RaiseApplicationEventAsync( It.Is(x => x.Id == product.Id) ), - Times.Exactly(authenticatedUser && viewed ? 1 : 0) + Times.Exactly((authenticatedUser && viewed) ? 1 : 0) ); } diff --git a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs index d43c01515..b1accbf44 100644 --- a/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs +++ b/tests/UnitTests/Customs/Application/Customs/Queries/Internal/Shared/GetAll/Tests.cs @@ -16,18 +16,16 @@ namespace CustomCADs.UnitTests.Customs.Application.Customs.Queries.Internal.Shar public class Tests : Data.Customs.BaseUnitTests { private readonly GetAllCustomsHandler handler; - private readonly GetAllCustomsQuery request = new(Query.Pagination); + private readonly GetAllCustomsQuery request; private readonly Mock reads = new(); private readonly Mock sender = new(); - private static readonly Custom[] Customs = [ - CreateCustom(id: ValidId), - CreateCustom(id: ValidId), + private readonly Custom[] customs = [ + CreateCustom(), + CreateCustom(), ]; - private static readonly CustomQuery Query = new( - Pagination: new(1, Customs.Length) - ); + private readonly CustomQuery Query; private readonly Dictionary customers = new() { [ValidBuyerId] = CustomerUsername, @@ -44,13 +42,15 @@ public class Tests : Data.Customs.BaseUnitTests public Tests() { handler = new(reads.Object, sender.Object); + request = new(Pagination: new(1, customs.Length)); + Query = new(Pagination: request.Pagination); - Customs.First().Accept(ValidDesignerId); + customs.First().Accept(ValidDesignerId); reads.Setup(x => x.AllAsync(Query, false, ct)) .ReturnsAsync(new Result( - Customs.Length, - Customs + customs.Length, + customs )); sender.Setup(x => x.SendQueryAsync( @@ -125,8 +125,8 @@ public async Task Handle_ShouldReturnResult() var result = await handler.Handle(request, ct); // Assert - int expectedCount = Customs.Length, actualCount = result.Count; - CustomId[] expectedIds = [.. Customs.Select(x => x.Id)], + int expectedCount = customs.Length, actualCount = result.Count; + CustomId[] expectedIds = [.. customs.Select(x => x.Id)], actualIds = [.. result.Items.Select(x => x.Id)]; Assert.Multiple( diff --git a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs index f656447a2..f66649b15 100644 --- a/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs +++ b/tests/UnitTests/Identity/Application/Users/Commands/Internal/VerificationEmail/Tests.cs @@ -19,7 +19,7 @@ public class Tests : Data.Users.BaseUnitTests private readonly Mock> settings = new(); private const string Token = "email-token"; - private readonly User user = CreateUser(); + private readonly User user = CreateUser(username: MaxValidUsername); public Tests() {