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 | | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-06-03 12:24:19 -05:00 | | | class CAditionalDataAccountId : public TSN::ITbpAdditionalData
|
2026-03-11 19:21:16 -05:00 | | | {
|
| | | 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 | | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-07-21 08:08:21 -05:00 | | | class CTestGetCustomersSoftware : public TSN::ICiTest
|
2026-03-11 18:43:38 -05:00 | | | {
|
| | | private:
|
2026-06-03 12:24:19 -05:00 | | | TSN::CTbpCustomers* m_tbp;
|
2026-03-11 18:43:38 -05:00 | | |
|
| | | public:
|
2026-06-03 12:24:19 -05:00 | | | CTestGetCustomersSoftware(TSN::CTbpCustomers* tbp) : m_tbp(tbp) {}
|
2026-03-11 18:43:38 -05:00 | | |
|
| | | 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-06-03 12:24:19 -05:00 | | | TSN::CJsonNode node = m_tbp.GetLastJson().GetRoot();
|
2026-07-21 08:08:21 -05:00 | | | Print(node.ComplexToString(false));
|
2026-03-11 18:43:38 -05:00 | | | if(node.Size() == 0)
|
| | | {
|
| | | msg = "JSON is empty";
|
| | | return false;
|
| | | }
|
| | | return true;
|
| | | }
|
| | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-07-21 08:08:21 -05:00 | | | class CTestUserHasSoftware : public TSN::ICiTest
|
2026-03-11 18:43:38 -05:00 | | | {
|
| | | private:
|
2026-06-03 12:24:19 -05:00 | | | TSN::CTbpCustomers* m_tbp;
|
2026-03-11 18:43:38 -05:00 | | | string m_user_id;
|
| | |
|
| | | public:
|
2026-06-03 12:24:19 -05:00 | | | CTestUserHasSoftware(TSN::CTbpCustomers* tbp, const string& user_id) : m_tbp(tbp), m_user_id(user_id) {}
|
2026-03-11 18:43:38 -05:00 | | |
|
| | | 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;
|
| | | }
|
| | | };
|
| | |
|
| | | //+------------------------------------------------------------------+
|
| | | //| |
|
| | | //+------------------------------------------------------------------+
|
2026-07-21 08:08:21 -05:00 | | | class CTestUserHasSoftwareNoAdditional : public TSN::ICiTest
|
2026-03-11 18:43:38 -05:00 | | | {
|
| | | private:
|
2026-06-03 12:24:19 -05:00 | | | TSN::CTbpCustomers* m_tbp;
|
2026-03-11 18:43:38 -05:00 | | | string m_user_id;
|
| | |
|
| | | public:
|
2026-06-03 12:24:19 -05:00 | | | CTestUserHasSoftwareNoAdditional(TSN::CTbpCustomers* tbp, const string& user_id) : m_tbp(tbp), m_user_id(user_id) {}
|
2026-03-11 18:43:38 -05:00 | | |
|
| | | 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:
|
2026-06-03 12:24:19 -05:00 | | | TSN::CTbpCustomers* m_tbp;
|
2026-03-11 18:43:38 -05:00 | | | string m_telegram_user;
|
| | |
|
| | | public:
|
2026-06-03 12:24:19 -05:00 | | | CTestUserHasSoftwareTelegram(TSN::CTbpCustomers* tbp, const string& telegram_user) : m_tbp(tbp), m_telegram_user(telegram_user) {}
|
2026-03-11 18:43:38 -05:00 | | |
|
| | | 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
|