Ejemplo n.º 1
0
        public void AddOrder_InvalidOrderListNull_ExceptArgumentException()
        {
            // arrange
            Customer customer = new Customer {
                ID = 1
            };
            DateTime         orderDate  = DateTime.Parse("30-03-2012", CultureInfo.GetCultureInfo("da-DK").DateTimeFormat);
            List <OrderBeer> orderBeers = null;

            Order order = new Order
            {
                ID = 1,
                AccumulatedPrice = 49.95,
                Customer         = customer,
                OrderCreated     = orderDate,
                OrderBeers       = orderBeers
            };

            IValidator validator = new BEValidator();

            // act + assert
            var ex = Assert.Throws <ArgumentException>(() => validator.ValidateOrder(order));

            Assert.Equal("Can not process order with no products", ex.Message);
        }
Ejemplo n.º 2
0
        public void AddOrder_InvalidOrderNewDate_ExceptArgumentException()
        {
            // arrange
            Customer customer = new Customer {
                ID = 1
            };
            DateTime         orderDate  = new DateTime();
            List <OrderBeer> orderBeers = new List <OrderBeer> {
                new OrderBeer {
                    BeerID = 1
                }
            };

            Order order = new Order
            {
                ID = 1,
                AccumulatedPrice = 49.95,
                Customer         = customer,
                OrderCreated     = orderDate,
                OrderBeers       = orderBeers
            };

            IValidator validator = new BEValidator();

            // act + assert
            var ex = Assert.Throws <ArgumentException>(() => validator.ValidateOrder(order));

            Assert.Equal("No order attached", ex.Message);
        }
Ejemplo n.º 3
0
        [InlineData(2, int.MinValue, "Price must be higher than zero")]       // invalid AccumulatedPrice: -2147483648
        public void AddOrder_InvalidOrder_ExceptArgumentException(int id, double price, string expectedErrorMsg)
        {
            // arrange
            Customer customer = new Customer {
                ID = 1
            };
            DateTime         orderDate  = DateTime.Parse("30-03-2012", CultureInfo.GetCultureInfo("da-DK").DateTimeFormat);
            List <OrderBeer> orderBeers = new List <OrderBeer> {
                new OrderBeer {
                    BeerID = 1
                }
            };

            Order order = new Order
            {
                ID = id,
                AccumulatedPrice = price,
                Customer         = customer,
                OrderCreated     = orderDate,
                OrderBeers       = orderBeers
            };

            IValidator validator = new BEValidator();

            // act + assert
            var ex = Assert.Throws <ArgumentException>(() => validator.ValidateOrder(order));

            Assert.Equal(expectedErrorMsg, ex.Message);
        }
Ejemplo n.º 4
0
        public void AddOrder_ValidOrder(int id, double price)
        {
            // arrange
            Customer customer = new Customer {
                ID = 1
            };
            DateTime         orderDate  = DateTime.Parse("30-03-2012", CultureInfo.GetCultureInfo("da-DK").DateTimeFormat);
            List <OrderBeer> orderBeers = new List <OrderBeer> {
                new OrderBeer {
                    BeerID = 1
                }
            };

            Order order = new Order
            {
                ID = id,
                AccumulatedPrice = price,
                Customer         = customer,
                OrderCreated     = orderDate,
                OrderBeers       = orderBeers
            };

            IValidator validator = new BEValidator();

            // act + assert
            validator.ValidateOrder(order);
        }
Ejemplo n.º 5
0
        public void AddOrder_InvalidOrderNull_ExceptArgumentException()
        {
            // arrange
            Order      order     = null;
            IValidator validator = new BEValidator();

            // act + assert
            var ex = Assert.Throws <ArgumentException>(() => validator.ValidateOrder(order));

            Assert.Equal("Order instance can't be null", ex.Message);
        }