16
16
public class ApplicationBaseUnitTests
17
17
{
18
18
[ Test ]
19
- public void OnDataProcessingEventShouldBeRized ( )
19
+ public void OnDataProcessingEventShouldBeRaized ( )
20
20
{
21
21
var app = this . GetAppMock ( ) ;
22
-
23
22
bool flag = false ;
24
23
app . OnDataProcessingEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
25
24
{
@@ -33,10 +32,9 @@ public void OnDataProcessingEventShouldBeRized()
33
32
}
34
33
35
34
[ Test ]
36
- public void OnDataProcessedEventShouldBeRized ( )
35
+ public void OnDataProcessedEventShouldBeRaized ( )
37
36
{
38
37
var app = this . GetAppMock ( ) ;
39
-
40
38
bool flag = false ;
41
39
app . OnDataProcessedEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
42
40
{
@@ -50,10 +48,9 @@ public void OnDataProcessedEventShouldBeRized()
50
48
}
51
49
52
50
[ Test ]
53
- public void OnSearchDataProcessingEventShouldBeRized ( )
51
+ public void OnSearchDataProcessingEventShouldBeRaized ( )
54
52
{
55
53
var app = this . GetAppMock ( ) ;
56
-
57
54
bool flag = false ;
58
55
app . OnSearchDataProcessingEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
59
56
{
@@ -66,14 +63,158 @@ public void OnSearchDataProcessingEventShouldBeRized()
66
63
Assert . IsTrue ( flag ) ;
67
64
}
68
65
66
+ [ Test ]
67
+ public void OnSearchDataProcessedEventShouldBeRaized ( )
68
+ {
69
+ var app = this . GetAppMock ( ) ;
70
+ bool flag = false ;
71
+ app . OnSearchDataProcessedEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
72
+ {
73
+ Trace . WriteLine ( flag ) ;
74
+ flag = true ;
75
+ } ;
76
+
77
+ app . Execute ( ) ;
78
+
79
+ Assert . IsTrue ( flag ) ;
80
+ }
81
+
82
+ [ Test ]
83
+ public void OnColumnsFilterDataProcessingEventShouldBeRaized ( )
84
+ {
85
+ var app = this . GetAppMock ( ) ;
86
+ bool flag = false ;
87
+ app . OnColumnsFilterDataProcessingEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
88
+ {
89
+ Trace . WriteLine ( flag ) ;
90
+ flag = true ;
91
+ } ;
92
+
93
+ app . Execute ( ) ;
94
+
95
+ Assert . IsTrue ( flag ) ;
96
+ }
97
+
98
+ [ Test ]
99
+ public void OnColumnsFilterDataProcessedEventShouldBeRaized ( )
100
+ {
101
+ var app = this . GetAppMock ( ) ;
102
+ bool flag = false ;
103
+ app . OnColumnsFilterDataProcessedEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
104
+ {
105
+ Trace . WriteLine ( flag ) ;
106
+ flag = true ;
107
+ } ;
108
+
109
+ app . Execute ( ) ;
110
+
111
+ Assert . IsTrue ( flag ) ;
112
+ }
113
+
114
+ [ Test ]
115
+ public void OnCustomFiltersDataProcessingEventShouldBeRaized ( )
116
+ {
117
+ var app = this . GetAppMock ( ) ;
118
+ bool flag = false ;
119
+ app . OnCustomFiltersDataProcessingEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
120
+ {
121
+ Trace . WriteLine ( flag ) ;
122
+ flag = true ;
123
+ } ;
124
+
125
+ app . Execute ( ) ;
126
+
127
+ Assert . IsTrue ( flag ) ;
128
+ }
129
+
130
+ [ Test ]
131
+ public void OnCustomFiltersDataProcessedEventShouldBeRaized ( )
132
+ {
133
+ var app = this . GetAppMock ( ) ;
134
+ bool flag = false ;
135
+ app . OnCustomFiltersDataProcessedEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
136
+ {
137
+ Trace . WriteLine ( flag ) ;
138
+ flag = true ;
139
+ } ;
140
+
141
+ app . Execute ( ) ;
142
+
143
+ Assert . IsTrue ( flag ) ;
144
+ }
145
+
146
+ [ Test ]
147
+ public void OnPagingDataProcessingEventShouldBeRaized ( )
148
+ {
149
+ var app = this . GetAppMock ( ) ;
150
+ bool flag = false ;
151
+ app . OnPagingDataProcessingEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
152
+ {
153
+ Trace . WriteLine ( flag ) ;
154
+ flag = true ;
155
+ } ;
156
+
157
+ app . Execute ( ) ;
158
+
159
+ Assert . IsTrue ( flag ) ;
160
+ }
161
+
162
+ [ Test ]
163
+ public void OnPagingDataProcessedEventShouldBeRaized ( )
164
+ {
165
+ var app = this . GetAppMock ( ) ;
166
+ bool flag = false ;
167
+ app . OnPagingDataProcessedEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
168
+ {
169
+ Trace . WriteLine ( flag ) ;
170
+ flag = true ;
171
+ } ;
172
+
173
+ app . Execute ( ) ;
174
+
175
+ Assert . IsTrue ( flag ) ;
176
+ }
177
+
178
+ [ Test ]
179
+ public void OnSortDataProcessingEventShouldBeRaized ( )
180
+ {
181
+ var app = this . GetAppMock ( ) ;
182
+ bool flag = false ;
183
+ app . OnSortDataProcessingEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
184
+ {
185
+ Trace . WriteLine ( flag ) ;
186
+ flag = true ;
187
+ } ;
188
+
189
+ app . Execute ( ) ;
190
+
191
+ Assert . IsTrue ( flag ) ;
192
+ }
193
+
194
+ [ Test ]
195
+ public void OnSortDataProcessedEventShouldBeRaized ( )
196
+ {
197
+ var app = this . GetAppMock ( ) ;
198
+ bool flag = false ;
199
+ app . OnSortDataProcessedEvent += ( ref object data , RequestInfoModel requestInfoModel ) =>
200
+ {
201
+ Trace . WriteLine ( flag ) ;
202
+ flag = true ;
203
+ } ;
204
+
205
+ app . Execute ( ) ;
206
+
207
+ Assert . IsTrue ( flag ) ;
208
+ }
209
+
69
210
public AppMock < IntModel > GetAppMock ( )
70
211
{
71
212
var serviceLocatorMock = new Mock < IServiceLocator > ( ) ;
72
- serviceLocatorMock . Setup ( x => x . GetSearchDataProcessor < IntModel > ( ) ) . Returns ( this . GetDataFilterMock ( ) . Object ) ;
73
- serviceLocatorMock . Setup ( x => x . GetColumnsFilterDataProcessor < IntModel > ( ) ) . Returns ( this . GetDataFilterMock ( ) . Object ) ;
74
- serviceLocatorMock . Setup ( x => x . GetCustomFiltersDataProcessor < IntModel > ( ) ) . Returns ( this . GetDataFilterMock ( ) . Object ) ;
75
- serviceLocatorMock . Setup ( x => x . GetPagingDataProcessor < IntModel > ( ) ) . Returns ( this . GetDataProcessMock ( ) . Object ) ;
76
- serviceLocatorMock . Setup ( x => x . GetSortDataProcessor < IntModel > ( ) ) . Returns ( this . GetDataProcessMock ( ) . Object ) ;
213
+ serviceLocatorMock . Setup ( x => x . GetSearchDataProcessor < IntModel > ( ) ) . Returns ( new DataProcessorFilterFake < IntModel > ( ) ) ;
214
+ serviceLocatorMock . Setup ( x => x . GetColumnsFilterDataProcessor < IntModel > ( ) ) . Returns ( new DataProcessorFilterFake < IntModel > ( ) ) ;
215
+ serviceLocatorMock . Setup ( x => x . GetCustomFiltersDataProcessor < IntModel > ( ) ) . Returns ( new DataProcessorFilterFake < IntModel > ( ) ) ;
216
+ serviceLocatorMock . Setup ( x => x . GetPagingDataProcessor < IntModel > ( ) ) . Returns ( new DataProcessorNotFilterFake < IntModel > ( ) ) ;
217
+ serviceLocatorMock . Setup ( x => x . GetSortDataProcessor < IntModel > ( ) ) . Returns ( new DataProcessorNotFilterFake < IntModel > ( ) ) ;
77
218
var formModelBinderMock = new Mock < IFormModelBinder > ( ) ;
78
219
formModelBinderMock . Setup ( x => x . BindModel ( It . IsAny < NameValueCollection > ( ) , It . IsAny < IQueryable < IntModel > > ( ) ) ) . Returns ( new RequestInfoModel ( ) { Helpers = new RequestHelpers ( ) , TableParameters = new DataTableAjaxPostModel ( ) } ) ;
79
220
var app = new AppMock < IntModel > ( serviceLocatorMock . Object , formModelBinderMock . Object ) ;
@@ -85,7 +226,7 @@ private Mock<IDataProcess<IntModel>> GetDataProcessMock()
85
226
{
86
227
var mock = new Mock < IDataProcess < IntModel > > ( ) ;
87
228
mock . Setup ( x => x . ProcessData ( It . IsAny < IQueryable < IntModel > > ( ) , It . IsAny < RequestInfoModel > ( ) ) ) . Returns ( new List < IntModel > ( ) . AsQueryable ( ) ) ;
88
- mock . Raise ( x => x . OnDataProcessedEvent += delegate { } ) ;
229
+ // mock.Raise(x => x.OnDataProcessedEvent += delegate { });
89
230
return mock ;
90
231
}
91
232
0 commit comments