示例#1
0
        public void AllTest()
        {
            //input
            decimal buyingAmount          = 100;
            decimal shippingAmountTTC     = 7;
            decimal variableFeePercentage = 9;
            decimal fixedFeeAmount        = 0.25m;
            decimal sellingAmountTTC      = 200;
            decimal vatRate  = 20;
            decimal markRate = 20;

            //result
            decimal feeAmountResult = 18.88m;
            decimal costResult      = 118.88m;

            decimal sellingUnusedHtResult      = 145.78m;
            decimal sellingUnusedTTCResult     = 174.94m;
            decimal sellingUnusedBenefitResult = 29.16m;

            decimal sellingUsedHtResult      = 143.18m;
            decimal sellingUsedTTCResult     = 151.82m;
            decimal sellingUsedBenefitResult = 28.64m;


            if (PriceHelper.GetFeeAmount(sellingAmountTTC, shippingAmountTTC, variableFeePercentage, fixedFeeAmount) != feeAmountResult)
            {
                throw new Exception();
            }

            if (PriceHelper.GetCost(buyingAmount, sellingAmountTTC, shippingAmountTTC, variableFeePercentage, fixedFeeAmount) != costResult)
            {
                throw new Exception();
            }


            if (Math.Round(PriceHelper.GetSellingAmount(VATEnum.HT, markRate, buyingAmount, shippingAmountTTC, variableFeePercentage, fixedFeeAmount, vatRate, PriceHelper.ConditionEnum.UNUSED), 2) != sellingUnusedHtResult)
            {
                throw new Exception();
            }

            if (Math.Round(PriceHelper.GetSellingAmount(VATEnum.TTC, markRate, buyingAmount, shippingAmountTTC, variableFeePercentage, fixedFeeAmount, vatRate, PriceHelper.ConditionEnum.UNUSED), 2) != sellingUnusedTTCResult)
            {
                throw new Exception();
            }

            if (Math.Round(PriceHelper.GetSellingAmount(VATEnum.HT, markRate, buyingAmount, shippingAmountTTC, variableFeePercentage, fixedFeeAmount, vatRate, PriceHelper.ConditionEnum.USED), 2) != sellingUsedHtResult)
            {
                throw new Exception();
            }

            if (Math.Round(PriceHelper.GetSellingAmount(VATEnum.TTC, markRate, buyingAmount, shippingAmountTTC, variableFeePercentage, fixedFeeAmount, vatRate, PriceHelper.ConditionEnum.USED), 2) != sellingUsedTTCResult)
            {
                throw new Exception();
            }

            //SellingUsedBenefit
            if (Math.Round(PriceHelper.GetProfitAmount(buyingAmount, PriceHelper.GetFeeAmount(sellingUsedTTCResult, shippingAmountTTC, variableFeePercentage, fixedFeeAmount), sellingUsedHtResult), 2) != sellingUsedBenefitResult)
            {
                throw new Exception();
            }

            //SellingUnusedBenefit
            if (Math.Round(PriceHelper.GetProfitAmount(buyingAmount, PriceHelper.GetFeeAmount(sellingUnusedTTCResult, shippingAmountTTC, variableFeePercentage, fixedFeeAmount), sellingUnusedHtResult), 2) != sellingUnusedBenefitResult)
            {
                throw new Exception();
            }
        }