From 39914c59d7e7b9072640bb7ebe80621f6dd32203 Mon Sep 17 00:00:00 2001 From: AdityaKasar Date: Tue, 24 Sep 2024 00:03:41 +0530 Subject: [PATCH] feat(core): Profile module unit tests --- .../src/cpp/sdk/cpptest/unit/profileTest.cpp | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/sdks/core/src/cpp/sdk/cpptest/unit/profileTest.cpp diff --git a/src/sdks/core/src/cpp/sdk/cpptest/unit/profileTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/unit/profileTest.cpp new file mode 100644 index 000000000..3490e43a9 --- /dev/null +++ b/src/sdks/core/src/cpp/sdk/cpptest/unit/profileTest.cpp @@ -0,0 +1,55 @@ +#include "unit.h" +#include "common/types.h" + + +class ProfileTest : public ::testing::Test { + protected: + JsonEngine* jsonEngine; + Firebolt::Error error = Firebolt::Error::None; + + void SetUp() override + { + jsonEngine = new JsonEngine(); + } + + void TearDown() override + { + delete jsonEngine; + } +}; + + +TEST_F(ProfileTest, ApproveContentRating) +{ + + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Profile.approveContentRating")); + + bool value = Firebolt::IFireboltAccessor::Instance().ProfileInterface().approveContentRating(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, expectedValues); +} + + +TEST_F(ProfileTest, ApprovePurchase) +{ + + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Profile.approvePurchase")); + + bool value = Firebolt::IFireboltAccessor::Instance().ProfileInterface().approvePurchase(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(value, expectedValues); +} + + +TEST_F(ProfileTest, Flags) +{ + + nlohmann::json_abi_v3_11_3::json expectedValues = nlohmann::json::parse(jsonEngine->get_value("Profile.flags")); + + Firebolt::Types::FlatMap flag = Firebolt::IFireboltAccessor::Instance().ProfileInterface().flags(&error); + + EXPECT_EQ(error, Firebolt::Error::None); + EXPECT_EQ(flag["userExperience"], expectedValues["userExperience"]); +} \ No newline at end of file