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"); }
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()); }
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(); }
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(); }
public void XmlModel_SeresBasic_ShouldDeserializeAndValidate() { _TestData.Model.CSharp.melding melding = DeserializeFromXmlResource(SERESBASIC_XML_RESOURCE); melding.E1.Should().Be("Yo"); }