private static string SerializeProtocolAsJsonString(ProtocolDescriptor descriptor) { using (var writer = new StringWriter()) { ProtocolDescriptorJsonStorage.Save(writer, descriptor); return(writer.ToString()); } }
public void WhenSavingWithDefaultSettings_ThenOutputFileIsUtf8Encoded() { var tempFilePath = Path.GetTempFileName(); try { var protocol = ProtocolFactory.CreateTest(); ProtocolDescriptorJsonStorage.Save(tempFilePath, protocol); Assert.True((new FileInfo(tempFilePath)).Length > 0); Assert.Equal(SerializeProtocolAsJsonString(protocol), File.ReadAllText(tempFilePath, Encoding.UTF8)); } finally { File.Delete(tempFilePath); } }