2
2
# -*- coding: utf-8 -*-
3
3
import unittest
4
4
5
- from dft .parameter_injection import TimeDisplay , MidnightTimeProvider , ProductionCodeTimeProvider , datetime
5
+ from dft .setter_injection import TimeDisplay , MidnightTimeProvider , ProductionCodeTimeProvider , datetime
6
6
7
7
"""
8
- Port of the Java example of "Parameter Injection" in
8
+ Port of the Java example of "Setter Injection" in
9
9
"xUnit Test Patterns - Refactoring Test Code" by Gerard Meszaros
10
10
(ISBN-10: 0131495054, ISBN-13: 978-0131495050) accessible in outdated version on
11
11
http://xunitpatterns.com/Dependency%20Injection.html.
@@ -29,8 +29,9 @@ def test_display_current_time_at_midnight(self):
29
29
"""
30
30
time_provider_stub = MidnightTimeProvider ()
31
31
class_under_test = TimeDisplay ()
32
+ class_under_test .set_time_provider (time_provider_stub )
32
33
expected_time = "<span class=\" tinyBoldText\" >24:01</span>"
33
- self .assertEqual (class_under_test .get_current_time_as_html_fragment (time_provider_stub ), expected_time )
34
+ self .assertEqual (class_under_test .get_current_time_as_html_fragment (), expected_time )
34
35
35
36
def test_display_current_time_at_current_time (self ):
36
37
"""
@@ -39,6 +40,7 @@ def test_display_current_time_at_current_time(self):
39
40
"""
40
41
production_code_time_provider = ProductionCodeTimeProvider ()
41
42
class_under_test = TimeDisplay ()
43
+ class_under_test .set_time_provider (production_code_time_provider )
42
44
current_time = datetime .datetime .now ()
43
45
expected_time = "<span class=\" tinyBoldText\" >" + str (current_time .hour ) + ":" + str (current_time .minute ) + "</span>"
44
- self .assertEqual (class_under_test .get_current_time_as_html_fragment (production_code_time_provider ), expected_time )
46
+ self .assertEqual (class_under_test .get_current_time_as_html_fragment (), expected_time )
0 commit comments