Beispiel #1
0
        public void JsonModel_SeresBasic_ShouldDeserializeAndValidate()
        {
            var json = EmbeddedResource.LoadDataFromEmbeddedResourceAsString(SERESBASIC_JSON_RESOURCE);

            _TestData.Model.CSharp.melding melding = JsonSerializer.Deserialize <_TestData.Model.CSharp.melding>(json);

            melding.E1.Should().Be("Yo");
        }
Beispiel #2
0
        private static string SerializeToXml(_TestData.Model.CSharp.melding melding)
        {
            var xmlSerializer = new System.Xml.Serialization.XmlSerializer(typeof(_TestData.Model.CSharp.melding));
            var xmlWriter     = new Utf8StringWriter();

            xmlSerializer.Serialize(xmlWriter, melding);

            return(xmlWriter.ToString());
        }
Beispiel #3
0
        public void CSharpModel_SeresBasic_ShouldSerializeToValidXml()
        {
            var melding = new _TestData.Model.CSharp.melding()
            {
                E1 = "Yo"
            };

            var xml = SerializeToXml(melding);

            bool validXml = ValidateXml(xml);

            validXml.Should().BeTrue();
        }
Beispiel #4
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();
        }
Beispiel #5
0
        public void XmlModel_SeresBasic_ShouldDeserializeAndValidate()
        {
            _TestData.Model.CSharp.melding melding = DeserializeFromXmlResource(SERESBASIC_XML_RESOURCE);

            melding.E1.Should().Be("Yo");
        }