Easyuino  1.1.0
RelayTest.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 RelayTest.h
26 */
27 #ifndef _EASYUINO_RELAY_TEST_h
28 #define _EASYUINO_RELAY_TEST_h
29 
30 #include "Easyuino.h"
31 #include "ManualTest.h"
32 
33 using Easyuino::Relay;
34 
35 class RelayTest : public ManualTest {
36 
37  private:
38  Relay* relay;
39 
40  public:
41  RelayTest(Stream &debugStream, uint8_t arduinoPin) : ManualTest(debugStream) {
42  relay = new Relay(arduinoPin);
43  }
44 
45  protected:
46  void testsSetup() {
47  relay->begin(false, HIGH);
48  }
49 
50  void tests() {
51  testStart("1.ON");
52  relay->turnOn();
53  _debugStream->println(relay->isOn());
54  testEnd();
55 
56  testStart("2.NOTHING");
57  relay->turnOn();
58  _debugStream->println(relay->isOn());
59  testEnd();
60 
61  testStart("3.OFF");
62  relay->turnOff();
63  _debugStream->println(relay->isOn());
64  testEnd();
65 
66  testStart("4.NOTHING");
67  relay->turnOff();
68  _debugStream->println(relay->isOn());
69  testEnd();
70 
71  testStart("5.ON");
72  relay->turnOn();
73  _debugStream->println(relay->isOn());
74  testEnd();
75 
76  testStart("6.OFF");
77  relay->end();
78  relay->turnOn();
79  _debugStream->println(relay->isOn());
80  testEnd();
81 
82  testStart("7.NOTHING");
83  relay->turnOff();
84  _debugStream->println(relay->isOn());
85  testEnd();
86 
87  testStart("8.NOTHING");
88  relay->begin(false, HIGH);
89  _debugStream->println(relay->isOn());
90  testEnd();
91 
92  testStart("9.ON");
93  relay->turnOn();
94  _debugStream->println(relay->isOn());
95  testEnd();
96 
97  testStart("10.OFF");
98  relay->turnOn();
99  _debugStream->println(relay->isOn());
100  testEnd();
101  }
102 
103  void afterTestSuite() {
104  relay->end();
105  delete relay;
106  relay = NULL;
107  }
108 
109 };
110 
111 #endif
Definition: RelayTest.h:35
Definition: ManualTest.h:42
Definition: Relay.h:42