Ejemplo n.º 1
0
 private static string SerializeProtocolAsJsonString(ProtocolDescriptor descriptor)
 {
     using (var writer = new StringWriter())
     {
         ProtocolDescriptorJsonStorage.Save(writer, descriptor);
         return(writer.ToString());
     }
 }
Ejemplo n.º 2
0
        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);
            }
        }