public void WhenActiveCartWithTwoItemsAndPayExpectPaidCart()
        {
            var activeCart = new CartStateActive(new[] { Product.ProductX, Product.ProductY });

            const decimal paidAmount = 12.34m;
            var newState = activeCart.Pay(paidAmount);

            var isPaidState = newState.Func(cartStateEmpty => false, cartStateActive => false, cartStatePaid => true);
            Assert.IsTrue(isPaidState);

            var itemCount = newState.Func(cartStateEmpty => -1, cartStateActive => -1, cartStatePaid => cartStatePaid.Items.Count());
            Assert.That(itemCount, Is.EqualTo(2));

            var actualPaidAmount = newState.Func(cartStateEmpty => -1, cartStateActive => -1, cartStatePaid => cartStatePaid.Amount);
            Assert.That(actualPaidAmount, Is.EqualTo(paidAmount));
        }
        public void WhenActiveCartWithTwoItemsAndPayExpectPaidCart()
        {
            var activeCart = new CartStateActive(new[] { Product.ProductX, Product.ProductY });

            const decimal paidAmount = 12.34m;
            var newState = activeCart.Pay(paidAmount);

            // assert
            var paidState = newState as CartStatePaid; //CAST!
            if (paidState != null)
            {
                var itemCount = paidState.Items.Count();
                Assert.That(itemCount, Is.EqualTo(2));

                var actualPaidAmount = paidState.Amount;
                Assert.That(actualPaidAmount, Is.EqualTo(paidAmount));
            }
            else
            {
                Assert.Fail("Expect CartStateActive");
            }
        }