From 09a6f7de652a6bd5ac1f3b4bf445f4fdfc7878fc Mon Sep 17 00:00:00 2001 From: Martin Kyjac Date: Fri, 17 May 2024 16:02:33 +0200 Subject: [PATCH] Add documentation comments to unit test methods --- .../ShoppingServiceTests.cs | 65 +++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/test/Kentico.Xperience.Shopify.Tests/ShoppingServiceTests.cs b/test/Kentico.Xperience.Shopify.Tests/ShoppingServiceTests.cs index 10f7dd2..985fadb 100644 --- a/test/Kentico.Xperience.Shopify.Tests/ShoppingServiceTests.cs +++ b/test/Kentico.Xperience.Shopify.Tests/ShoppingServiceTests.cs @@ -11,6 +11,9 @@ namespace Kentico.Xperience.Shopify.Tests { + /// + /// unit tests. + /// [TestFixture] public class ShoppingServiceTests { @@ -18,12 +21,19 @@ public class ShoppingServiceTests private ShoppingCartRepository CartRepository { get; set; } private DiscountCodesRepository DiscountCodesRepository { get; set; } + + /// + /// Create instance. + /// public ShoppingServiceTests() { mocker = new AutoMocker(); } + /// + /// One time tests setup. Add mocks to dependency injection container. + /// [OneTimeSetUp] public void OneTimeSetUp() { @@ -33,6 +43,10 @@ public void OneTimeSetUp() } + /// + /// Set up before each test. + /// Create shopping cart and discount codes repository mocks. + /// [SetUp] public void SetUp() { @@ -41,6 +55,9 @@ public void SetUp() } + /// + /// Get existing shopping cart stored in session. + /// [Test] public async Task GetCurrentShoppingCart_ExistingCartIdInSession_ShouldReturnCart() { @@ -65,6 +82,9 @@ public async Task GetCurrentShoppingCart_ExistingCartIdInSession_ShouldReturnCar } + /// + /// Get shopping cart without any data stored in session. + /// [Test] public async Task GetCurrentShoppingCart_NoCartIdInSession_ShouldReturnNull() { @@ -76,6 +96,9 @@ public async Task GetCurrentShoppingCart_NoCartIdInSession_ShouldReturnNull() } + /// + /// Set negative quantity to shopping cart item. + /// [Test] public async Task UpdateCartItem_SetNegativeQuantity_ShouldRemoveCartItem() { @@ -111,6 +134,9 @@ public async Task UpdateCartItem_SetNegativeQuantity_ShouldRemoveCartItem() } + /// + /// Try remove shopping cart item when no shopping cart is stored in session. + /// [Test] public async Task RemoveCartItem_NoCartIdInSession_ShouldRetrunNull() { @@ -127,6 +153,9 @@ public async Task RemoveCartItem_NoCartIdInSession_ShouldRetrunNull() } + /// + /// Update non existing shopping cart item. + /// [Test] public async Task UpdateCartItem_AddNewCartItem_ShouldAddItemToCart() { @@ -161,6 +190,9 @@ public async Task UpdateCartItem_AddNewCartItem_ShouldAddItemToCart() } + /// + /// Update existing shopping cart item. + /// [Test] public async Task UpdateCartItem_UpdatedProductAlreadyInCart_ShouldUpdateExistingCartItem() { @@ -193,6 +225,9 @@ public async Task UpdateCartItem_UpdatedProductAlreadyInCart_ShouldUpdateExistin } + /// + /// Remove existing shopping cart item. + /// [Test] public async Task RemoveCartItem_CartContainsItem_ShouldRemoveCartItem() { @@ -216,6 +251,9 @@ public async Task RemoveCartItem_CartContainsItem_ShouldRemoveCartItem() } + /// + /// Remove non existing shopping cart item. + /// [Test] public async Task RemoveCartItem_CartDoesNotContainItem_ShouldReturnUnmodifiedCart() { @@ -244,6 +282,9 @@ public async Task RemoveCartItem_CartDoesNotContainItem_ShouldReturnUnmodifiedCa } + /// + /// Add new shopping cart item to existing shopping cart. + /// [Test] public async Task AddItemToCart_ExistingCartIdStoredInSession_ShouldAddItemToCart() { @@ -276,6 +317,9 @@ public async Task AddItemToCart_ExistingCartIdStoredInSession_ShouldAddItemToCar } + /// + /// Add product to shopping cart when no shopping cart is stored in session. + /// [Test] public async Task AddItemToCart_NoExistingCartIdInSession_ShouldReturnNewCartWithProduct() { @@ -303,6 +347,9 @@ public async Task AddItemToCart_NoExistingCartIdInSession_ShouldReturnNewCartWit } + /// + /// Add discount code to existing shopping cart. + /// [Test] public async Task AddDiscountCode_ExistingCartIdInSession_ShouldAddDiscountCode() { @@ -329,6 +376,9 @@ public async Task AddDiscountCode_ExistingCartIdInSession_ShouldAddDiscountCode( } + /// + /// Add invalid discount code to existing shopping cart. + /// [Test] public async Task AddDiscountCode_NonExistingDiscountCode_ShouldIgnoreDiscountCode() { @@ -353,6 +403,9 @@ public async Task AddDiscountCode_NonExistingDiscountCode_ShouldIgnoreDiscountCo } + /// + /// Add valid discount code to the cart that already contains the same discount code. + /// [Test] public async Task AddDiscountCode_CartAlreadyContainsAnotherCode_ShouldAddDiscountCode() { @@ -381,6 +434,9 @@ public async Task AddDiscountCode_CartAlreadyContainsAnotherCode_ShouldAddDiscou } + /// + /// Add invalid discount code to shopping cart. + /// [Test] public async Task AddNonExistingDiscountCode_CartHasAnotherDiscountCode_ShouldIgnoreCode() { @@ -407,6 +463,9 @@ public async Task AddNonExistingDiscountCode_CartHasAnotherDiscountCode_ShouldIg } + /// + /// Remove valid discount code from existing shopping cart. + /// [Test] public async Task RemoveExistingDiscountCode_CartContainsDiscountCode_ShouldRemoveCode() { @@ -434,6 +493,9 @@ public async Task RemoveExistingDiscountCode_CartContainsDiscountCode_ShouldRemo } + /// + /// Remove non-existing discount code from shopping cart. + /// [Test] public async Task RemoveNonExistingDiscountCode_CartContainsAnotherDiscountCode_ShouldIgnoreCode() { @@ -461,6 +523,9 @@ public async Task RemoveNonExistingDiscountCode_CartContainsAnotherDiscountCode_ } + /// + /// Remove whole shopping cart from session. + /// [Test] public async Task RemoveCurrentShoppingCart_CartExists_ShouldRemoveCart() {