first test for the whisper com service #5

Merged
byterazor merged 2 commits from csander/WhisperCom:main into main 2023-07-31 16:19:43 +02:00
Showing only changes of commit f3a46ef218 - Show all commits

View File

@ -36,16 +36,14 @@ SCENARIO("Constructing two services that send and receive messages.","[Service]"
std::string testTopic = "testTopic";
std::shared_ptr<WhisperCom::Service> serviceSource = nullptr;
REQUIRE_NOTHROW( serviceSource == std::make_shared<WhisperCom::Service>() );
REQUIRE_NOTHROW( serviceSource = std::make_shared<WhisperCom::Service>() );
REQUIRE( serviceSource != nullptr );
serviceSource->subscribe( testTopic );
std::this_thread::sleep_for( 2000ms );
std::shared_ptr<WhisperCom::Service> serviceSink = nullptr;
REQUIRE_NOTHROW( serviceSink == std::make_shared<WhisperCom::Service>() );
REQUIRE_NOTHROW( serviceSink = std::make_shared<WhisperCom::Service>() );
REQUIRE( serviceSink != nullptr );
serviceSink->subscribe( testTopic );
std::this_thread::sleep_for( 2000ms );
WHEN("Sending a message")
{
@ -54,17 +52,15 @@ SCENARIO("Constructing two services that send and receive messages.","[Service]"
WhisperCom::Protobuf::Message wmsg{};
wmsg.mutable_payload()->PackFrom( msg );
serviceSource->sendMessage( "test", wmsg );
std::this_thread::sleep_for( 200ms );
std::this_thread::sleep_for( 400ms );
THEN("The sink service should receive the message")
{
CHECK( serviceSink->hasMessages() );
std::this_thread::sleep_for( 6000ms );
} //THEN
} // WHEN
serviceSource->stop();
std::this_thread::sleep_for( 2000ms );
serviceSink->stop();
} // GIVEN
} //SCENARIO