Exemple #1
0
        public async Task AcknowledgePrivilegeNotificationAsync_Throws_InvalidOperationException_When_Not_Connected()
        {
            using (var s = new SoulseekClient())
            {
                var ex = await Record.ExceptionAsync(() => s.AcknowledgePrivilegeNotificationAsync(1));

                Assert.NotNull(ex);
                Assert.IsType <InvalidOperationException>(ex);
            }
        }
Exemple #2
0
        public async Task AcknowledgePrivilegeNotificationAsync_Throws_ArgumentException_When_ID_Is_Less_Than_0()
        {
            using (var s = new SoulseekClient())
            {
                var ex = await Record.ExceptionAsync(() => s.AcknowledgePrivilegeNotificationAsync(-1));

                Assert.NotNull(ex);
                Assert.IsType <ArgumentException>(ex);
            }
        }
Exemple #3
0
        public async Task AcknowledgePrivilegeNotificationAsync_Throws_InvalidOperationException_When_Not_Logged_In()
        {
            using (var s = new SoulseekClient())
            {
                s.SetProperty("State", SoulseekClientStates.Connected);

                var ex = await Record.ExceptionAsync(() => s.AcknowledgePrivilegeNotificationAsync(1));

                Assert.NotNull(ex);
                Assert.IsType <InvalidOperationException>(ex);
            }
        }
Exemple #4
0
        public async Task AcknowledgePrivilegeNotificationAsync_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.AcknowledgePrivilegeNotificationAsync(1));

                Assert.Null(ex);
            }
        }
Exemple #5
0
        public async Task AcknowledgePrivilegeNotificationAsync_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.AcknowledgePrivilegeNotificationAsync(1, CancellationToken.None));

                Assert.NotNull(ex);
                Assert.IsType <OperationCanceledException>(ex);
            }
        }
Exemple #6
0
        public async Task AcknowledgePrivilegeNotificationAsync_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.AcknowledgePrivilegeNotificationAsync(1, CancellationToken.None));

                Assert.NotNull(ex);
                Assert.IsType <TimeoutException>(ex);
            }
        }