@@ -302,7 +302,7 @@ TEST(connection_impl_start, start_fails_if_connect_request_times_out)
302302 auto websocket_client = std::make_shared<test_websocket_client>();
303303 websocket_client->set_receive_function ([]()->pplx ::task<std::string>
304304 {
305- return pplx::task_from_result (std::string (" " ));
305+ return pplx::task_from_result (std::string (" {} " ));
306306 });
307307
308308 auto connection =
@@ -320,6 +320,36 @@ TEST(connection_impl_start, start_fails_if_connect_request_times_out)
320320 }
321321}
322322
323+ TEST (connection_impl_start, start_fails_if_protocol_versions_not_compatible)
324+ {
325+ auto web_request_factory = std::make_unique<test_web_request_factory>([](const web::uri& url)
326+ {
327+ auto response_body =
328+ url.path () == _XPLATSTR (" /negotiate" )
329+ ? _XPLATSTR (" {\" Url\" :\" /signalr\" , \" ConnectionToken\" : \" A==\" , \" ConnectionId\" : \" f7707523-307d-4cba-9abf-3eef701241e8\" , " )
330+ _XPLATSTR (" \" KeepAliveTimeout\" : 20.0, \" DisconnectTimeout\" : 30.0, \" ConnectionTimeout\" : 110.0, \" TryWebSockets\" : true, " )
331+ _XPLATSTR (" \" ProtocolVersion\" : \" 1.2\" , \" TransportConnectTimeout\" : 0.1, \" LongPollDelay\" : 0.0}" )
332+ : _XPLATSTR (" { }" );
333+
334+ return std::unique_ptr<web_request>(new web_request_stub ((unsigned short )200 , _XPLATSTR (" OK" ), response_body));
335+ });
336+
337+ auto websocket_client = std::make_shared<test_websocket_client>();
338+ auto connection =
339+ connection_impl::create (create_uri (), _XPLATSTR (" " ), trace_level::all, std::make_shared<trace_log_writer>(),
340+ std::move (web_request_factory), std::make_unique<test_transport_factory>(websocket_client));
341+
342+ try
343+ {
344+ connection->start ().get ();
345+ ASSERT_TRUE (false ); // exception not thrown
346+ }
347+ catch (const std::runtime_error &e)
348+ {
349+ ASSERT_STREQ (" incompatible protocol version. client protocol version: 1.4, server protocol version: 1.2" , e.what ());
350+ }
351+ }
352+
323353TEST (connection_impl_process_response, process_response_logs_messages)
324354{
325355 std::shared_ptr<log_writer> writer (std::make_shared<memory_log_writer>());
0 commit comments