-
Notifications
You must be signed in to change notification settings - Fork 1
/
MQLUnitTestLibrary.mqh
61 lines (49 loc) · 2.15 KB
/
MQLUnitTestLibrary.mqh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//+------------------------------------------------------------------+
//| MQLUnit |
//| Copyright 2021, Niklas Schlimm |
//| https://github.com/nschlimm/MQL5Unit |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, Niklas Schlimm"
#property link "https://github.com/nschlimm/MQL5Unit"
#property version "1.00"
//+------------------------------------------------------------------+
//| Inclusions
//+------------------------------------------------------------------+
#include "MQLUnitTestAsserts.mqh"
#include "MQLUnitTestSuite.mqh"
datetime candleOpenTime;
int candleCounter = 0;
bool tickTestCase = false;
bool finished = false;
CUnitTestSuite* m_testSuite;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void IncremetCandleCounter()
{
datetime candleOpenTimeCheck = iTime(_Symbol, PERIOD_CURRENT,0);
if(candleOpenTime!=candleOpenTimeCheck)
{
//Print("new candle at: " + candleOpenTimeCheck);
candleOpenTime = candleOpenTimeCheck;
candleCounter++;
Print("### Candle count: " + IntegerToString(candleCounter));
if (finished) ExpertRemove();
if(m_testSuite.CanFinish(candleCounter)&&m_testSuite.NotEmpty()) {
m_testSuite.FinishUnitTestsuite();
finished = true;
};
}
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnTick()
{
IncremetCandleCounter();
m_testSuite.ExecuteOnInitTests();
m_testSuite.ExecuteSetup(candleCounter);
m_testSuite.ExecuteNewCandleTests(candleCounter);
m_testSuite.ExecuteTeardown(candleCounter);
}
//+------------------------------------------------------------------+