public void SchemaNull_MappingNull_no_errors()
        {
            var rule        = new UniqueKeyMatchesMappingRule();
            var schema      = new SolrSchema();
            var validations = rule.Validate(typeof(SchemaMappingTestDocument), schema, new MappingManager()).ToList();

            Assert.IsNotNull(validations);
            Assert.AreEqual(0, validations.Count);
        }
        public void SchemaNotNull_MappingNull_generates_warning()
        {
            var rule   = new UniqueKeyMatchesMappingRule();
            var schema = new SolrSchema {
                UniqueKey = "id"
            };
            var validations = rule.Validate(typeof(SchemaMappingTestDocument), schema, new MappingManager()).ToList();

            Assert.IsNotNull(validations);
            Assert.AreEqual(1, validations.Count);
            foreach (var v in validations)
            {
                Console.WriteLine("{0}: {1}", v.GetType(), v.Message);
            }
            Assert.IsInstanceOf <ValidationWarning>(validations[0]);
        }
Ejemplo n.º 3
0
        public void SchemaNotNull_MappingNull_generates_warning()
        {
            var rule   = new UniqueKeyMatchesMappingRule();
            var schema = new SolrSchema {
                UniqueKey = "id"
            };
            var validations = rule.Validate(typeof(SchemaMappingTestDocument), schema, new MappingManager()).ToList();

            Assert.NotNull(validations);
            Assert.Single(validations);
            foreach (var v in validations)
            {
                testOutputHelper.WriteLine("{0}: {1}", v.GetType(), v.Message);
            }
            Assert.IsType <ValidationWarning>(validations[0]);
        }
        public void SchemaNull_MappingNotNull_generates_error()
        {
            var rule       = new UniqueKeyMatchesMappingRule();
            var mapper     = new MappingManager();
            var idProperty = typeof(SchemaMappingTestDocument).GetProperty("ID");

            mapper.Add(idProperty);
            mapper.SetUniqueKey(idProperty);
            var validations = rule.Validate(typeof(SchemaMappingTestDocument), new SolrSchema(), mapper).ToList();

            Assert.IsNotNull(validations);
            Assert.AreEqual(1, validations.Count);
            foreach (var v in validations)
            {
                Console.WriteLine("{0}: {1}", v.GetType(), v.Message);
            }
            Assert.IsInstanceOf <ValidationError>(validations[0]);
        }