Exemple #1
0
        public void ItShouldReturnCorrectTotalForItemScannedItem()
        {
            var banana = new Banana();

            CheckoutCounter.Scan(banana);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(banana.GetCost()));
        }
        /// <summary>
        ///     跳转方式获得数据
        /// </summary>
        /// <param name="info"></param>
        /// <param name="orderInfo"></param>
        /// <param name="postUrl"></param>
        /// <returns></returns>
        public IDictionary <string, string> PayByCounter(MerchantInfo info, CheckoutCounter orderInfo,
                                                         out string postUrl)
        {
            postUrl = host + "/order/gwayOrderPay";
            var dict = new Dictionary <string, string>
            {
                { "orderCode", orderInfo.orderCode },
                { "totalAmount", orderInfo.totalAmount.ToString().PadLeft(12, '0') },
                { "subject", orderInfo.subject },
                { "body", orderInfo.body }
            };

            if (string.IsNullOrEmpty(orderInfo.txnTimeOut))
            {
                dict.Add("txnTimeOut", orderInfo.txnTimeOut);
            }
            dict.Add("payMode", orderInfo.payMode);
            if (string.IsNullOrEmpty(orderInfo.payExtra))
            {
                dict.Add("payExtra", orderInfo.payExtra);
            }
            dict.Add("clientIp", orderInfo.clientIp);
            dict.Add("notifyUrl", orderInfo.notifyUrl);
            dict.Add("frontUrl", orderInfo.frontUrl);
            if (string.IsNullOrEmpty(orderInfo.storeId))
            {
                dict.Add("storeId", orderInfo.storeId);
            }

            if (string.IsNullOrEmpty(orderInfo.terminalId))
            {
                dict.Add("terminalId", orderInfo.terminalId);
            }
            if (string.IsNullOrEmpty(orderInfo.operatorId))
            {
                dict.Add("operatorId", orderInfo.operatorId);
            }

            dict.Add("clearCycle", Convert.ToInt32(orderInfo.clearCycle).ToString());

            if (string.IsNullOrEmpty(orderInfo.riskRateInfo))
            {
                dict.Add("riskRateInfo", orderInfo.riskRateInfo);
            }


            if (string.IsNullOrEmpty(orderInfo.bizExtendParams))
            {
                dict.Add("bizExtendParams", orderInfo.bizExtendParams);
            }
            if (string.IsNullOrEmpty(orderInfo.merchExtendParams))
            {
                dict.Add("merchExtendParams", orderInfo.merchExtendParams);
            }
            if (string.IsNullOrEmpty(orderInfo.extend))
            {
                dict.Add("extend", orderInfo.extend);
            }
            return(dict);
        }
Exemple #3
0
        public void ItShouldReturnCorrectTotalForTwentyPercentDiscount()
        {
            var banana = BananaTwentyPenceDiscountBuilder.Build.AnInstance();

            CheckoutCounter.Scan(banana);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(0.5M));
        }
Exemple #4
0
        public void ItShouldReturnTheCorrectCostOfTwoOranges()
        {
            var orange = new Orange();

            CheckoutCounter.Scan(orange);
            CheckoutCounter.Scan(orange);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(orange.GetCost() * 2));
        }
Exemple #5
0
        public void ItShouldReturnTheCorrectTotalForTwoForAPoundDiscount()
        {
            var banana = new Banana();

            CheckoutCounter.Scan(banana);
            CheckoutCounter.Scan(banana);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(1.0M));
        }
Exemple #6
0
        public void ItShouldReturnTheCorrectTotalForAppleTwoForOneDiscount()
        {
            var apple = new Apple();

            CheckoutCounter.Scan(apple);
            CheckoutCounter.Scan(apple);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(apple.GetCost()));
        }
Exemple #7
0
        public void ItShouldReturnCorrectPriceIf2OfTheSameItemIsScanned()
        {
            var orange = new Orange();

            CheckoutCounter.Scan(orange);
            CheckoutCounter.Scan(orange);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(orange.GetCost() * 2));
        }
Exemple #8
0
        public void ItShouldReturnCorrectPriceFor2DifferentItemsAreScanned()
        {
            var apple  = new Apple();
            var orange = new Orange();

            CheckoutCounter.Scan(apple);
            CheckoutCounter.Scan(orange);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(apple.GetCost() + orange.GetCost()));
        }
Exemple #9
0
        public void ItShouldReturnTheCorrectDiscountOfThreeOrangesForNinetyPence()
        {
            var orange = new Orange();

            CheckoutCounter.Scan(orange);
            CheckoutCounter.Scan(orange);
            CheckoutCounter.Scan(orange);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(0.9M));
        }
Exemple #10
0
        public void ItShouldReturnTheCorrectTotalForBananaTwoForAPoundDiscountWhenInDifferentOrder()
        {
            var banana = new Banana();
            var orange = new Orange();
            var apple  = new Apple();

            CheckoutCounter.Scan(banana);
            CheckoutCounter.Scan(orange);
            CheckoutCounter.Scan(banana);
            CheckoutCounter.Scan(apple);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(1.00M + orange.GetCost() + apple.GetCost()));
        }
Exemple #11
0
        public void ItShouldReturnTheCorrectDiscountOfThreeOrangesForNinetyPenceWhenNotInOrder()
        {
            var orange = new Orange();
            var apple  = new Apple();

            CheckoutCounter.Scan(orange);
            CheckoutCounter.Scan(apple);
            CheckoutCounter.Scan(orange);
            CheckoutCounter.Scan(apple);
            CheckoutCounter.Scan(apple);
            CheckoutCounter.Scan(orange);
            Assert.That(CheckoutCounter.Total(), Is.EqualTo(0.9M + apple.GetCost() * 3));
        }
Exemple #12
0
    public string GetObjectDescription(StoreObject obj)
    {
        DisplayShelf possibleDisplayShelf = obj.GetComponent <DisplayShelf>();

        if (possibleDisplayShelf != null)
        {
            return("Shelf used to hold products");
        }
        BudtenderCounter possibleBudtenderCounter = obj.GetComponent <BudtenderCounter>();

        if (possibleBudtenderCounter != null)
        {
            return("Opens " + possibleBudtenderCounter.stations.Count + " budtender jobs.  Budtenders assist customers and keep your shelves stocked");
        }
        CheckoutCounter possibleCheckoutCounter = obj.GetComponent <CheckoutCounter>();

        if (possibleCheckoutCounter != null)
        {
            return("Place for customers to check out");
        }
        return("Error: " + obj.ToString());
    }
Exemple #13
0
 public void ItShouldThrowItemNotFoundExceptionIfScanningEmpty()
 {
     Assert.Throws <ItemNotFoundException>(() => CheckoutCounter.Scan(null));
 }