public void ValidateFormats(FileFormatVersions version) { byte[] Roundtrip() { var data = SdbSchemaData.GetSchemaData(version); using (var ms = new MemoryStream()) { data.SerializeSdbData(ms); return(ms.ToArray()); } } byte[] GetStream() { using (var stream = SdbSchemaData.GetStream(version, SdbSchemaData.Constraints)) using (var ms = new MemoryStream()) { stream.CopyTo(ms); return(ms.ToArray()); } } var expected = GetStream(); var actual = Roundtrip(); Assert.Equal(expected.Length, actual.Length); Assert.Equal(expected, actual); }
/// <summary> /// Initializes a new instance of the SchemaValidator. /// </summary> /// <param name="fileFormat">The target Open XML format.</param> /// <exception cref="ArgumentOutOfRangeException">Thrown when the "fileFormat" parameter is not FileFormat.Office2007, FileFormat.Office2010 or FileFormat.O15.</exception> public SchemaValidator(FileFormatVersions fileFormat) { _sdbSchemaDatas = SdbSchemaData.GetSchemaData(fileFormat); _schemaTypeValidator = new SchemaTypeValidator(_sdbSchemaDatas); }
/// <summary> /// Initializes a new instance of the SchemaTypeValidator. /// </summary> /// <param name="sdbSchemaDatas"></param> internal SchemaTypeValidator(SdbSchemaData sdbSchemaDatas) { _sdbSchemaDatas = sdbSchemaDatas; }