forked from nique_372/TbpWrraper
170 lines
5.7 KiB
MQL5
170 lines
5.7 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 TSN::ITbpAdditionalData
| |
{
| |
public:
| |
CAditionalDataAccountId(void) {}
| |
~CAditionalDataAccountId(void) {}
| |
// usaremos un id harcodeado
| |
string Get() override final { return "3000078006"; /*IntegerToString(AccountInfoInteger(ACCOUNT_LOGIN)); */}
| |
};
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
class CTestGetCustomersSoftware : public TSN::ICiTest
| |
{
| |
private:
| |
TSN::CTbpCustomers* m_tbp;
| |
| |
public:
| |
CTestGetCustomersSoftware(TSN::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;
| |
}
| |
TSN::CJsonNode node = m_tbp.GetLastJson().GetRoot();
| |
Print(node.ComplexToString(false));
| |
if(node.Size() == 0)
| |
{
| |
msg = "JSON is empty";
| |
return false;
| |
}
| |
return true;
| |
}
| |
};
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
class CTestUserHasSoftware : public TSN::ICiTest
| |
{
| |
private:
| |
TSN::CTbpCustomers* m_tbp;
| |
string m_user_id;
| |
| |
public:
| |
CTestUserHasSoftware(TSN::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 TSN::ICiTest
| |
{
| |
private:
| |
TSN::CTbpCustomers* m_tbp;
| |
string m_user_id;
| |
| |
public:
| |
CTestUserHasSoftwareNoAdditional(TSN::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:
| |
TSN::CTbpCustomers* m_tbp;
| |
string m_telegram_user;
| |
| |
public:
| |
CTestUserHasSoftwareTelegram(TSN::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
|