-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logic_test.py
39 lines (35 loc) · 1.07 KB
/
Logic_test.py
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
import unittest
from ToggleSwitch import ToggleSwitch
from LightBulb import LightBulb
from Logic import Logic
class TestLogic(unittest.TestCase):
def test_OneSwitchScenario(self):
ts1 = ToggleSwitch()
lb1 = LightBulb()
logic = Logic(lb1, [ts1])
ts1.switch()
logic.processing()
self.assertEqual(True, lb1.state)
def test_TwoSwitchesScenario(self):
ts1 = ToggleSwitch()
ts2 = ToggleSwitch()
lb1 = LightBulb()
logic = Logic(lb1, [ts1, ts2])
ts1.switch()
logic.processing()
ts2.switch()
logic.processing()
self.assertEqual(False, lb1.state)
def test_ThreeSwitchesScenario(self):
ts1 = ToggleSwitch()
ts2 = ToggleSwitch()
ts3 = ToggleSwitch()
lb1 = LightBulb()
logic = Logic(lb1, [ts1, ts2, ts3])
ts1.switch()
logic.processing()
ts2.switch()
logic.processing()
ts3.switch()
logic.processing()
self.assertEqual(True, lb1.state)