예제 #1
0
        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
            gc.IsGiftCardValid().ShouldEqual(true);

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

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

            //add usage history record
            gc.GiftCardUsageHistory.Add(new GiftCardUsageHistory()
            {
                UsedValue = 1000
            });
            gc.IsGiftCardValid().ShouldEqual(false);
        }