public void ValidChangeSumShouldBeCalculate()
        {
            var input = new Dictionary<decimal, int>();
            input.Add(10m, 1);

            var calculator = new ChangeCalculator();
            var result = calculator.Calculate(input, 10);
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(1, result[10m]);

            input.Add(5m, 10);
            input.Add(2m, 10);
            input.Add(1m, 10);

            result = calculator.Calculate(input, 18);
            Assert.AreEqual(4, result.Count);
            Assert.AreEqual(1, result[10m]);
            Assert.AreEqual(1, result[5m]);
            Assert.AreEqual(1, result[2m]);
            Assert.AreEqual(1, result[1m]);

            input = new Dictionary<decimal, int>
            {
                { 10m, 1 },
                { 1m, 9 },
                { 0.1m, 10 }
            };

            result = calculator.Calculate(input, 9.4m);
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(9, result[1m]);
            Assert.AreEqual(4, result[0.1m]);

            input = new Dictionary<decimal, int>
            {
                { 10m, 10 },
                { 5m, 9 },
                { 3m, 10 }
            };

            result = calculator.Calculate(input, 18m);
            Assert.AreEqual(3, result.Count);
            Assert.AreEqual(1, result[3m]);
            Assert.AreEqual(1, result[5m]);
            Assert.AreEqual(1, result[10m]);

            input = new Dictionary<decimal, int>
            {
                { 10m, 10 },
                { 4m, 9 },
                { 3m, 10 }
            };

            result = calculator.Calculate(input, 15m);
            Assert.AreEqual(2, result.Count);
            Assert.AreEqual(1, result[3m]);
            Assert.AreEqual(3, result[4m]);
        }
        public void EmptyDictionaryShouldBeReturnedIsCalculationIsImpossible()
        {
            var input = new Dictionary<decimal, int>();

            var calculator = new ChangeCalculator();
            var result = calculator.Calculate(input, 0);
            Assert.AreEqual(0, result.Count, "Empty dictionary is expected if sum is 0");

            input.Add(10m, 1);
            result = calculator.Calculate(input, 11);
            Assert.AreEqual(0, result.Count, "Empty dictionary is expected if not enough values");

            input.Add(2m, 10);
            result = calculator.Calculate(input, 11);
            Assert.AreEqual(0, result.Count, "Empty dictionary is expected if it is impossible to calc a change");
        }
        public void Calculate_ValidChange_Test()
        {
            ChangeCalculator changeCalculator = new ChangeCalculator();

            CalculateRequest request = new CalculateRequest();

            request.ProductAmount = 1000;
            request.PaidAmount    = 2576;

            //uint expected100Bills = 0;
            //uint expected50Bills = 0;
            //uint expected20Bills = 0;
            uint expected10Bills = 1;
            uint expected5Bills  = 1;
            //uint expected2Bills = 0;

            //uint expected100Coins = 15;
            uint expected50Coins = 1;
            uint expected25Coins = 1;
            uint expected1Coins  = 1;

            CalculateResponse response = changeCalculator.Calculate(request);

            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.IsFalse(response.ErrorReportCollection.Any());


            Assert.AreEqual(5, response.Change.Count());
            Assert.AreEqual(expected10Bills, response.Change[1000]);
            Assert.AreEqual(expected5Bills, response.Change[500]);
            Assert.AreEqual(expected50Coins, response.Change[50]);
            Assert.AreEqual(expected25Coins, response.Change[25]);
            Assert.AreEqual(expected1Coins, response.Change[1]);
        }
        public void WriteToLog_Test()
        {
            ChangeCalculator changeCalculator = new ChangeCalculator();

            CalculateRequest request = new CalculateRequest();

            request.ProductAmount = 100;
            request.PaidAmount    = 150;

            CalculateResponse response = changeCalculator.Calculate(request);
        }
        public void Calculate_ChangeAmountZero_Test()
        {
            ChangeCalculator changeCalculator = new ChangeCalculator();
            CalculateRequest request          = new CalculateRequest();

            request.ProductAmount = 1000;
            request.PaidAmount    = 1000;

            CalculateResponse response = changeCalculator.Calculate(request);

            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
            Assert.IsFalse(response.ErrorReportCollection.Any());
        }
        public void PerformanceTest()
        {
            var input = new Dictionary<decimal, int>();
            input.Add(0.1m, Int32.MaxValue);
            input.Add(0.5m, Int32.MaxValue);
            input.Add(1m, Int32.MaxValue);
            input.Add(2m, Int32.MaxValue);
            input.Add(3m, Int32.MaxValue);
            input.Add(5m, Int32.MaxValue);
            input.Add(7m, Int32.MaxValue);
            input.Add(10m, Int32.MaxValue);

            var calculator = new ChangeCalculator();
            var result = calculator.Calculate(input, Int32.MaxValue);
        }