Skip to content

Commit

Permalink
Fixes Account.test.mq5 and Exchange.test.mq5 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kenorb committed May 3, 2024
1 parent 3165600 commit 48c14c4
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Account/AccountBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class AccountBase : public Dynamic {
*/
~AccountBase() {}

/* Virtual methods */

/**
* Returns balance value of the current account.
*/
Expand Down
41 changes: 40 additions & 1 deletion Account/tests/Account.test.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,51 @@
#include "../../Test.mqh"
#include "../Account.h"


// Test classes.
class AccountTest : public Account<AccountBaseState, AccountBaseEntry> {
/**
* Returns balance value of the current account.
*/
float GetBalance() { return 0; }

/**
* Returns credit value of the current account.
*/
float GetCredit() { return 0; }

/**
* Returns profit value of the current account.
*/
float GetProfit() { return 0; }

/**
* Returns equity value of the current account.
*/
float GetEquity() { return 0; }

/**
* Returns margin value of the current account.
*/
float GetMarginUsed() { return 0; }

/**
* Returns free margin value of the current account.
*/
float GetMarginFree() { return 0; }

/**
* Get account available margin.
*/
float GetMarginAvail() { return 0; }
};

/**
* Implements OnInit().
*/
int OnInit() {
bool _result = true;
Account<AccountBaseState, AccountBaseEntry> acc1;
AccountTest acc1;
// ...
return _result && GetLastError() == 0 ? INIT_SUCCEEDED : INIT_FAILED;
}
Expand Down
38 changes: 37 additions & 1 deletion Exchange/tests/Exchange.test.mq5
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,43 @@
#include "../Exchange.h"

// Test classes.
class AccountDummy : public AccountBase {}; // <AccountForexState, AccountForexEntry>
class AccountDummy : public AccountBase {
/**
* Returns balance value of the current account.
*/
float GetBalance() { return 0; }

/**
* Returns credit value of the current account.
*/
float GetCredit() { return 0; }

/**
* Returns profit value of the current account.
*/
float GetProfit() { return 0; }

/**
* Returns equity value of the current account.
*/
float GetEquity() { return 0; }

/**
* Returns margin value of the current account.
*/
float GetMarginUsed() { return 0; }

/**
* Returns free margin value of the current account.
*/
float GetMarginFree() { return 0; }

/**
* Get account available margin.
*/
float GetMarginAvail() { return 0; }
};

class ExchangeDummy : public Exchange {};
class SymbolDummy : public SymbolInfo {};
class TradeDummy : public Trade {
Expand Down

0 comments on commit 48c14c4

Please sign in to comment.