TbpWrraper/Workflows/Test/Cutomers/Main.mqh
Nique_372 cc704c7794
2026-04-13 18:51:11 -05:00

170 lines
5.6 KiB
MQL5

//+------------------------------------------------------------------+
//| Main.mqh |
//| Copyright 2025, Niquel Mendoza. |
//| https://www.mql5.com/es/users/nique_372 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2025, Niquel Mendoza."
#property link "https://www.mql5.com/es/users/nique_372"
#property strict
#ifndef TBPWRRAPER_WORKFLOWS_TEST_CUSTOMERS_MAIN_MQH
#define TBPWRRAPER_WORKFLOWS_TEST_CUSTOMERS_MAIN_MQH
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
#include "..\\Def.mqh"
#include <TSN\\MqlCI\\UnitTest.mqh>
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CAditionalDataAccountId : public ITbpAdditionalData
{
public:
CAditionalDataAccountId(void) {}
~CAditionalDataAccountId(void) {}
// usaremos un id harcodeado
string Get() override final { return "3000078006"; /*IntegerToString(AccountInfoInteger(ACCOUNT_LOGIN)); */}
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CTestGetCustomersSoftware : public ICiTest
{
private:
CTbpCustomers* m_tbp;
public:
CTestGetCustomersSoftware(CTbpCustomers* tbp) : m_tbp(tbp) {}
inline string Name() const override { return "GetCustomersSoftware"; }
inline int Importance() const override { return 70; }
bool Run(string &msg) override
{
if(!m_tbp.GetCustomersSotfware())
{
msg = "HTTP call failed";
return false;
}
Print(m_tbp.GetLastJson().Serialize(true));
CJsonNode node = m_tbp.GetLastJson().GetRoot();
if(node.Size() == 0)
{
msg = "JSON is empty";
return false;
}
return true;
}
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CTestUserHasSoftware : public ICiTest
{
private:
CTbpCustomers* m_tbp;
string m_user_id;
public:
CTestUserHasSoftware(CTbpCustomers* tbp, const string& user_id) : m_tbp(tbp), m_user_id(user_id) {}
inline string Name() const override { return "UserHasSoftware"; }
inline int Importance() const override { return 90; }
bool Run(string &msg) override
{
bool out = false;
if(!m_tbp.UserHasSoftware(m_user_id, out))
{
msg = "HTTP call failed";
return false;
}
if(!out)
{
msg = "User has no software";
return false;
}
return true;
}
};
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CTestUserHasSoftwareNoAdditional : public ICiTest
{
private:
CTbpCustomers* m_tbp;
string m_user_id;
public:
CTestUserHasSoftwareNoAdditional(CTbpCustomers* tbp, const string& user_id) : m_tbp(tbp), m_user_id(user_id) {}
inline string Name() const override { return "UserHasSoftwareNoAdditional"; }
inline int Importance() const override { return 60; }
bool Run(string &msg) override
{
bool out = false;
if(!m_tbp.UserHastSoftwareNoaAdditionalData(m_user_id, out))
{
msg = "HTTP call failed";
return false;
}
if(!out)
{
msg = "User has no software";
return false;
}
return true;
}
};
/*
// En caso tegnan un sotfware y un usuario que les haya comprado por ahi
// pueden incluir este test.. por ahora lo comentare
// dado qeu yo no tengo ningun usario que me haya comprado via telegram
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
class CTestUserHasSoftwareTelegram : public ICiTest
{
private:
CTbpCustomers* m_tbp;
string m_telegram_user;
public:
CTestUserHasSoftwareTelegram(CTbpCustomers* tbp, const string& telegram_user) : m_tbp(tbp), m_telegram_user(telegram_user) {}
inline string Name() const override { return "UserHasSoftwareTelegram"; }
inline int Importance() const override { return 50; }
bool Run(string &msg) override
{
bool out = false;
if(!m_tbp.UserHastSoftwareTelegram(m_telegram_user, out))
{
msg = "HTTP call failed";
return false;
}
// Comente esto dado que en mis test aun no tnego un usuario que haya comprado por telegram
// en caso tengan uno pueden descomentarlo
// por ahora me basta con que la api funcione
//if(!out)
//{
// msg = "User has no software";
// return false;
/}
return true;
}
};
*/
//+------------------------------------------------------------------+
#endif // TBPWRRAPER_WORKFLOWS_TEST_CUSTOMERS_MAIN_MQH