diff --git a/src/Global/GlobalAssemblyInfo.cs b/src/Global/GlobalAssemblyInfo.cs index 4170c5f..ba28f97 100644 --- a/src/Global/GlobalAssemblyInfo.cs +++ b/src/Global/GlobalAssemblyInfo.cs @@ -22,4 +22,4 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[ assembly : AssemblyVersion( "1.8.0.0" ) ] \ No newline at end of file +[ assembly : AssemblyVersion( "1.9.0.0" ) ] \ No newline at end of file diff --git a/src/ShopifyAccess/Models/ProductVariant/ShopifyProductVariant.cs b/src/ShopifyAccess/Models/ProductVariant/ShopifyProductVariant.cs index a57a680..f63d1fa 100644 --- a/src/ShopifyAccess/Models/ProductVariant/ShopifyProductVariant.cs +++ b/src/ShopifyAccess/Models/ProductVariant/ShopifyProductVariant.cs @@ -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; } diff --git a/src/ShopifyAccessTests/ShopifyAccessTests/Products/Models/ShopifyProductVariantTests.cs b/src/ShopifyAccessTests/ShopifyAccessTests/Products/Models/ShopifyProductVariantTests.cs new file mode 100644 index 0000000..abb7ff4 --- /dev/null +++ b/src/ShopifyAccessTests/ShopifyAccessTests/Products/Models/ShopifyProductVariantTests.cs @@ -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 ); + } + } +} \ No newline at end of file diff --git a/src/ShopifyAccessTests/ShopifyAccessTests/ShopifyAccessTests.csproj b/src/ShopifyAccessTests/ShopifyAccessTests/ShopifyAccessTests.csproj index 2598844..84aef1d 100644 --- a/src/ShopifyAccessTests/ShopifyAccessTests/ShopifyAccessTests.csproj +++ b/src/ShopifyAccessTests/ShopifyAccessTests/ShopifyAccessTests.csproj @@ -109,6 +109,7 @@ +