Files
caliverse_server/BrokerApiTest/EntityTests/EntityTests.cs
2025-05-01 07:23:28 +09:00

68 lines
2.3 KiB
C#

using BrokerApiCore;
using ServerBase;
using ServerCommon;
using BrokerApiServer;
namespace BrokerTest;
public class EntityTests
{
private readonly BrokerServerLogic m_logic;
// BrokerServerLogic 내에서 초기화 됨
private readonly DynamoDbClient m_dynamo_db_client;
// BrokerServerLogic 내에서 초기화 됨
private readonly ServerConfigMetaverseBroker m_server_config;
private const string TestAccountId = "20462"; // tenafter71@gmail.com
public EntityTests()
{
var server_config = new ServerConfigMetaverseBroker();
var server_config_path = "./Config/ServerConfig.json";
server_config.setConfigFilePath(server_config_path);
var result = server_config.tryLoadConfig().GetAwaiter().GetResult();
m_server_config = server_config;
m_logic = new BrokerServerLogic(server_config);
m_logic.onInit().Wait();
m_dynamo_db_client = m_logic.getDynamoDbClient();
}
[Fact]
public async Task userAuthEntityTest()
{
await m_logic.onInit();
var user_entity = new PlanetUserEntity(m_logic);
await user_entity.onInit();
var user_auth_action = user_entity.getEntityActionNotNull<UserAuthAction>();
var (result, account_base_doc) = await user_auth_action.findAccountDoc(TestAccountId);
var account_attribute = user_entity.getEntityAttributeNotNull<AccountAttribute>();
account_attribute.copyEntityAttributeFromDoc(account_base_doc);
Assert.Equal(TestAccountId, account_attribute.AccountId);
var user_attribute = user_entity.getEntityAttributeNotNull<UserAttribute>();
(result, var user_doc) = await user_auth_action.findUserDoc(account_attribute.UserGuid);
Assert.NotNull(user_doc);
user_attribute.copyEntityAttributeFromDoc(user_doc);
Assert.NotEmpty(user_attribute.UserGuid);
Assert.Equal(TestAccountId, user_attribute.AccountId);
Assert.Equal(account_attribute.UserGuid, user_attribute.UserGuid);
await user_auth_action.findNicknameDoc(account_attribute.UserGuid);
(result, var nickname_doc) = await user_auth_action.findNicknameDoc(account_attribute.UserGuid);
Assert.NotNull(nickname_doc);
var user_nickname = user_entity.getEntityAttribute<NicknameAttribute>();
Assert.NotNull(user_nickname);
await user_nickname.onInit();
user_nickname.copyEntityAttributeFromDoc(nickname_doc);
Assert.NotEmpty(user_nickname.Nickname);
}
}