Beispiel #1
0
 public async Task WriteMessageAsync_ValidatesNullArgument_Async()
 {
     await using (var protocol = new MuxerProtocol(Stream.Null, ownsStream: true, NullLogger <MuxerProtocol> .Instance))
     {
         await Assert.ThrowsAsync <ArgumentNullException>("message", () => protocol.WriteMessageAsync(null, default)).ConfigureAwait(false);
     }
 }
Beispiel #2
0
        public async Task DisposeAsync_DisposesStreamIfNeeded_Async(bool ownsStream)
        {
            var stream = new Mock <Stream>(MockBehavior.Strict);

            if (ownsStream)
            {
                stream.Setup(s => s.DisposeAsync()).Returns(ValueTask.CompletedTask).Verifiable();
            }

            var protocol = new MuxerProtocol(stream.Object, ownsStream, NullLogger <MuxerProtocol> .Instance);
            await protocol.DisposeAsync();

            stream.Verify();
        }
Beispiel #3
0
        public async Task WriteMessageAsync_SerializesCorrectly_Async()
        {
            await using (MemoryStream stream = new MemoryStream())
                await using (var protocol = new MuxerProtocol(stream, ownsStream: true, NullLogger <MuxerProtocol> .Instance))
                {
                    await protocol.WriteMessageAsync(
                        new RequestMessage()
                    {
                        MessageType         = MuxerMessageType.ListDevices,
                        BundleID            = "com.apple.iTunes",
                        ClientVersionString = "usbmuxd-374.70",
                        ProgName            = "iTunes",
                    },
                        default).ConfigureAwait(false);

                    var actual   = stream.ToArray();
                    var expected = File.ReadAllBytes("Muxer/list-request.bin");

                    Assert.Equal(
                        expected,
                        actual);
                }
        }
Beispiel #4
0
        public async Task Constructor_InitializesProperties_Async()
        {
            await using var protocol = new MuxerProtocol(Stream.Null, ownsStream: false, NullLogger <MuxerProtocol> .Instance);

            Assert.Equal(Stream.Null, protocol.Stream);
        }
Beispiel #5
0
 public async Task ReadMessageAsync_CanReadPropertyList_Async()
 {
     await using (Stream stream = File.OpenRead("Muxer/list-response.bin"))
         await using (var protocol = new MuxerProtocol(stream, ownsStream: true, NullLogger <MuxerProtocol> .Instance))
         {
             var value = await protocol.ReadMessageAsync(