public void FilterSpecificationsAreNotSatisfiedBy_UseGroup_AllSatisfied()
        {
            var Customer = new Customer (){ Age = 18, Name = "Test name" };

            var not = SpecificationService.FilterSpecificationsAreNotSatisfiedBy<Customer> (Customer, "Sell");

            Assert.AreEqual (0, not.Length);
        }
        public void FilterSpecificationsAreNotSatisfiedBy_UseGroup_OneNotSatisfied()
        {
            var Customer = new Customer (){ Age = 10,  Name = "Test name" };

            var not = SpecificationService.FilterSpecificationsAreNotSatisfiedBy<Customer> (Customer, "Sell");

            Assert.AreEqual (1, not.Length);

            not = SpecificationService.FilterSpecificationsAreNotSatisfiedBy<Customer> (Customer, SampleSpecificationGroup.Save);

            Assert.AreEqual (1, not.Length);
        }
        public ActionResult Create(Customer customer)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    CustomerService.CreateCustomer(customer);
                }

                return View();
            }
            catch(Exception ex)
            {
                ViewBag.ErrorMessage = ex.Message;

                return View();
            }
        }
        public static void CreateCustomer(Customer customer)
        {
            SpecificationService.ThrowIfAnySpecificationIsNotSatisfiedBy(customer, new CustomerCreationSpecification());

            // TODO: Logic to create customer...
        }
        public void ThrowIfAnySpecificationIsNotSatisfiedBy_UseGroup_ThrowsException()
        {
            var customer = new Customer (){ Age = 15, Name = "Test name" };

            ExceptionAssert.IsThrowing (new SpecificationNotSatisfiedException ("Customer must be at least 18 yers old."), () =>
            {
                SpecificationService.ThrowIfAnySpecificationIsNotSatisfiedBy (customer, "Sell");
            });
        }
        public void ThrowIfAnySpecificationIsNotSatisfiedBy_UseGroup_AllSatisfied()
        {
            var customer = new Customer (){ Age = 18, Name = "Test name" };

            SpecificationService.ThrowIfAnySpecificationIsNotSatisfiedBy (customer, "Sell");
        }