示例#1
0
        public void Validate_WhenCollectionMissingOptionalProperty_ReturnsTrue()
        {
            var schema = new PropertyCollectionSchemaBuilder()
                         .Add(new PropertyCollectionSchemaEntryBuilder(SharedDefinition))
                         .Build();

            var collection = new PropertyCollection();

            Assert.IsTrue(schema.Validate(collection));
        }
示例#2
0
        public void Validate_WhenCollectionHasRequiredProperty_ReturnsTrue()
        {
            var schema = new PropertyCollectionSchemaBuilder()
                         .Add(new PropertyCollectionSchemaEntryBuilder(SharedDefinition)
                              .AsRequired())
                         .Build();

            var collection = new PropertyCollection();

            collection.GetProperty(SharedDefinition);

            Assert.IsTrue(schema.Validate(collection));
        }
示例#3
0
        public void Validate_WhenCollectionHasPropertyOfWrongType_ReturnsFalse()
        {
            var sharedName = "ConflictingProperty";

            var existingDefinition = new PropertyDefinition <string>(sharedName);
            var schemaDefinition   = new PropertyDefinition <int>(sharedName);
            var schema             = new PropertyCollectionSchemaBuilder()
                                     .Add(new PropertyCollectionSchemaEntryBuilder(schemaDefinition))
                                     .Build();

            var collection = new PropertyCollection();

            collection.GetProperty(existingDefinition);

            Assert.IsFalse(schema.Validate(collection));
        }