static void Main(string[] args)
        {
            var input = "A,A,B,C,C,A,A,B,C,B,A";

            Console.WriteLine(AnotherApproach(input));

            var catalog = new Dictionary <char, IItemCalculator>()
            {
                { 'A', new DiscountItemCalculator(30, 50, 2) },
                { 'B', new SimpleItemCalculator(40) },
                { 'C', new DiscountItemCalculator(50, 120, 3) },
            };

            var calculator = new SuperMarketCalculator(catalog);

            var result = calculator.Calculate(input);

            Console.WriteLine(result);
            Console.ReadLine();
        }
示例#2
0
        public void Should_CalculateRightPrice_WhenInput(string input, int expectedPrice)
        {
            var result = calculator.Calculate(input);

            Assert.Equal(expectedPrice, result);
        }