7 changed files with 87 additions and 26 deletions
@ -1,7 +1,42 @@
|
||||
#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); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue