예제 #1
0
        /// <summary>
        /// Checks whether given order can be added.
        /// Performs logical and business validation.
        /// </summary>
        public ValidationResult ValidateNewOrder(Order newOrder)
        {
            var result = ValidationResult.Default;

            if (newOrder == null)
            {
                throw new ArgumentNullException("newOrder");
            }

            var items = queryAllItems.Execute();

            foreach (var item in newOrder.OrderItems)
            {
                if (item.Value <= 0)
                {
                    result |= ValidationResult.NoItemQuantity;
                }
                if (!items.Any(p => p.Id == item.Key))
                {
                    result |= ValidationResult.ItemDoesNotExist;
                }
            }

            if (result == ValidationResult.Default)
            {
                result = ValidationResult.Ok;
            }

            return(result);
        }
예제 #2
0
        public void TestExecuteShouldReturnXAxisGridLines()
        {
            var results = _query.Execute(_controlSize);

            Assert.That(results, Has.Member(_xGridLine));
        }
예제 #3
0
 /// <summary>
 /// Lists all items that exist in db
 /// </summary>
 public IEnumerable <Item> All()
 {
     return(_query.Execute().ToList());
 }