From 82244e2fc04698ca58dcc7085203da2a8adcaecf Mon Sep 17 00:00:00 2001 From: kenorb Date: Fri, 3 May 2024 15:18:37 +0100 Subject: [PATCH] Fixes Account.test.mq5, AccountForex.test.mq5 and Exchange.test.mq5 tests --- Account/AccountBase.h | 2 ++ Account/tests/Account.test.mq5 | 40 ++++++++++++++++++++++++++++- Account/tests/AccountForex.test.mq5 | 40 ++++++++++++++++++++++++++++- Exchange/tests/Exchange.test.mq5 | 38 ++++++++++++++++++++++++++- 4 files changed, 117 insertions(+), 3 deletions(-) diff --git a/Account/AccountBase.h b/Account/AccountBase.h index 5cb522e24..359d4c0ed 100644 --- a/Account/AccountBase.h +++ b/Account/AccountBase.h @@ -57,6 +57,8 @@ class AccountBase : public Dynamic { */ ~AccountBase() {} + /* Virtual methods */ + /** * Returns balance value of the current account. */ diff --git a/Account/tests/Account.test.mq5 b/Account/tests/Account.test.mq5 index 67b1ca128..286017e2c 100644 --- a/Account/tests/Account.test.mq5 +++ b/Account/tests/Account.test.mq5 @@ -28,12 +28,50 @@ #include "../../Test.mqh" #include "../Account.h" +// Test classes. +class AccountTest : public Account { + /** + * 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 acc1; + AccountTest acc1; // ... return _result && GetLastError() == 0 ? INIT_SUCCEEDED : INIT_FAILED; } diff --git a/Account/tests/AccountForex.test.mq5 b/Account/tests/AccountForex.test.mq5 index 350526aea..2e01162b8 100644 --- a/Account/tests/AccountForex.test.mq5 +++ b/Account/tests/AccountForex.test.mq5 @@ -28,12 +28,50 @@ #include "../../Test.mqh" #include "../AccountForex.h" +// Test classes. +class AccountForexTest : public Account { + /** + * 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 acc1; + AccountForexTest acc1; // ... return _result && GetLastError() == 0 ? INIT_SUCCEEDED : INIT_FAILED; } diff --git a/Exchange/tests/Exchange.test.mq5 b/Exchange/tests/Exchange.test.mq5 index d3d289c61..498c0c791 100644 --- a/Exchange/tests/Exchange.test.mq5 +++ b/Exchange/tests/Exchange.test.mq5 @@ -30,7 +30,43 @@ #include "../Exchange.h" // Test classes. -class AccountDummy : public AccountBase {}; // +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 {