forked from ABAP-Logger/ABAP-Logger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzcl_logger_settings.clas.testclasses.abap
143 lines (128 loc) · 4.7 KB
/
zcl_logger_settings.clas.testclasses.abap
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
class lcl_logger_settings_should definition deferred.
class zcl_logger_settings definition local friends lcl_logger_settings_should.
class lcl_logger_settings_should definition for testing
risk level harmless
duration short.
private section.
data cut type ref to zcl_logger_settings.
methods setup.
methods have_correct_defaults for testing.
methods set_autosave for testing.
methods set_expiry_date for testing.
methods set_expiry_in_days for testing.
methods set_flag_to_keep_until_expiry for testing.
methods set_usage_of_2nd_db_connection for testing.
methods set_max_drilldown_level for testing.
endclass.
class lcl_logger_settings_should implementation.
method setup.
create object cut.
endmethod.
method have_correct_defaults.
cl_aunit_assert=>assert_equals(
exporting
exp = abap_true
act = cut->zif_logger_settings~get_autosave( )
msg = |Auto save should be on by default|
).
cl_aunit_assert=>assert_equals(
exporting
exp = abap_true
act = cut->zif_logger_settings~get_usage_of_secondary_db_conn( )
msg = |2nd database connection should be used by default|
).
cl_aunit_assert=>assert_equals(
exporting
exp = abap_false
act = cut->zif_logger_settings~get_must_be_kept_until_expiry( )
msg = |Log should be deletable before expiry date is reached by default|
).
cl_aunit_assert=>assert_initial(
exporting
act = cut->zif_logger_settings~get_expiry_date( )
msg = |No expiry date set by default|
).
cl_aunit_assert=>assert_equals(
exporting
exp = 10
act = cut->zif_logger_settings~get_max_exception_drill_down( )
msg = |Max exception drill down should be 10 by default|
).
endmethod.
method set_autosave.
cut->zif_logger_settings~set_autosave( abap_false ).
cl_aunit_assert=>assert_equals(
exporting
exp = abap_false
act = cut->zif_logger_settings~get_autosave( )
msg = |Auto save was not deactivated correctly|
).
endmethod.
method set_expiry_date.
cut->zif_logger_settings~set_expiry_date( '20161030' ).
cl_aunit_assert=>assert_equals(
exporting
exp = '20161030'
act = cut->zif_logger_settings~get_expiry_date( )
msg = |Expiry date was not set correctly|
).
endmethod.
method set_expiry_in_days.
cut->zif_logger_settings~set_expiry_in_days( -1 ).
cl_aunit_assert=>assert_initial(
exporting
act = cut->zif_logger_settings~get_expiry_date( )
msg = |Expiry in days should remain default when setting incorrect values.|
).
cut->zif_logger_settings~set_expiry_in_days( 10 ).
data lv_exp type d.
lv_exp = sy-datum + 10.
cl_aunit_assert=>assert_equals(
exporting
exp = lv_exp
act = cut->zif_logger_settings~get_expiry_date( )
msg = |Expiry in days was not set correctly.|
).
endmethod.
method set_flag_to_keep_until_expiry.
cut->zif_logger_settings~set_must_be_kept_until_expiry( abap_true ).
cl_aunit_assert=>assert_equals(
exporting
exp = abap_true
act = cut->zif_logger_settings~get_must_be_kept_until_expiry( )
msg = |Setter for keeping log until expiry is not working correctly.|
).
endmethod.
method set_usage_of_2nd_db_connection.
cut->zif_logger_settings~set_usage_of_secondary_db_conn( abap_false ).
cl_aunit_assert=>assert_equals(
exporting
exp = abap_false
act = cut->zif_logger_settings~get_usage_of_secondary_db_conn( )
msg = |Setter for using 2nd db connection is not working correctly.|
).
endmethod.
method set_max_drilldown_level.
cut->zif_logger_settings~set_max_exception_drill_down( 20 ).
cl_aunit_assert=>assert_equals(
exporting
exp = 20
act = cut->zif_logger_settings~get_max_exception_drill_down( )
msg = |Setter for max drilldown level is not working correctly.|
).
cut->zif_logger_settings~set_max_exception_drill_down( -1 ).
cl_aunit_assert=>assert_equals(
exporting
exp = 20
act = cut->zif_logger_settings~get_max_exception_drill_down( )
msg = |Max exception drill down level should not change if value is incorrect.|
).
cut->zif_logger_settings~set_max_exception_drill_down( 0 ).
cl_aunit_assert=>assert_equals(
exporting
exp = 0
act = cut->zif_logger_settings~get_max_exception_drill_down( )
msg = |Max exception drill down should be deactivatable.|
).
endmethod.
endclass.