public void Where_evaluates_preconditions()
        {
            var conventions = new ConventionsConfiguration();
            var entities    = new TypeConventionConfiguration(conventions);

            var ex = Assert.Throws <ArgumentNullException>(
                () => entities.Where(null));

            Assert.Equal("predicate", ex.ParamName);
        }
        public void Where_configures_predicates()
        {
            Func <Type, bool> predicate1 = t => true;
            Func <Type, bool> predicate2 = t => false;
            var conventions = new ConventionsConfiguration();
            var entities    = new TypeConventionConfiguration(conventions);

            var config = entities
                         .Where(predicate1)
                         .Where(predicate2);

            Assert.NotNull(config);
            Assert.Same(conventions, config.ConventionsConfiguration);
            Assert.Equal(2, config.Predicates.Count());
            Assert.Same(predicate2, config.Predicates.Last());
        }
        public void Having_configures_capturing_predicate()
        {
            var conventions = new ConventionsConfiguration();
            var entities    = new TypeConventionConfiguration(conventions);
            Func <Type, bool>   predicate          = t => true;
            Func <Type, object> capturingPredicate = t => null;

            var config = entities
                         .Where(predicate)
                         .Having(capturingPredicate);

            Assert.NotNull(config);
            Assert.Same(conventions, config.ConventionsConfiguration);
            Assert.Equal(1, config.Predicates.Count());
            Assert.Same(predicate, config.Predicates.Single());
            Assert.Same(capturingPredicate, config.CapturingPredicate);
        }
        public void Configure_adds_convention()
        {
            Func <Type, bool> predicate = t => true;
            Action <ConventionTypeConfiguration> configurationAction = c => { };
            var conventions = new ConventionsConfiguration();
            var entities    = new TypeConventionConfiguration(conventions);

            entities
            .Where(predicate)
            .Configure(configurationAction);

            Assert.Equal(16, conventions.ConfigurationConventions.Count());

            var convention = (TypeConvention)conventions.ConfigurationConventions.Last();

            Assert.Equal(1, convention.Predicates.Count());
            Assert.Same(predicate, convention.Predicates.Single());
            Assert.Same(configurationAction, convention.EntityConfigurationAction);
        }