MessageReceived() private method

private MessageReceived ( IWebSocketResponse webSocketResponse, IConnection connection ) : void
webSocketResponse IWebSocketResponse
connection IConnection
return void
コード例 #1
0
        public void ExceptionCaughtAndReportedIfThrownWhenGettingDataReader()
        {
            var exception = new Exception();

            var fakeWebSocketResponse = new FakeWebSocketResponse();

            fakeWebSocketResponse.Setup <IDataReader>("GetDataReader", () => { throw exception; });

            var transport = new WebSocketTransport();

            transport.Start(
                new FakeConnection
            {
                TransportConnectTimeout = new TimeSpan(0, 0, 0, 0, 100)
            },
                string.Empty, CancellationToken.None);

            var fakeConnection = new FakeConnection();

            transport.MessageReceived(fakeWebSocketResponse, fakeConnection);

            fakeConnection.Verify("OnError", new List <object[]> {
                new object[] { exception }
            });
        }
コード例 #2
0
        public void MessageReceivedReadsAndProcessesMessages()
        {
            var fakeDataReader = new FakeDataReader
            {
                UnicodeEncoding        = (UnicodeEncoding)(-1),
                UnconsumedBufferLength = 42
            };

            fakeDataReader.Setup("ReadString", () => "MessageBody");

            var fakeWebSocketResponse = new FakeWebSocketResponse();

            fakeWebSocketResponse.Setup("GetDataReader", () => fakeDataReader);

            var transport = new WebSocketTransport();

            transport.Start(new FakeConnection(), string.Empty, CancellationToken.None);

            var fakeConnection = new FakeConnection();

            transport.MessageReceived(fakeWebSocketResponse, fakeConnection);

            Assert.Equal(UnicodeEncoding.Utf8, fakeDataReader.UnicodeEncoding);
            fakeDataReader.Verify("ReadString", new List <object[]> {
                new object[] { 42u }
            });

            // invoked by ProcessResponse
            Assert.Equal(1, fakeConnection.GetInvocations("MarkLastMessage").Count());
            Assert.Equal(1, fakeConnection.GetInvocations("Trace").Count());
        }
コード例 #3
0
        public void ExceptionCaughtAndReportedIfThrownWhenGettingDataReader()
        {
            var exception = new Exception();

            var fakeWebSocketResponse = new FakeWebSocketResponse();
            fakeWebSocketResponse.Setup<IDataReader>("GetDataReader", () => { throw exception; });

            var transport = new WebSocketTransport();
            transport.Start(
                new FakeConnection
                {
                    TransportConnectTimeout = new TimeSpan(0, 0, 0, 0, 100)
                },
                string.Empty, CancellationToken.None);

            var fakeConnection = new FakeConnection();
            transport.MessageReceived(fakeWebSocketResponse, fakeConnection);

            fakeConnection.Verify("OnError", new List<object[]> { new object[] { exception } });
        }
コード例 #4
0
        public void MessageReceivedReadsAndProcessesMessages()
        {
            var fakeDataReader = new FakeDataReader
            {
                UnicodeEncoding = (UnicodeEncoding)(-1),
                UnconsumedBufferLength = 42
            };
            fakeDataReader.Setup("ReadString", () => "MessageBody");

            var fakeWebSocketResponse = new FakeWebSocketResponse();
            fakeWebSocketResponse.Setup("GetDataReader", () => fakeDataReader);

            var transport = new WebSocketTransport();
            transport.Start(new FakeConnection(), string.Empty, CancellationToken.None);

            var fakeConnection = new FakeConnection();
            transport.MessageReceived(fakeWebSocketResponse, fakeConnection);

            Assert.Equal(UnicodeEncoding.Utf8, fakeDataReader.UnicodeEncoding);
            fakeDataReader.Verify("ReadString", new List<object[]> {new object[] { 42u}});

            // invoked by ProcessResponse
            Assert.Equal(1, fakeConnection.GetInvocations("MarkLastMessage").Count());
            Assert.Equal(1, fakeConnection.GetInvocations("Trace").Count());
        }