public void should_validate_each_object_within_an_enumerable_property()
        {
            var model = new ContactModel
                            {
                                FirstName = "Test",
                                LastName = "Contact",
                                Addresses = new List<AddressModel>
                                                {
                                                    new AddressModel // Missing country
                                                        {
                                                            Address1 = "1234 Test Lane",
                                                            City = "Austin",
                                                            StateOrProvince = "TX",
                                                            PostalCode = "78701"
                                                        },
                                                    new AddressModel // Missing postal code
                                                        {
                                                            Address1 = "1234 Test Lane",
                                                            City = "Austin",
                                                            StateOrProvince = "TX",
                                                            Country = "US"
                                                        }
                                                }
                            };

            var notification = _provider.Validate(model);
            var messages = notification.AllMessages;

            var country = AccessorFactory.Create<AddressModel>(m => m.Country);
            var postalCode = AccessorFactory.Create<AddressModel>(m => m.PostalCode);

            messages.ShouldContain(m => m.Accessors.Any(a => a.Equals(country)));
            messages.ShouldContain(m => m.Accessors.Any(a => a.Equals(postalCode)));
        }
        public void should_validate_collection_length_for_enumerable_property()
        {
            var model = new ContactModel
                            {
                                FirstName = "Test",
                                LastName = "Contact"
                            };

            var notification = _provider.Validate(model);
            var messages = notification.AllMessages;
            var addresses = AccessorFactory.Create<ContactModel>(m => m.Addresses);

            messages
                .ShouldContain(m => m.Accessors.Any(a => a.Equals(addresses)));
        }
        public void SetUp()
        {
            theModel = new ContactModel();
            theType = theModel.GetType();

            r1 = MockRepository.GenerateStub<IValidationRule>();
            r2 = MockRepository.GenerateStub<IValidationRule>();
            r3 = MockRepository.GenerateStub<IValidationRule>();

            theMatchingSource = ConfiguredValidationSource.For(type => type == theType, r1, r2);
            theOtherSource = ConfiguredValidationSource.For(type => type == typeof(int), r3);

            theGraph = ValidationGraph.BasicGraph();
            theGraph.RegisterSource(theMatchingSource);
            theGraph.RegisterSource(theOtherSource);

            theContext = ValidationContext.For(theModel);

            thePlan = ValidationPlan.For(theType, theGraph);
        }