You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1013 B
42 lines
1013 B
#include <Catch/catch.hpp> |
|
#include <SessionContext.hpp> |
|
#include <ws.hpp> |
|
|
|
SCENARIO("the test suite is working") { |
|
REQUIRE(true); |
|
REQUIRE_FALSE(false); |
|
} |
|
|
|
struct TestConnection { |
|
|
|
}; |
|
|
|
struct TestWsServer { |
|
void send_close(TestConnection &con,tr::ws::status status, std::string reason) { |
|
send_close_calls_++; |
|
} |
|
int send_close_calls_ = 0; |
|
}; |
|
|
|
SCENARIO("we have a websocket resource") { |
|
TestConnection connection; |
|
TestSession session; |
|
TestWsServer server; |
|
GIVEN("the session is valid") { |
|
session.valid = true; |
|
WHEN("we open the connection") { |
|
tr::ws::on_open(server, session, connection); |
|
THEN("the session should post torrent torrent updates") { |
|
REQUIRE(session.post_torrent_updates_calls_ == 1); |
|
} |
|
} |
|
} |
|
GIVEN("the session is invalid") { |
|
WHEN("we open the connection") { |
|
tr::ws::on_open(server, session, connection); |
|
THEN("the server should close the connection") { |
|
REQUIRE(server.send_close_calls_ == 1); |
|
} |
|
} |
|
} |
|
} |