예제 #1
0
        public async Task JsonModel_SeresBasic_ShouldValidate()
        {
            var json       = EmbeddedResource.LoadDataFromEmbeddedResourceAsString(SERESBASIC_JSON_RESOURCE);
            var jsonSchema = await EmbeddedResource.LoadDataFromEmbeddedResourceAsJsonSchema(SERESBASIC_JSON_SCHEMA_RESOURCE);

            var jsonDocument = JsonDocument.Parse(json);

            var validationResults = jsonSchema.Validate(jsonDocument.RootElement, new ValidationOptions()
            {
                OutputFormat = OutputFormat.Detailed
            });

            validationResults.IsValid.Should().BeTrue();
        }
예제 #2
0
        public async Task CSharpModel_SeresBasic_ShouldSerializeToValidJson()
        {
            JsonSchemaKeywords.RegisterXsdKeywords();
            var melding = new _TestData.Model.CSharp.melding()
            {
                E1 = "Yo"
            };

            var json       = JsonSerializer.Serialize(melding);
            var jsonSchema = await EmbeddedResource.LoadDataFromEmbeddedResourceAsJsonSchema(SERESBASIC_JSON_SCHEMA_RESOURCE);

            var jsonDocument = JsonDocument.Parse(json);

            var validationResults = jsonSchema.Validate(jsonDocument.RootElement, new ValidationOptions()
            {
                OutputFormat = OutputFormat.Detailed
            });

            validationResults.IsValid.Should().BeTrue();
        }