Files
caliverse_server/BrokerApiTest/User/UserDocRepoTests.cs
2025-05-01 07:20:41 +09:00

134 lines
4.9 KiB
C#

using ServerCore;
using ServerBase;
using ServerCommon;
using MODULE_ID = System.UInt32;
namespace BrokerTest.User;
public class TestServerLogic : IServerLogic
{
private DynamoDbClient m_dynamo_db_client;
private ServerConfig m_server_config;
public TestServerLogic(DynamoDbClient dynamoDbClient, ServerConfig serverConfig)
{
m_dynamo_db_client = dynamoDbClient;
m_server_config = serverConfig;
}
public DynamoDbClient getDynamoDbClient() => m_dynamo_db_client;
public RedisConnector getRedisConnector()
{
throw new NotImplementedException();
}
public ServerConfig getServerConfig() => m_server_config;
public string getServerName() => "TestServer";
public string getServerType() => "BrokerApi";
public string toBasicString() => "TestServerLogic";
public IModule getModule(MODULE_ID moduleId) { throw new NullReferenceException(); }
public Result registerEntityTicker(EntityTicker entityTicker) { throw new NullReferenceException(); }
}
// public class UserDocRepoTests
// {
// private readonly ServerConfig m_server_config = new ServerConfig();
// private DynamoDbClient? m_dynamo_db_client;
// private bool m_is_init = false;
// private TestServerLogic? m_server_logic;
//
// // public UserDocRepoTests()
// // {
// // // var user = new UserEntity();
// // // user.OnInit();
// // }
//
// private async Task init()
// {
// if (m_is_init) return;
// Log.NLogFileName = "./Config/nlog-BrokerApiServer.config";
// Log.initLog("BrokerApiServerTest", "Developer");
// var path = "./Config/ServerConfig-Local.json";
// var full_path = Path.GetFullPath(path);
// m_server_config.setConfigFilePath(full_path);
// var result =m_server_config.loadConfig();
// Assert.True(result.isSuccess());
// Assert.NotNull(m_dynamo_db_client);
// m_server_logic = new TestServerLogic(m_dynamo_db_client, m_server_config);
// ServerLogicApp.setServerLogicApp(m_server_logic);
//
// m_dynamo_db_client = new DynamoDbClient();
// var connection_result = m_dynamo_db_client.connectToDb(m_server_config);
// await m_dynamo_db_client.createDBIfNotExists(false);
// Assert.True(connection_result.isSuccess());
//
// m_is_init = true;
// }
//
// [Fact]
// public async Task findTests()
// {
// await init();
//
// //=============================================================================================
// // db에 "heon3" 계정이 존재한다는 전제로 테스트 진행
// //=============================================================================================
//
// // TODO: 계정을 생성하는 절차를 추가할 것
//
// var account_id = "heon3";
// Assert.NotNull(m_dynamo_db_client);
// var account_repo = new AccountDocRepo(m_dynamo_db_client);
// var (result_account, account_attrib) = await account_repo.findAccountBaseAttrib(account_id);
// Assert.True(result_account.isSuccess());
// Assert.NotNull(account_attrib);
//
// var user_guid = account_attrib.UserGuid;
// Assert.NotNull(user_guid);
//
// var user_doc_repo = new UserBaseDocRepo(m_dynamo_db_client);
// var (result_user, user_attrib) = await user_doc_repo.findUserBaseAttrib(user_guid);
// Assert.True(result_user.isSuccess());
// Assert.NotNull(user_attrib);
// Assert.True(user_attrib.UserGuid == user_guid);
// Assert.True(user_attrib.AccountId == account_id);
//
// // var money_doc_repo = new MoneyDocRepo(m_dynamo_db_client);
// // var (result_money, money_attrib) = await money_doc_repo.findMoneyAttrib(user_guid, CancellationToken.None);
// // Assert.True(result_money.isSuccess());
// // Assert.NotNull(money_attrib);
// // Assert.True(money_attrib.Sapphire >= 0);
// // Assert.True(money_attrib.Gold >= 0);
// // Assert.True(money_attrib.Ruby >= 0);
// // Assert.True(money_attrib.Calium >= 0);
// }
//
// private async Task<string> findUser(string accountId)
// {
// await init();
// Assert.NotNull(m_dynamo_db_client);
// var account_repo = new AccountDocRepo(m_dynamo_db_client);
// var (result_account, account_attrib) = await account_repo.findAccountBaseAttrib(accountId);
// Assert.True(result_account.isSuccess());
// Assert.NotNull(account_attrib);
//
// var user_guid = account_attrib.UserGuid;
// Assert.NotNull(user_guid);
//
// var user_doc_repo = new UserBaseDocRepo(m_dynamo_db_client);
// var (result_user, user_attrib) = await user_doc_repo.findUserBaseAttrib(user_guid);
// Assert.True(result_user.isSuccess());
// Assert.NotNull(user_attrib);
// return user_attrib.UserGuid;
// }
// }