|
1 | 1 | #!/usr/bin/env python
|
2 | 2 | # -*- coding: utf-8 -*-
|
3 | 3 | import unittest
|
4 |
| -from creational.builder import construct_building, BuilderHouse, BuilderFlat |
| 4 | +from creational.builder import construct_building, House, Flat, ComplexHouse |
5 | 5 |
|
6 | 6 |
|
7 |
| -class TestHouseBuilding(unittest.TestCase): |
| 7 | +class TestSimple(unittest.TestCase): |
8 | 8 |
|
9 |
| - def setUp(self): |
10 |
| - self.building = construct_building(BuilderHouse()) |
| 9 | + def test_house(self): |
| 10 | + house = House() |
| 11 | + self.assertEqual(house.size, 'Big') |
| 12 | + self.assertEqual(house.floor, 'One') |
11 | 13 |
|
12 |
| - def test_house_size(self): |
13 |
| - self.assertEqual(self.building.size, 'Big') |
| 14 | + def test_flat(self): |
| 15 | + flat = Flat() |
| 16 | + self.assertEqual(flat.size, 'Small') |
| 17 | + self.assertEqual(flat.floor, 'More than One') |
14 | 18 |
|
15 |
| - def test_num_floor_in_house(self): |
16 |
| - self.assertEqual(self.building.floor, 'One') |
17 | 19 |
|
| 20 | +class TestComplex(unittest.TestCase): |
18 | 21 |
|
19 |
| -class TestFlatBuilding(unittest.TestCase): |
20 |
| - |
21 |
| - def setUp(self): |
22 |
| - self.building = construct_building(BuilderFlat()) |
23 |
| - |
24 |
| - def test_house_size(self): |
25 |
| - self.assertEqual(self.building.size, 'Small') |
26 |
| - |
27 |
| - def test_num_floor_in_house(self): |
28 |
| - self.assertEqual(self.building.floor, 'More than One') |
| 22 | + def test_house(self): |
| 23 | + house = construct_building(ComplexHouse) |
| 24 | + self.assertEqual(house.size, 'Big and fancy') |
| 25 | + self.assertEqual(house.floor, 'One') |
0 commit comments