Skip to content

Commit

Permalink
Add documentation comments to unit test methods
Browse files Browse the repository at this point in the history
  • Loading branch information
martinkyjac committed May 17, 2024
1 parent 2425146 commit 09a6f7d
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions test/Kentico.Xperience.Shopify.Tests/ShoppingServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,29 @@

namespace Kentico.Xperience.Shopify.Tests
{
/// <summary>
/// <see cref="ShoppingService"/> unit tests.
/// </summary>
[TestFixture]
public class ShoppingServiceTests
{
private readonly AutoMocker mocker;
private ShoppingCartRepository CartRepository { get; set; }
private DiscountCodesRepository DiscountCodesRepository { get; set; }


/// <summary>
/// Create <see cref="ShoppingServiceTests"/> instance.
/// </summary>
public ShoppingServiceTests()
{
mocker = new AutoMocker();
}


/// <summary>
/// One time tests setup. Add mocks to dependency injection container.
/// </summary>
[OneTimeSetUp]
public void OneTimeSetUp()
{
Expand All @@ -33,6 +43,10 @@ public void OneTimeSetUp()
}


/// <summary>
/// Set up before each test.
/// Create shopping cart and discount codes repository mocks.
/// </summary>
[SetUp]
public void SetUp()
{
Expand All @@ -41,6 +55,9 @@ public void SetUp()
}


/// <summary>
/// Get existing shopping cart stored in session.
/// </summary>
[Test]
public async Task GetCurrentShoppingCart_ExistingCartIdInSession_ShouldReturnCart()
{
Expand All @@ -65,6 +82,9 @@ public async Task GetCurrentShoppingCart_ExistingCartIdInSession_ShouldReturnCar
}


/// <summary>
/// Get shopping cart without any data stored in session.
/// </summary>
[Test]
public async Task GetCurrentShoppingCart_NoCartIdInSession_ShouldReturnNull()
{
Expand All @@ -76,6 +96,9 @@ public async Task GetCurrentShoppingCart_NoCartIdInSession_ShouldReturnNull()
}


/// <summary>
/// Set negative quantity to shopping cart item.
/// </summary>
[Test]
public async Task UpdateCartItem_SetNegativeQuantity_ShouldRemoveCartItem()
{
Expand Down Expand Up @@ -111,6 +134,9 @@ public async Task UpdateCartItem_SetNegativeQuantity_ShouldRemoveCartItem()
}


/// <summary>
/// Try remove shopping cart item when no shopping cart is stored in session.
/// </summary>
[Test]
public async Task RemoveCartItem_NoCartIdInSession_ShouldRetrunNull()
{
Expand All @@ -127,6 +153,9 @@ public async Task RemoveCartItem_NoCartIdInSession_ShouldRetrunNull()
}


/// <summary>
/// Update non existing shopping cart item.
/// </summary>
[Test]
public async Task UpdateCartItem_AddNewCartItem_ShouldAddItemToCart()
{
Expand Down Expand Up @@ -161,6 +190,9 @@ public async Task UpdateCartItem_AddNewCartItem_ShouldAddItemToCart()
}


/// <summary>
/// Update existing shopping cart item.
/// </summary>
[Test]
public async Task UpdateCartItem_UpdatedProductAlreadyInCart_ShouldUpdateExistingCartItem()
{
Expand Down Expand Up @@ -193,6 +225,9 @@ public async Task UpdateCartItem_UpdatedProductAlreadyInCart_ShouldUpdateExistin
}


/// <summary>
/// Remove existing shopping cart item.
/// </summary>
[Test]
public async Task RemoveCartItem_CartContainsItem_ShouldRemoveCartItem()
{
Expand All @@ -216,6 +251,9 @@ public async Task RemoveCartItem_CartContainsItem_ShouldRemoveCartItem()
}


/// <summary>
/// Remove non existing shopping cart item.
/// </summary>
[Test]
public async Task RemoveCartItem_CartDoesNotContainItem_ShouldReturnUnmodifiedCart()
{
Expand Down Expand Up @@ -244,6 +282,9 @@ public async Task RemoveCartItem_CartDoesNotContainItem_ShouldReturnUnmodifiedCa
}


/// <summary>
/// Add new shopping cart item to existing shopping cart.
/// </summary>
[Test]
public async Task AddItemToCart_ExistingCartIdStoredInSession_ShouldAddItemToCart()
{
Expand Down Expand Up @@ -276,6 +317,9 @@ public async Task AddItemToCart_ExistingCartIdStoredInSession_ShouldAddItemToCar
}


/// <summary>
/// Add product to shopping cart when no shopping cart is stored in session.
/// </summary>
[Test]
public async Task AddItemToCart_NoExistingCartIdInSession_ShouldReturnNewCartWithProduct()
{
Expand Down Expand Up @@ -303,6 +347,9 @@ public async Task AddItemToCart_NoExistingCartIdInSession_ShouldReturnNewCartWit
}


/// <summary>
/// Add discount code to existing shopping cart.
/// </summary>
[Test]
public async Task AddDiscountCode_ExistingCartIdInSession_ShouldAddDiscountCode()
{
Expand All @@ -329,6 +376,9 @@ public async Task AddDiscountCode_ExistingCartIdInSession_ShouldAddDiscountCode(
}


/// <summary>
/// Add invalid discount code to existing shopping cart.
/// </summary>
[Test]
public async Task AddDiscountCode_NonExistingDiscountCode_ShouldIgnoreDiscountCode()
{
Expand All @@ -353,6 +403,9 @@ public async Task AddDiscountCode_NonExistingDiscountCode_ShouldIgnoreDiscountCo
}


/// <summary>
/// Add valid discount code to the cart that already contains the same discount code.
/// </summary>
[Test]
public async Task AddDiscountCode_CartAlreadyContainsAnotherCode_ShouldAddDiscountCode()
{
Expand Down Expand Up @@ -381,6 +434,9 @@ public async Task AddDiscountCode_CartAlreadyContainsAnotherCode_ShouldAddDiscou
}


/// <summary>
/// Add invalid discount code to shopping cart.
/// </summary>
[Test]
public async Task AddNonExistingDiscountCode_CartHasAnotherDiscountCode_ShouldIgnoreCode()
{
Expand All @@ -407,6 +463,9 @@ public async Task AddNonExistingDiscountCode_CartHasAnotherDiscountCode_ShouldIg
}


/// <summary>
/// Remove valid discount code from existing shopping cart.
/// </summary>
[Test]
public async Task RemoveExistingDiscountCode_CartContainsDiscountCode_ShouldRemoveCode()
{
Expand Down Expand Up @@ -434,6 +493,9 @@ public async Task RemoveExistingDiscountCode_CartContainsDiscountCode_ShouldRemo
}


/// <summary>
/// Remove non-existing discount code from shopping cart.
/// </summary>
[Test]
public async Task RemoveNonExistingDiscountCode_CartContainsAnotherDiscountCode_ShouldIgnoreCode()
{
Expand Down Expand Up @@ -461,6 +523,9 @@ public async Task RemoveNonExistingDiscountCode_CartContainsAnotherDiscountCode_
}


/// <summary>
/// Remove whole shopping cart from session.
/// </summary>
[Test]
public async Task RemoveCurrentShoppingCart_CartExists_ShouldRemoveCart()
{
Expand Down

0 comments on commit 09a6f7d

Please sign in to comment.