{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/comments/26531562","id":26531562,"diff_hunk":"@@ -0,0 +1,116 @@\n+// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+#pragma once\n+\n+#include \"stdafx.h\"\n+#include <string>\n+#include \"cpprest\\details\\basic_types.h\"\n+#include \"cpprest\\json.h\" \n+#include \"connection.h\"\n+#include \"hub_connection.h\"\n+#include \"url.h\"\n+\n+using namespace signalr;\n+using namespace utility;\n+using namespace std;\n+using namespace pplx;\n+\n+TEST(connection_tests, send_message)\n+{\n+    auto conn = make_shared<connection>(url + U(\"raw-connection\"));\n+    auto message = make_shared<string_t>();\n+    auto test_event = make_shared<pplx::event>();\n+\n+    conn->set_message_received([message, test_event](const string_t& payload)\n+    {\n+        *message = payload;\n+        test_event->set();\n+    });\n+\n+    conn->start()\n+        .then([conn](task<void> start_task)\n+        {\n+            try\n+            {\n+                start_task.get();\n+                ASSERT_EQ(conn->get_connection_state(), connection_state::connected);\n+\n+                web::json::value obj;\n+                obj[U(\"type\")] = web::json::value::number(0);\n+                obj[U(\"value\")] = web::json::value::string(U(\"test\"));\n+\n+                conn->send(obj.serialize());\n+            }\n+            catch (...)\n+            { }\n+        });\n+\n+    ASSERT_FALSE(test_event->wait(10000));\n+\n+    ASSERT_EQ(*message, U(\"\\\"Send: test\\\"\"));\n+}\n+\n+TEST(connection_tests, send_message_after_connection_restart)\n+{\n+    auto conn = make_shared<connection>(url + U(\"raw-connection\"));\n+    auto message = make_shared<string_t>();\n+    auto test_event = make_shared<pplx::event>();\n+\n+    conn->set_message_received([message, test_event](const string_t& payload)\n+    {\n+        *message = payload;\n+        test_event->set();\n+    });\n+\n+    conn->start()\n+        .then([conn](task<void> start_task)\n+        {\n+            try\n+            {\n+                start_task.get();\n+                ASSERT_EQ(conn->get_connection_state(), connection_state::connected);\n+            }\n+            catch (...)\n+            {\n+                ASSERT_TRUE(false);\n+            }\n+        }).get();\n+\n+    conn->stop()\n+        .then([conn](task<void> stop_task)\n+        {\n+            try\n+            {\n+                stop_task.get();\n+                ASSERT_EQ(conn->get_connection_state(), connection_state::disconnected);\n+            }\n+            catch (...)\n+            {\n+                ASSERT_TRUE(false);\n+            }\n+        }).get();\n+\n+    conn->start()\n+        .then([conn](task<void> start_task)\n+        {\n+            try\n+            {\n+                start_task.get();\n+                ASSERT_EQ(conn->get_connection_state(), connection_state::connected);\n+\n+                web::json::value obj;\n+                obj[U(\"type\")] = web::json::value::number(0);\n+                obj[U(\"value\")] = web::json::value::string(U(\"test\"));\n+\n+                conn->send(obj.serialize());\n+            }\n+            catch (...)\n+            { }\n+        });\n+","path":"test/signalrclient-e2e-tests/connection_tests.cpp","position":111,"original_position":111,"commit_id":"1f8e0fc50fbc8e75a46c1beaedf6ec5fbf7652d3","original_commit_id":"1f8e0fc50fbc8e75a46c1beaedf6ec5fbf7652d3","user":{"login":"moozzyk","id":1438884,"avatar_url":"https://avatars.githubusercontent.com/u/1438884?v=3","gravatar_id":"","url":"https://api.github.com/users/moozzyk","html_url":"https://github.com/moozzyk","followers_url":"https://api.github.com/users/moozzyk/followers","following_url":"https://api.github.com/users/moozzyk/following{/other_user}","gists_url":"https://api.github.com/users/moozzyk/gists{/gist_id}","starred_url":"https://api.github.com/users/moozzyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/moozzyk/subscriptions","organizations_url":"https://api.github.com/users/moozzyk/orgs","repos_url":"https://api.github.com/users/moozzyk/repos","events_url":"https://api.github.com/users/moozzyk/events{/privacy}","received_events_url":"https://api.github.com/users/moozzyk/received_events","type":"User","site_admin":false},"body":"You want something like this (less than formatting):\r\n\r\n    conn->start().then([conn])\r\n    {\r\n        web::json::value obj;\r\n        obj[U(\"type\")] = web::json::value::number(0);\r\n        obj[U(\"value\")] = web::json::value::string(U(\"test\"));\r\n\r\n         return conn->send(obj.serialize());\r\n     }).then([](pplx::task<void> send_task)\r\n     {\r\n         try\r\n         {\r\n               send_task.get();\r\n         }\r\n         catch(...)\r\n         {\r\n              ASSERT_TRUE(false);\r\n         }\r\n    });\r\n\r\nSimilarly to the previous test - because you block the connection does not have to be shared_ptr","created_at":"2015-03-16T21:54:39Z","updated_at":"2015-03-16T21:54:39Z","html_url":"https://github.com/aspnet/SignalR-Client-Cpp/pull/109#discussion_r26531562","pull_request_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/109","_links":{"self":{"href":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/comments/26531562"},"html":{"href":"https://github.com/aspnet/SignalR-Client-Cpp/pull/109#discussion_r26531562"},"pull_request":{"href":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/109"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/109","id":30990076,"html_url":"https://github.com/aspnet/SignalR-Client-Cpp/pull/109","diff_url":"https://github.com/aspnet/SignalR-Client-Cpp/pull/109.diff","patch_url":"https://github.com/aspnet/SignalR-Client-Cpp/pull/109.patch","issue_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues/109","number":109,"state":"open","locked":false,"title":"add c++ end-to-end tests","user":{"login":"Xiaohongt","id":2381199,"avatar_url":"https://avatars.githubusercontent.com/u/2381199?v=3","gravatar_id":"","url":"https://api.github.com/users/Xiaohongt","html_url":"https://github.com/Xiaohongt","followers_url":"https://api.github.com/users/Xiaohongt/followers","following_url":"https://api.github.com/users/Xiaohongt/following{/other_user}","gists_url":"https://api.github.com/users/Xiaohongt/gists{/gist_id}","starred_url":"https://api.github.com/users/Xiaohongt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xiaohongt/subscriptions","organizations_url":"https://api.github.com/users/Xiaohongt/orgs","repos_url":"https://api.github.com/users/Xiaohongt/repos","events_url":"https://api.github.com/users/Xiaohongt/events{/privacy}","received_events_url":"https://api.github.com/users/Xiaohongt/received_events","type":"User","site_admin":false},"body":"Added e2e tests for below scenarios: \r\nsend message, send message after connection re-start, send message after reconnect \r\n\r\nSupport ulr can be specified in commandline parameter as well, like:\r\nsignalrclient-e2e-tests.exe url=http://server1:8081/\r\n\r\nI will have separate PR for hub method parameter tests etc.\r\n\r\nNow the host is moved to test, not in sample.","created_at":"2015-03-11T22:04:25Z","updated_at":"2015-03-16T21:54:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c98b1fed9a49a322722d3f2b1876db3b28b5e5ac","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/109/commits","review_comments_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/109/comments","review_comment_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues/109/comments","statuses_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/statuses/1f8e0fc50fbc8e75a46c1beaedf6ec5fbf7652d3","head":{"label":"aspnet:xiaota/e2e","ref":"xiaota/e2e","sha":"1f8e0fc50fbc8e75a46c1beaedf6ec5fbf7652d3","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":24436973,"name":"SignalR-Client-Cpp","full_name":"aspnet/SignalR-Client-Cpp","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/SignalR-Client-Cpp","description":"C++ client for SignalR.","fork":false,"url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp","forks_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/forks","keys_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/teams","hooks_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/hooks","issue_events_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/events","assignees_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/tags","blobs_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/languages","stargazers_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/stargazers","contributors_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/contributors","subscribers_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/subscribers","subscription_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/subscription","commits_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/merges","archive_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/downloads","issues_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/releases{/id}","created_at":"2014-09-25T00:02:40Z","updated_at":"2015-03-16T20:42:58Z","pushed_at":"2015-03-16T20:43:09Z","git_url":"git://github.com/aspnet/SignalR-Client-Cpp.git","ssh_url":"git@github.com:aspnet/SignalR-Client-Cpp.git","clone_url":"https://github.com/aspnet/SignalR-Client-Cpp.git","svn_url":"https://github.com/aspnet/SignalR-Client-Cpp","homepage":"","size":3444,"stargazers_count":24,"watchers_count":24,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":9,"forks":7,"open_issues":9,"watchers":24,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"7af4317610aa76dfd1c618d60c1f9c7a20686ee8","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":24436973,"name":"SignalR-Client-Cpp","full_name":"aspnet/SignalR-Client-Cpp","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/SignalR-Client-Cpp","description":"C++ client for SignalR.","fork":false,"url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp","forks_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/forks","keys_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/teams","hooks_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/hooks","issue_events_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/events","assignees_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/tags","blobs_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/languages","stargazers_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/stargazers","contributors_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/contributors","subscribers_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/subscribers","subscription_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/subscription","commits_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/merges","archive_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/downloads","issues_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/releases{/id}","created_at":"2014-09-25T00:02:40Z","updated_at":"2015-03-16T20:42:58Z","pushed_at":"2015-03-16T20:43:09Z","git_url":"git://github.com/aspnet/SignalR-Client-Cpp.git","ssh_url":"git@github.com:aspnet/SignalR-Client-Cpp.git","clone_url":"https://github.com/aspnet/SignalR-Client-Cpp.git","svn_url":"https://github.com/aspnet/SignalR-Client-Cpp","homepage":"","size":3444,"stargazers_count":24,"watchers_count":24,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":7,"mirror_url":null,"open_issues_count":9,"forks":7,"open_issues":9,"watchers":24,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/109"},"html":{"href":"https://github.com/aspnet/SignalR-Client-Cpp/pull/109"},"issue":{"href":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues/109"},"comments":{"href":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/issues/109/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/109/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/pulls/109/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/SignalR-Client-Cpp/statuses/1f8e0fc50fbc8e75a46c1beaedf6ec5fbf7652d3"}}}}