Exemple #1
0
        public void ExpectedOutputTest()
        {
            //Arrange
            string[] processedInput = InputGenerator.GenerateTestInput(new string[] { "5",
                                                                                      "3 1 2 3",
                                                                                      "2 1 1",
                                                                                      "4 10 5 5 1",
                                                                                      "0",
                                                                                      "1 2" });

            //Act
            OrderInputParser orderInputParser = new OrderInputParser();

            TotalPrizeMoneyCalculator totalPrizeMoneyCalculator = new TotalPrizeMoneyCalculator(orderInputParser.ParseOrders(processedInput));

            //Assert
            Assert.AreEqual(19, totalPrizeMoneyCalculator.CalculateTotal());
        }
Exemple #2
0
        public void NegativeDayOrderAmount()
        {
            //Arrange
            string[] processedInput = InputGenerator.GenerateTestInput(new string[] { "1",
                                                                                      "-2 4  3" });

            //Act
            try
            {
                //Act
                OrderInputParser          orderInputParser          = new OrderInputParser();
                TotalPrizeMoneyCalculator totalPrizeMoneyCalculator = new TotalPrizeMoneyCalculator(orderInputParser.ParseOrders(processedInput));
                totalPrizeMoneyCalculator.CalculateTotal();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Issue During Parsing Invalid Character Detected - Check Input", ex.InnerException.Message);
            }
        }
Exemple #3
0
        public void CampaignDayAmountOrderlineMisMatch2()
        {
            //Arrange
            string[] processedInput = InputGenerator.GenerateTestInput(new string[] { "2",
                                                                                      "3 1 2 3" });

            //Act
            try
            {
                //Act
                OrderInputParser          orderInputParser          = new OrderInputParser();
                TotalPrizeMoneyCalculator totalPrizeMoneyCalculator = new TotalPrizeMoneyCalculator(orderInputParser.ParseOrders(processedInput));
                totalPrizeMoneyCalculator.CalculateTotal();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Campaign Day Amout Does Not Match Order Detail Lines Sum", ex.Message);
            }
        }
Exemple #4
0
        public void GreaterThenValidTotalOrderAmount()
        {
            //Arrange
            string[] processedInput = InputGenerator.GenerateTestInput(new string[] { "1",
                                                                                      "10 100000 100000 100000 100000 100000 100000 100000 100000 100000 100001" });

            //Act
            try
            {
                //Act
                OrderInputParser          orderInputParser          = new OrderInputParser();
                TotalPrizeMoneyCalculator totalPrizeMoneyCalculator = new TotalPrizeMoneyCalculator(orderInputParser.ParseOrders(processedInput));
                totalPrizeMoneyCalculator.CalculateTotal();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Total order amount cannot exceed 1000000", ex.Message);
            }
        }
Exemple #5
0
        public void GreaterThenValidDayOrderAmount()
        {
            //Arrange
            string[] processedInput = InputGenerator.GenerateTestInput(new string[] { "1",
                                                                                      "100001 4  3" });

            //Act
            try
            {
                //Act
                OrderInputParser          orderInputParser          = new OrderInputParser();
                TotalPrizeMoneyCalculator totalPrizeMoneyCalculator = new TotalPrizeMoneyCalculator(orderInputParser.ParseOrders(processedInput));
                totalPrizeMoneyCalculator.CalculateTotal();
            }
            catch (Exception ex)
            {
                Assert.AreEqual("Invalid Day Amount Detected - Ensure Each Day Amount Is Valid", ex.InnerException.Message);
            }
        }
Exemple #6
0
        public void StressTest()
        {
            bool passed = false;

            try
            {
                //Arrange
                string[] processedInput = InputGenerator.GenerateTestInput(1000, 1000, "1");

                //Act
                OrderInputParser          orderInputParser          = new OrderInputParser();
                TotalPrizeMoneyCalculator totalPrizeMoneyCalculator = new TotalPrizeMoneyCalculator(orderInputParser.ParseOrders(processedInput));
                int totalGivenPrizeMoeny = totalPrizeMoneyCalculator.CalculateTotal();

                passed = true;
            }
            catch (Exception ex)
            {
            }

            //Assert
            Assert.AreEqual(true, passed);
        }