forked from citizenfx/fivem
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTestServerEventComponent.cpp
More file actions
23 lines (20 loc) · 1.14 KB
/
TestServerEventComponent.cpp
File metadata and controls
23 lines (20 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <StdInc.h>
#include <catch_amalgamated.hpp>
#include "ClientRegistry.h"
#include "ServerEventComponent.h"
#include "ServerEventComponentInstance.h"
#include "ServerInstance.h"
TEST_CASE("onPlayerJoining event test")
{
fwRefContainer<fx::ServerInstanceBase> serverInstance = ServerInstance::Create();
serverInstance->SetComponent(new fx::ClientRegistry());
const fx::ClientSharedPtr client = serverInstance->GetComponent<fx::ClientRegistry>()->MakeClient("test");
const fx::ClientSharedPtr entityClient = client;
const int slotId = 127;
auto sec = fx::ServerEventComponentInstance::Create();
sec->TriggerClientEvent("onPlayerJoining", fmt::sprintf("%d", client->GetNetId()), entityClient->GetNetId(), entityClient->GetName(), slotId);
REQUIRE(fx::ServerEventComponentInstance::lastClientEvent.has_value() == true);
REQUIRE(fx::ServerEventComponentInstance::lastClientEvent.value().eventName == "onPlayerJoining");
REQUIRE(fx::ServerEventComponentInstance::lastClientEvent.value().targetSrc == std::to_string(client->GetNetId()));
REQUIRE(fx::ServerEventComponentInstance::lastClientEvent.value().data.size() == 8);
}