public void Parsed_ShouldReturnParsedSchemaContents() { string contents = SchemaFixtureUtils.GetProtoBuf("ValidSchema"); var schema = new ProtoBufSchema( Guid.NewGuid(), new SchemaGroupAggregate.Schemas.Version(1), contents); FileDescriptorSet descriptor = schema.Parsed; Assert.NotNull(descriptor); Assert.Empty(descriptor.GetErrors()); }
public void AddSchema_TransitivelyForwardIncompatibleWithOlderSchemas_ShouldReturnRuleViolations() { this.ruleMock .Setup(rule => rule.Validate(It.Is <ProtoBufSchema>(schema => schema.Version == Version.Initial.Next()), It.IsAny <ProtoBufSchema>())) .Returns(new ValidationResult(true, this.fixture.Create <string>())); this.ruleMock .Setup(rule => rule.Validate(It.Is <ProtoBufSchema>(schema => schema.Version == Version.Initial), It.IsAny <ProtoBufSchema>())) .Returns(new ValidationResult(false, this.fixture.Create <string>())); this.schemaFactoryMock .Setup(factory => factory.CreateNew(It.IsAny <Version>(), It.IsAny <string>())) .Returns(new ProtoBufSchema(Guid.NewGuid(), Version.Initial.Next().Next(), string.Empty)); var groupId = this.fixture.Create <Guid>(); var firstSchema = new ProtoBufSchema(Guid.NewGuid(), Version.Initial, string.Empty); var previousSchema = new ProtoBufSchema(Guid.NewGuid(), Version.Initial.Next(), string.Empty); var schemaGroup = new SchemaGroup <FileDescriptorSet>( groupId, this.fixture.Create <string>(), new List <Schema <FileDescriptorSet> > { firstSchema, previousSchema }, new List <Rule <FileDescriptorSet> > { this.ruleMock.Object }); var config = new ConfigurationSet( this.fixture.Create <Guid>(), new Dictionary <RuleCode, RuleConfig> { { RuleCode.R0001, new RuleConfig(false, Severity.Error) }, }, groupId, false, true, false, true); IEnumerable <RuleViolation> ruleViolations = schemaGroup.AddSchema( this.fixture.Create <string>(), config, this.schemaFactoryMock.Object); Assert.NotEmpty(ruleViolations); }
public void AddSchema_WithBackwardIncompatibleContentsAndDisabledBackwardCompatibility_ShouldAddSchema() { this.ruleMock .Setup(rule => rule.Validate(It.IsAny <ProtoBufSchema>(), It.Is <ProtoBufSchema>(schema => schema.Version == Version.Initial))) .Returns(new ValidationResult(false, this.fixture.Create <string>())); this.ruleMock .Setup(rule => rule.Validate(It.Is <ProtoBufSchema>(schema => schema.Version == Version.Initial), It.IsAny <ProtoBufSchema>())) .Returns(new ValidationResult(true, this.fixture.Create <string>())); this.schemaFactoryMock .Setup(factory => factory.CreateNew(It.IsAny <Version>(), It.IsAny <string>())) .Returns(new ProtoBufSchema(Guid.NewGuid(), Version.Initial.Next().Next(), string.Empty)); var groupId = this.fixture.Create <Guid>(); var firstSchema = new ProtoBufSchema(Guid.NewGuid(), Version.Initial, string.Empty); var schemaGroup = new SchemaGroup <FileDescriptorSet>( groupId, this.fixture.Create <string>(), new List <Schema <FileDescriptorSet> > { firstSchema }, new List <Rule <FileDescriptorSet> > { this.ruleMock.Object }); var config = new ConfigurationSet( this.fixture.Create <Guid>(), new Dictionary <RuleCode, RuleConfig> { { RuleCode.R0001, new RuleConfig(false, Severity.Error) }, }, groupId, false, true, false, false); schemaGroup.AddSchema( this.fixture.Create <string>(), config, this.schemaFactoryMock.Object); Assert.Equal(2, schemaGroup.Schemas.Count); }