Skip to content

Commit

Permalink
VT-6136 Shopify: Shopify quantity not matching quantity in SV (#34)
Browse files Browse the repository at this point in the history
* VT-6136 : ignore case for enum

* 1.9.0.0

* VT-6136 : updated to TestCase

* VT-6136 : added more tests for Blank
  • Loading branch information
mrassudishkin authored Aug 29, 2023
1 parent bbd3e27 commit 07b05bb
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Global/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[ assembly : AssemblyVersion( "1.8.0.0" ) ]
[ assembly : AssemblyVersion( "1.9.0.0" ) ]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public InventoryManagementEnum InventoryManagement
{
get
{
if ( Enum.TryParse< InventoryManagementEnum >( RawInventoryManagement, out var inventoryManagement ) )
if ( Enum.TryParse< InventoryManagementEnum >( RawInventoryManagement, true, out var inventoryManagement ) )
{
return inventoryManagement;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using FluentAssertions;
using NUnit.Framework;
using ServiceStack.Text;
using ShopifyAccess.Models.ProductVariant;

namespace ShopifyAccessTests.Products.Models
{
[ TestFixture ]
public class ShopifyProductVariantTests
{
[ TestCase( "" ) ]
[ TestCase( null ) ]
[ TestCase( "Blank" ) ]
[ TestCase( "blank" ) ]
[ TestCase( "strange_status" ) ]
public void Deserialize_ReturnsBlankInventoryManagement( string rawInventoryManagement )
{
// Arrange
var json = "{\"id\":1,\"inventory_management\":\"" + rawInventoryManagement + "\",\"inventory_item_id\":0,\"weight\":0,\"price\":0,\"updated_at\":\"\\/Date(-62135596800000-0000)\\/\"}";

// Act
var shopifyProductVariant = JsonSerializer.DeserializeFromString< ShopifyProductVariant >( json );

// Assert
shopifyProductVariant.InventoryManagement.Should().Be( InventoryManagementEnum.Blank );
}

[ TestCase( "Shopify" ) ]
[ TestCase( "shopify" ) ]
public void Deserialize_ReturnsShopifyInventoryManagement( string rawInventoryManagement )
{
// Arrange
var json = "{\"id\":1,\"inventory_management\":\"" + rawInventoryManagement + "\",\"inventory_item_id\":0,\"weight\":0,\"price\":0,\"updated_at\":\"\\/Date(-62135596800000-0000)\\/\"}";

// Act
var shopifyProductVariant = JsonSerializer.DeserializeFromString< ShopifyProductVariant >( json );

// Assert
shopifyProductVariant.InventoryManagement.Should().Be( InventoryManagementEnum.Shopify );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
<Compile Include="OperationTimeoutTests.cs" />
<Compile Include="Orders\OrderMapperTests.cs" />
<Compile Include="Orders\OrdersListTests.cs" />
<Compile Include="Products\Models\ShopifyProductVariantTests.cs" />
<Compile Include="Products\ProductVariantTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\WebRequestServicesTests.cs" />
Expand Down

0 comments on commit 07b05bb

Please sign in to comment.