public void TestRestoreEmpty() { using (var stream = new MemoryStream()) { using (var writer = XmlWriter.Create(stream)) { writer.WriteStartElement("datasources"); writer.WriteEndElement(); } stream.Position = 0; using (var reader = XmlReader.Create(stream)) { reader.MoveToContent(); var actualSettings = new DataSourceSettings(); actualSettings.Restore(reader, out _); actualSettings.FolderDataSourceRecursive.Should().BeTrue(); actualSettings.FolderDataSourcePattern.Should().Be("*.txt;*.log"); } } }
private static DataSourceSettings Roundtrip(DataSourceSettings settings) { using (var stream = new MemoryStream()) { using (var writer = XmlWriter.Create(stream)) { writer.WriteStartElement("datasources"); settings.Save(writer); writer.WriteEndElement(); } stream.Position = 0; using (var reader = XmlReader.Create(stream)) { reader.MoveToContent(); var actualSettings = new DataSourceSettings(); actualSettings.Restore(reader, out _); return(actualSettings); } } }