Пример #1
0
        static PriceRange GetPriceRange(string caption, double confidence, float expensiveMultiplier, Random rnd)
        {
            PriceRange priceRange;

            priceRange.lowPrice  = 0;
            priceRange.highPrice = 0;

            // Longer captions means higher prices
            foreach (char c in caption)
            {
                priceRange.highPrice += c;
            }

            // Randomly increase price
            priceRange.highPrice *= (int)(1.0f + rnd.NextDouble() * 30.0f);

            priceRange.highPrice = (int)(priceRange.highPrice * expensiveMultiplier);

            priceRange.highPrice *= 2; // General multiplier to inflate prices

            priceRange.lowPrice = (int)(priceRange.highPrice * confidence);

            PriceRange roundedRange = PriceRange.RoundPrices(priceRange);

            return(roundedRange);
        }
Пример #2
0
        public static void PriceRangesAreRoundedToAppealingNumbers(int inLowPrice, int inHighPrice, int expectedRoundedLowPrice, int expectedRoundedHighPrice)
        {
            PriceRange inputRange = new PriceRange
            {
                lowPrice  = inLowPrice,
                highPrice = inHighPrice,
            };

            PriceRange roundedRange = PriceRange.RoundPrices(inputRange);

            // Input range shouldn't be changed
            Assert.Equal(inLowPrice, inputRange.lowPrice);
            Assert.Equal(inHighPrice, inputRange.highPrice);

            Assert.Equal(expectedRoundedLowPrice, roundedRange.lowPrice);
            Assert.Equal(expectedRoundedHighPrice, roundedRange.highPrice);
        }