示例#1
0
        public void ShouldThrowInvalidInputExceptionWithCorrectMessage_WhenInvalidCustomerNameReceived()
        {
            var productsList        = new List <OrderItem>();
            var inputReader         = new MockInputReader(standardCSVHeaders, csvBodyWithOneOrder);
            var orderInputValidator = new MockOrderInputValidator();

            orderInputValidator.SetReturnToFalse("name");
            var    orderTaker = new CSVOrderTaker(inputReader, productsList, orderInputValidator);
            Action act        = () => orderTaker.CreateOrder();

            var exception = Assert.Throws <InvalidInputException>(act);

            Assert.Equal("Test Name is an invalid input - Name should start with alphabet letter and with the minimal length of 3 characters.", exception.Message);
        }
示例#2
0
        public void ShouldThrowInvalidInputException_WhenInvalidQuantityInputReceived()
        {
            var productsList        = new OrderItemsFactory().Create();
            var inputReader         = new MockInputReader(standardCSVHeaders, csvBodyWithOneOrder);
            var orderInputValidator = new MockOrderInputValidator();

            orderInputValidator.SetReturnToFalse("quantity");
            var    orderTaker = new CSVOrderTaker(inputReader, productsList, orderInputValidator);
            Action act        = () => orderTaker.CreateOrder();

            var exception = Assert.Throws <InvalidInputException>(act);

            Assert.Equal("8 is an invalid input - Quantity should be recorded in round number and within the range of 1 - 100.", exception.Message);
        }
示例#3
0
        public void ShouldThrowInvalidInputException_WhenInvalidDueDateInputReceived()
        {
            var productsList        = new List <OrderItem>();
            var inputReader         = new MockInputReader(standardCSVHeaders, csvBodyWithOneOrder);
            var orderInputValidator = new MockOrderInputValidator();

            orderInputValidator.SetReturnToFalse("dueDate");
            var    orderTaker = new CSVOrderTaker(inputReader, productsList, orderInputValidator);
            Action act        = () => orderTaker.CreateOrder();

            var exception = Assert.Throws <InvalidInputException>(act);

            Assert.Equal("19-Jan-21 is an invalid input - Date could not be in the past and should be in DD-MMM-YY format.", exception.Message);
        }
示例#4
0
        public void ShouldCreateMultipleOrders_WhenMultipleOrderDetailsRowsAreReceived()
        {
            var csvBodyWithTwoOrders = new List <string[]>
            {
                new string[]
                {
                    "Test Name", "Test Address", "19-Jan-21", "1", "2", "3", "4", "5", "6", "7", "8", "9"
                },
                new string[]
                {
                    "Test Name", "Test Address", "19-Jan-21", "1", "2", "3", "4", "5", "6", "7", "8", "9"
                },
            };
            var productsList        = new OrderItemsFactory().Create();
            var orderInputValidator = new MockOrderInputValidator();
            var inputReader         = new MockInputReader(standardCSVHeaders, csvBodyWithTwoOrders);
            var orderTaker          = new CSVOrderTaker(inputReader, productsList, orderInputValidator);
            var result = orderTaker.CreateOrder();

            Assert.Equal(2, result.Count);
        }