public void Can_validate_giftCard()
        {
            var gc = new GiftCard
            {
                Amount = 100,
                IsGiftCardActivated = true
            };

            gc.GiftCardUsageHistory.Add
            (
                new GiftCardUsageHistory
            {
                UsedValue = 30
            }

            );
            gc.GiftCardUsageHistory.Add
            (
                new GiftCardUsageHistory
            {
                UsedValue = 20
            }

            );
            gc.GiftCardUsageHistory.Add
            (
                new GiftCardUsageHistory
            {
                UsedValue = 5
            }

            );

            //valid
            _giftCardService.IsGiftCardValid(gc).ShouldEqual(true);

            //mark as not active
            gc.IsGiftCardActivated = false;
            _giftCardService.IsGiftCardValid(gc).ShouldEqual(false);

            //again active
            gc.IsGiftCardActivated = true;
            _giftCardService.IsGiftCardValid(gc).ShouldEqual(true);

            //add usage history record
            gc.GiftCardUsageHistory.Add(new GiftCardUsageHistory
            {
                UsedValue = 1000
            });
            _giftCardService.IsGiftCardValid(gc).ShouldEqual(false);
        }
        public void Can_validate_giftCard()
        {
            RunWithTestServiceProvider(() => {
                var gc = _giftCardService.GetGiftCardById(1);

                _giftCardService.InsertGiftCardUsageHistory(
                    new GiftCardUsageHistory
                {
                    GiftCardId = gc.Id,
                    UsedValue  = 30
                });

                _giftCardService.InsertGiftCardUsageHistory(
                    new GiftCardUsageHistory
                {
                    GiftCardId = gc.Id,
                    UsedValue  = 20
                });

                _giftCardService.InsertGiftCardUsageHistory(
                    new GiftCardUsageHistory
                {
                    GiftCardId = gc.Id,
                    UsedValue  = 5
                });


                //valid
                _giftCardService.IsGiftCardValid(gc).Should().BeTrue();

                //mark as not active
                gc.IsGiftCardActivated = false;
                _giftCardService.IsGiftCardValid(gc).Should().BeFalse();

                //again active
                gc.IsGiftCardActivated = true;
                _giftCardService.IsGiftCardValid(gc).Should().BeTrue();

                //add usage history record
                _giftCardService.InsertGiftCardUsageHistory(
                    new GiftCardUsageHistory
                {
                    GiftCardId = gc.Id,
                    UsedValue  = 1000
                });

                _giftCardService.IsGiftCardValid(gc).Should().BeFalse();
            });
        }
        public void CanValidateGiftCard()
        {
            _giftCardService.InsertGiftCardUsageHistory(
                new GiftCardUsageHistory {
                GiftCardId = _giftCard1.Id, UsedWithOrderId = 1, UsedValue = 30
            });

            _giftCardService.InsertGiftCardUsageHistory(
                new GiftCardUsageHistory {
                GiftCardId = _giftCard1.Id, UsedWithOrderId = 1, UsedValue = 20
            });

            _giftCardService.InsertGiftCardUsageHistory(
                new GiftCardUsageHistory {
                GiftCardId = _giftCard1.Id, UsedWithOrderId = 1, UsedValue = 5
            });

            //valid
            _giftCardService.IsGiftCardValid(_giftCard1).Should().BeTrue();

            //mark as not active
            _giftCard1.IsGiftCardActivated = false;
            _giftCardService.IsGiftCardValid(_giftCard1).Should().BeFalse();

            //again active
            _giftCard1.IsGiftCardActivated = true;
            _giftCardService.IsGiftCardValid(_giftCard1).Should().BeTrue();

            //add usage history record
            _giftCardService.InsertGiftCardUsageHistory(
                new GiftCardUsageHistory {
                GiftCardId = _giftCard1.Id, UsedWithOrderId = 1, UsedValue = 1000
            });

            _giftCardService.IsGiftCardValid(_giftCard1).Should().BeFalse();
        }