Exception handling numeric data types with SerializableCart

Found in

EPiServer.Commerce 11.0.0

Fixed in

EPiServer.Commerce 11.4.0

Created

Oct 03 2017

Updated

Nov 10 2017

Area

Core

State

Closed, Fixed and tested


Description

When storing numberic values in serializable carts, it might throw exception later, on load.

Test to prove:

 
    public class When_saving_a_serializable_cart : IntegrationCartTestBase
    {
        private static decimal _loaded;
 
        Establish context = () =>
        {
            EnableSerializedCarts();
            var cart = OrderRepository.Create(Guid.Empty, "Default");
            cart.GetFirstForm().Properties["Test"] = (decimal)1.23;
            OrderRepository.Save(cart);
            cart = OrderRepository.Load(cart.OrderLink.OrderGroupId);
            _loaded = (decimal)cart.GetFirstForm().Properties["Test"]; // BAM
        };
 
        It Should_serialize_correctly = () => _loaded.ShouldEqual(1.23m);
    }