2026-03-11 18:43:38 -05:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| 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"
|
2026-04-13 18:51:11 -05:00
|
|
|
#include <TSN\\MqlCI\\UnitTest.mqh>
|
2026-03-11 19:21:16 -05:00
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
class CAditionalDataAccountId : public ITbpAdditionalData
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CAditionalDataAccountId(void) {}
|
|
|
|
|
~CAditionalDataAccountId(void) {}
|
|
|
|
|
// usaremos un id harcodeado
|
|
|
|
|
string Get() override final { return "3000078006"; /*IntegerToString(AccountInfoInteger(ACCOUNT_LOGIN)); */}
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-11 18:43:38 -05:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
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;
|
|
|
|
|
}
|
2026-03-11 19:21:16 -05:00
|
|
|
Print(m_tbp.GetLastJson().Serialize(true));
|
2026-03-11 18:43:38 -05:00
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-11 19:21:16 -05:00
|
|
|
/*
|
|
|
|
|
// 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
|
2026-03-11 18:43:38 -05:00
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
//| |
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
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;
|
2026-03-11 19:21:16 -05:00
|
|
|
if(!m_tbp.UserHastSoftwareTelegram(m_telegram_user, out))
|
2026-03-11 18:43:38 -05:00
|
|
|
{
|
|
|
|
|
msg = "HTTP call failed";
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2026-03-11 19:21:16 -05:00
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
/}
|
2026-03-11 18:43:38 -05:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
};
|
2026-03-11 19:21:16 -05:00
|
|
|
*/
|
2026-03-11 18:43:38 -05:00
|
|
|
|
|
|
|
|
//+------------------------------------------------------------------+
|
|
|
|
|
#endif // TBPWRRAPER_WORKFLOWS_TEST_CUSTOMERS_MAIN_MQH
|