예제 #1
0
파일: Request.cs 프로젝트: kittinap/kunnjae
        /// <summary>
        /// Deserializes on object of this type from a stream reader.
        /// </summary>
        /// <remarks>
        /// Doesn't handle any exceptions.
        /// </remarks>
        public static async Task <Request> DeserializeAsync(Stream reader, CancellationToken token)
        {
            var id = await Utils.ReadIntAsync(reader, token);

            var operation = await IpcOperation.DeserializeAsync(reader, token);

            var request = new Request(id, operation);

            return(request);
        }
예제 #2
0
        public async Task TestIpcOperationSerializeAsync(string payload, bool waitForAck)
        {
            var ipcOp = new IpcOperation(payload, waitForAck);

            // serialize
            using var stream = new MemoryStream();
            await ipcOp.SerializeAsync(stream, CancellationToken.None);

            // reset stream position and deserialize
            stream.Position = 0;
            var ipcOpClone = await IpcOperation.DeserializeAsync(stream, CancellationToken.None);

            // compare
            var errMessage = $"Cloning failed:\n - original: {ipcOp}\n - clone: {ipcOpClone}";

            XAssert.AreEqual(payload, ipcOpClone.Payload, errMessage);
            XAssert.AreEqual(waitForAck, ipcOpClone.ShouldWaitForServerAck, errMessage);
        }