Commit 337ed1f3 authored by Patrick Chen's avatar Patrick Chen

fix listen event bug

parent 7ad112c4
......@@ -9,9 +9,10 @@ int main()
{
xs::ExchangeServer server("greeting", {}, {}, 0, nullptr);
server.onCmd(
"GetGreetingMessage",
"GetMessage",
[&server](const std::string&, const std::string&) {
const auto name = server.runCmd("GetName", "");
server.postEvent("NotifyGetMessage", "");
return "Hello, " + name + "!";
}
);
......
......@@ -3,14 +3,17 @@
{
"command": "GetName",
"response": "Master"
},
{
"event": "NotifyGetMessage"
}
],
"script": [
{
"command": "GetGreetingMessage",
"command": "GetMessage",
"expect": "Hello, Master!",
"runs": ["GetName"],
"posts": []
"posts": ["NotifyGetMessage"]
}
]
}
......@@ -106,9 +106,6 @@ std::string Tester::onCommand(const std::string& name, const std::string& params
void Tester::onEvent(const std::string& name, const std::string& params) noexcept
{
const auto found = acceptEvents_.find(name);
const auto* service = std::get<1>(*found);
receivedEventCount_[name]++;
}
......@@ -118,6 +115,11 @@ void Tester::run() noexcept
resetCounters();
const auto response = server_.runCmd(expectation.name_, "");
// wait 100ms for upcoming events
using namespace std::chrono_literals;
std::this_thread::sleep_for(100ms);
const auto report = createReport(response, expectation);
if (report.pass) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment