private Start ( IConnection connection, string connectionData ) : Task | ||
connection | IConnection | |
connectionData | string | |
Résultat | Task |
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 } }); }
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()); }
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 } }); }
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()); }