public async Task AcknowledgePrivateMessageAsync_Throws_InvalidOperationException_When_Not_Connected() { var s = new SoulseekClient(); var ex = await Record.ExceptionAsync(async() => await s.AcknowledgePrivateMessageAsync(1)); Assert.NotNull(ex); Assert.IsType <InvalidOperationException>(ex); }
public async Task AcknowledgePrivateMessageAsync_Throws_ArgumentException_When_ID_Is_Less_Than_0() { using (var s = new SoulseekClient()) { var ex = await Record.ExceptionAsync(() => s.AcknowledgePrivateMessageAsync(-1)); Assert.NotNull(ex); Assert.IsType <ArgumentException>(ex); } }
public async Task AcknowledgePrivateMessageAsync_Does_Not_Throw_When_Write_Does_Not_Throw() { var s = new SoulseekClient(); s.SetProperty("State", SoulseekClientStates.Connected | SoulseekClientStates.LoggedIn); var ex = await Record.ExceptionAsync(async() => await s.AcknowledgePrivateMessageAsync(1)); Assert.Null(ex); }
public async Task AcknowledgePrivateMessageAsync_Throws_InvalidOperationException_When_Not_Logged_In() { using (var s = new SoulseekClient()) { s.SetProperty("State", SoulseekClientStates.Connected); var ex = await Record.ExceptionAsync(() => s.AcknowledgePrivateMessageAsync(1)); Assert.NotNull(ex); Assert.IsType <InvalidOperationException>(ex); } }
public async Task AcknowledgePrivateMessageAsync_Does_Not_Throw_When_Write_Does_Not_Throw() { var conn = new Mock <IMessageConnection>(); conn.Setup(m => m.State) .Returns(ConnectionState.Connected); using (var s = new SoulseekClient(serverConnection: conn.Object)) { s.SetProperty("State", SoulseekClientStates.Connected | SoulseekClientStates.LoggedIn); var ex = await Record.ExceptionAsync(() => s.AcknowledgePrivateMessageAsync(1)); Assert.Null(ex); } }
public async Task AcknowledgePrivateMessageAsync_Throws_OperationCanceledException_When_Write_Is_Canceled() { var conn = new Mock <IMessageConnection>(); conn.Setup(m => m.WriteAsync(It.IsAny <IOutgoingMessage>(), It.IsAny <CancellationToken>())) .Throws(new OperationCanceledException()); using (var s = new SoulseekClient(serverConnection: conn.Object)) { s.SetProperty("State", SoulseekClientStates.Connected | SoulseekClientStates.LoggedIn); var ex = await Record.ExceptionAsync(() => s.AcknowledgePrivateMessageAsync(1, CancellationToken.None)); Assert.NotNull(ex); Assert.IsType <OperationCanceledException>(ex); } }
public async Task AcknowledgePrivateMessageAsync_Throws_PrivateMessageException_When_Write_Throws() { var conn = new Mock <IMessageConnection>(); conn.Setup(m => m.WriteMessageAsync(It.IsAny <Message>(), It.IsAny <CancellationToken>())) .Throws(new ConnectionWriteException()); var s = new SoulseekClient("127.0.0.1", 1, serverConnection: conn.Object); s.SetProperty("State", SoulseekClientStates.Connected | SoulseekClientStates.LoggedIn); var ex = await Record.ExceptionAsync(async() => await s.AcknowledgePrivateMessageAsync(1)); Assert.NotNull(ex); Assert.IsType <PrivateMessageException>(ex); Assert.IsType <ConnectionWriteException>(ex.InnerException); }
public async Task AcknowledgePrivateMessageAsync_Throws_TimeoutException_When_Write_Times_Out() { var conn = new Mock <IMessageConnection>(); conn.Setup(m => m.WriteAsync(It.IsAny <byte[]>(), It.IsAny <CancellationToken>())) .Throws(new TimeoutException()); using (var s = new SoulseekClient("127.0.0.1", 1, serverConnection: conn.Object)) { s.SetProperty("State", SoulseekClientStates.Connected | SoulseekClientStates.LoggedIn); var ex = await Record.ExceptionAsync(async() => await s.AcknowledgePrivateMessageAsync(1, CancellationToken.None)); Assert.NotNull(ex); Assert.IsType <TimeoutException>(ex); } }