Add DonationVendorComponent, ItemComponent, LevelProgressionComponent, MiniGameControlComponent tests and enhance PetComponent tests

Co-authored-by: aronwk-aaron <26027722+aronwk-aaron@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-08-31 22:37:18 +00:00
parent c29f0d151e
commit f4a9cd21be
6 changed files with 622 additions and 1 deletions

View File

@@ -0,0 +1,83 @@
#include "GameDependencies.h"
#include <gtest/gtest.h>
#include "BitStream.h"
#include "MiniGameControlComponent.h"
#include "Entity.h"
#include "eReplicaComponentType.h"
class MiniGameControlComponentTest : public GameDependenciesTest {
protected:
Entity* baseEntity;
MiniGameControlComponent* miniGameControlComponent;
CBITSTREAM
uint32_t flags = 0;
void SetUp() override {
SetUpDependencies();
baseEntity = new Entity(15, GameDependenciesTest::info);
miniGameControlComponent = baseEntity->AddComponent<MiniGameControlComponent>();
}
void TearDown() override {
delete baseEntity;
TearDownDependencies();
}
};
// Test serialization behavior (should always write 0x40000000)
TEST_F(MiniGameControlComponentTest, SerializationBehavior) {
miniGameControlComponent->Serialize(bitStream, true);
// MiniGameControlComponent::Serialize writes a fixed uint32_t value
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 32);
uint32_t value;
bitStream.Read(value);
EXPECT_EQ(value, 0x40000000);
bitStream.Reset();
}
// Test serialization with isConstruction = false
TEST_F(MiniGameControlComponentTest, SerializationWithoutConstruction) {
miniGameControlComponent->Serialize(bitStream, false);
// Should write the same value regardless of isConstruction parameter
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 32);
uint32_t value;
bitStream.Read(value);
EXPECT_EQ(value, 0x40000000);
bitStream.Reset();
}
// Test multiple serializations produce consistent results
TEST_F(MiniGameControlComponentTest, ConsistentSerialization) {
// First serialization
miniGameControlComponent->Serialize(bitStream, true);
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 32);
uint32_t value1;
bitStream.Read(value1);
bitStream.Reset();
// Second serialization
miniGameControlComponent->Serialize(bitStream, false);
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 32);
uint32_t value2;
bitStream.Read(value2);
bitStream.Reset();
// Third serialization
miniGameControlComponent->Serialize(bitStream, true);
ASSERT_EQ(bitStream.GetNumberOfUnreadBits(), 32);
uint32_t value3;
bitStream.Read(value3);
EXPECT_EQ(value1, value2);
EXPECT_EQ(value2, value3);
EXPECT_EQ(value1, 0x40000000); // All should be 0x40000000
bitStream.Reset();
}