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); } }
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(); }
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); } }
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); }
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(