Easyuino  1.1.0
RelayNamedTest.h
1 /*
2 MIT License
3 
4 Copyright (c) 2017 André Pires
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 /*
25 RelayNamedTest.h
26 */
27 #ifndef _EASYUINO_RELAY_NAMED_TEST_h
28 #define _EASYUINO_RELAY_NAMED_TEST_h
29 
30 #include "Easyuino.h"
31 #include "ManualTest.h"
32 
34 
35 class RelayNamedTest : public ManualTest {
36 
37  private:
38  RelayNamed* relay;
39 
40  public:
41  RelayNamedTest(Stream &debugStream, uint8_t arduinoPin, const char* relayName) : ManualTest(debugStream) {
42  relay = new RelayNamed(arduinoPin, relayName);
43  }
44 
45  protected:
46  void testsSetup() {
47  relay->begin(false, HIGH);
48  }
49 
50  void tests() {
51  testStart("1.TO STRING");
52  _debugStream->print(relay->toString());
53  _debugStream->println("|"); // To mark the end of string
54  testEnd();
55 
56  testStart("2.<<");
57  *_debugStream << *relay;
58  _debugStream->println("|"); // To mark the end of string
59  testEnd();
60 
61  testStart("3.ON");
62  relay->turnOn();
63  _debugStream->println(relay->isOn());
64  testEnd();
65 
66  testStart("4.NOTHING");
67  relay->turnOn();
68  _debugStream->println(relay->isOn());
69  testEnd();
70 
71  testStart("5.OFF");
72  relay->turnOff();
73  _debugStream->println(relay->isOn());
74  testEnd();
75 
76  testStart("6.NOTHING");
77  relay->turnOff();
78  _debugStream->println(relay->isOn());
79  testEnd();
80 
81  testStart("7.ON");
82  relay->turnOn();
83  _debugStream->println(relay->isOn());
84  testEnd();
85 
86  testStart("8.OFF");
87  relay->end();
88  _debugStream->println(relay->isOn());
89  testEnd();
90 
91  testStart("9.NOTHING");
92  relay->turnOff();
93  _debugStream->println(relay->isOn());
94  testEnd();
95 
96  testStart("10.NOTHING");
97  relay->begin(false, HIGH);
98  _debugStream->println(relay->isOn());
99  testEnd();
100 
101  testStart("11.ON");
102  relay->turnOn();
103  _debugStream->println(relay->isOn());
104  testEnd();
105 
106  testStart("12.OFF");
107  relay->turnOff();
108  _debugStream->println(relay->isOn());
109  testEnd();
110  }
111 
112  void afterTestSuite() {
113  relay->end();
114  delete relay;
115  relay = NULL;
116  }
117 
118 };
119 
120 #endif
Definition: RelayNamed.h:48
Definition: ManualTest.h:42
Definition: RelayNamedTest.h:35