public void Test()
        {
            var clientId = Guid.NewGuid();
            var expected = new Operation(OperationType.Delete, new Char(new CharId(clientId, 0), "1", Char.Begin.Id, Char.End.Id));
            var actual   = OperationSerializer.Deserialize(OperationSerializer.Serialize(expected));

            Console.WriteLine(clientId);
            Console.WriteLine(OperationSerializer.Serialize(expected));
            Assert.AreEqual(JsonConvert.SerializeObject(expected), JsonConvert.SerializeObject(actual));
        }
Пример #2
0
 private static string SerializeOperations(IEnumerable <TestOperation> operations)
 {
     using (var stream = new MemoryStream())
         using (var writer = new StreamWriter(stream))
             using (var reader = new StreamReader(stream))
             {
                 OperationSerializer.Serialize(writer, operations);
                 stream.Position = 0;
                 return(reader.ReadToEnd());
             }
 }
Пример #3
0
        private static void DumpOperations(string clipTitle, IEnumerable <TestOperation> operations)
        {
            var testName = NUnit.Framework.TestContext.CurrentContext.Test.Name
                           .Replace(" ", "-");
            var testDate = DateTime.Now.TimeOfDay.ToString()
                           .Replace(" ", "-")
                           .Replace(":", "-");
            var pid = Process.GetCurrentProcess().Id;

            var fullPath = Path.Combine(Path.GetTempPath(), $"{testName}_{pid}_{testDate}");

            using (var writer = new StreamWriter(fullPath))
            {
                writer.WriteLine(clipTitle);
                OperationSerializer.Serialize(writer, operations);
                Console.WriteLine($"Test operations dumped to {fullPath}");
            }
        }