Ejemplo n.º 1
0
        public async Task OpenAsync_UriIsNull_ThrowsException()
        {
            // arrange
            string name = "Foo";
            IReadOnlyList <ISocketProtocolFactory> protocolFactories =
                Array.Empty <ISocketProtocolFactory>();
            var socket = new WebSocketClient(name, protocolFactories);

            // act
            Exception?exception =
                await Record.ExceptionAsync(() => socket.OpenAsync(CancellationToken.None));

            // assert
            Assert.IsType <SocketOperationException>(exception).Message.MatchSnapshot();
        }
Ejemplo n.º 2
0
        public async Task OpenAsync_Disposed_ThrowsException()
        {
            // arrange
            string name = "Foo";
            IReadOnlyList <ISocketProtocolFactory> protocolFactories =
                Array.Empty <ISocketProtocolFactory>();
            var socket = new WebSocketClient(name, protocolFactories);
            await socket.DisposeAsync();

            // act
            Exception?exception =
                await Record.ExceptionAsync(() => socket.OpenAsync(CancellationToken.None));

            // assert
            Assert.IsType <ObjectDisposedException>(exception);
        }