Produced by Araxis Merge on 4/7/2019 7:13:56 PM Eastern Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | MHLTH_CLOZ_MOD _SRC.zip\MHLTH_CLOZ_MOD _SRC\Releases\ClozMod_Build5_.zip\Va.Gov.Nccc.Registry.Tests\SystemAdministration | SystemAdministrationControllerTest.cs | Mon Mar 4 20:33:52 2019 UTC |
2 | MHLTH_CLOZ_MOD _SRC.zip\MHLTH_CLOZ_MOD _SRC\Releases\ClozMod_Build5_.zip\Va.Gov.Nccc.Registry.Tests\SystemAdministration | SystemAdministrationControllerTest.cs | Thu Apr 4 19:05:44 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 9 | 742 |
Changed | 8 | 16 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | using Micr osoft.Visu alStudio.T estTools.U nitTesting ; | |
2 | using Va.G ov.Nccc.Re gistry.Con trollers; | |
3 | using Va.G ov.Nccc.Re gistry.Mod els.Home; | |
4 | using Va.G ov.Nccc.Da ta.Common. Repository ; | |
5 | using Va.G ov.Nccc.Da ta.Common. FacilityRe gistryUser s; | |
6 | using Moq; | |
7 | using Va.G ov.Nccc.Da ta.Common. RegistryUs ers; | |
8 | using Syst em.Threadi ng.Tasks; | |
9 | using Va.G ov.Nccc.Da ta.Common. Results; | |
10 | using Syst em.Collect ions.Gener ic; | |
11 | using Syst em.Web.Mvc ; | |
12 | using Va.G ov.Nccc.Da ta.Common. PhoneNumbe rs; | |
13 | using Va.G ov.Nccc.Da ta.Common. Facilities ; | |
14 | using Va.G ov.Nccc.Da ta.Common; | |
15 | using Va.G ov.Nccc.Da ta.Common. Roles; | |
16 | using Syst em.Compone ntModel; | |
17 | ||
18 | namespace Va.Gov.Ncc c.Registry .Tests.Sys temAdminis tration | |
19 | { | |
20 | [TestC lass] | |
21 | public class Sys temAdminis trationCon trollerTes t | |
22 | { | |
23 | Sy stemAdmini strationCo ntroller c ontrollerS ystemUnder Test; | |
24 | Lo ginViewMod el modelTo BePassedTo SystemUnde rTest; | |
25 | Mo ck<IReposi tory> mock NcccReposi tory; | |
26 | Mo ck<IFacili tyRegistry UsersRepos itory> moc kIFacility RegistryUs ersReposit ory; | |
27 | Mo ck<IRegist ryUsersRep ository> m ockIRegist ryUsersRep ository; | |
28 | Mo ck<IFacili tiesReposi tory> mock IFacilityR epository; | |
29 | Mo ck<IRolesR epository> mockIRole sRepositor y; | |
30 | ||
31 | ||
32 | [T estInitial ize] | |
33 | pu blic void TestMethod 1() | |
34 | { | |
35 | // Mock out our us er reposit ory (a fak e concrete instance) | |
36 | mockIFac ilityRegis tryUsersRe pository = new Mock< IFacilityR egistryUse rsReposito ry>(MockBe havior.Loo se); | |
37 | mockIReg istryUsers Repository = new Moc k<IRegistr yUsersRepo sitory>(Mo ckBehavior .Loose); | |
38 | mockIFac ilityRepos itory = ne w Mock<IFa cilitiesRe pository>( MockBehavi or.Loose); | |
39 | mockIRol esReposito ry = new M ock<IRoles Repository >(MockBeha vior.Loose ); | |
40 | ||
41 | // Mock out our la rger repos itory (tha t collects all the r epositorie s) | |
42 | mockNccc Repository = new Moc k<IReposit ory>(MockB ehavior.Lo ose); | |
43 | ||
44 | // Set u p the meth od for the larger re pository t hat calls the smalle r reposito ry | |
45 | mockNccc Repository .Setup(p = > p.Facili tyRegistry Users).Ret urns(mockI FacilityRe gistryUser sRepositor y.Object); | |
46 | mockNccc Repository .Setup(p = > p.Users) .Returns(m ockIRegist ryUsersRep ository.Ob ject); | |
47 | mockNccc Repository .Setup(p = > p.Facili ties).Retu rns(mockIF acilityRep ository.Ob ject); | |
48 | mockNccc Repository .Setup(p = > p.Roles) .Returns(m ockIRolesR epository. Object); | |
49 | ||
50 | ||
51 | // Creat e a concre te instanc e of the s ystem we w ill be tes ting | |
52 | controll erSystemUn derTest = new System Administra tionContro ller(mockN cccReposit ory.Object ); | |
53 | ||
54 | // Pass a concrete ViewModel to the co ntroller | |
55 | modelToB ePassedToS ystemUnder Test = new LoginView Model(); | |
56 | } | |
57 | [T estMethod( )] | |
58 | pu blic async Task Inde xSuccess() | |
59 | { | |
60 | //Setup | |
61 | mockIReg istryUsers Repository .Setup(p = > p.ReadAj axAdmin(1, 8, string .Empty, "S uper Admin istrator") ).ReturnsA sync(new P agedListRe sult<Regis tryUser> | |
62 | { | |
63 | List = new Lis t<Registry User> | |
64 | { | |
65 | new Regist ryUser { UserName = "UserName ", EmailAd dress = " PII ", | |
66 | Regis tryUserNam e = new Da ta.Common. PersonName { First=" First Test ",Last="La st Test"}, | |
67 | }, | |
68 | new Regist ryUser { U serName = "UserName2 ", EmailAd dress = " PII ", | |
69 | PhoneN umber= new PhoneNumb er { Numbe r ="932-00 0-0000" }, | |
70 | Regist ryUserName = new Dat a.Common.P ersonName { First="F irst Test2 ",Last="La st Test2"} , }, | |
71 | }, | |
72 | Succ ess = true | |
73 | }); | |
74 | ||
75 | //Action | |
76 | ActionRe sult resul t = await controller SystemUnde rTest.Inde x(); | |
77 | ||
78 | Redirect ToRouteRes ult redire ctResult = result as RedirectT oRouteResu lt; | |
79 | ||
80 | //Assert | |
81 | Assert.I sNotNull(r esult); | |
82 | Assert.I sInstanceO fType(resu lt, typeof (ViewResul t)); | |
83 | } | |
84 | ||
85 | [T estMethod( )] | |
86 | pu blic async Task Load Facilities Admin_Dele te_Success () | |
87 | { | |
88 | ||
89 | mockIFac ilityRegis tryUsersRe pository.S etup(p => p.Removead ministrato r(It.IsAny <int>(),It .IsAny<int >())).Retu rnsAsync(n ew ItemRes ult<Facili tyRegistry User> | |
90 | { | |
91 | Succ ess = true , | |
92 | Item = null, | |
93 | ||
94 | }); | |
95 | ||
96 | ||
97 | //loadin g facility admin | |
98 | mockIFac ilityRepos itory.Setu p(p => p.R eadAsync(I t.IsAny<in t>())).Ret urnsAsync( new ItemRe sult<Facil ity> | |
99 | { | |
100 | Succ ess = true , | |
101 | Item = new Fac ility | |
102 | { | |
103 | Id = 2, | |
104 | Parent = n ew Facilit y | |
105 | { | |
106 | Id = 2 , | |
107 | Statio nName = "t est", | |
108 | Statio nNumber = 900, | |
109 | ShortN ame = "tes t12", | |
110 | Addres s = new Ad dress { Ci ty = "city ", State = "tx", Zip Code = "75 094", Line 1 = "l1", Line2 = "l 2" }, | |
111 | Region = "region ", | |
112 | ||
113 | }, | |
114 | Address = new Addres s { City = "city", S tate = "tx ", ZipCode = "75094" , Line1 = "l1", Line 2 = "l2" } , | |
115 | StationNam e = "test" , | |
116 | StationNum ber = 900, | |
117 | } | |
118 | ||
119 | }); | |
120 | ||
121 | mockIFac ilityRegis tryUsersRe pository.S etup(p => p.ReadAllU sers(1)).R eturns(new ListResul t<Facility RegistryUs er> | |
122 | { | |
123 | List = new Lis t<Facility RegistryUs er> | |
124 | { | |
125 | new Facil ityRegistr yUser { | |
126 | Regist ryUserId = 1, Facilit y = new Fa cility { I d = 1, Sho rtName="SN ", | |
127 | Addre ss = new A ddress { C ity = "cit y", State = "tx", Zi pCode = "7 5094", Lin e1 = "l1", Line2 = " l2" }, | |
128 | Parent = new Fac ility { Id = 1 }, St ationName = "test", StationNum ber = 900 }, | |
129 | Regist ryUser = n ew Registr yUser | |
130 | { EmailAdd ress = " PII ", PhoneNu mber = new PhoneNumb er { Numbe r = "972-0 00-0000" } , | |
131 | Re gistryUser Name = new PersonNam e { First = "First T est", Last = "Last T est" }, | |
132 | Id =1, Activ e=true | |
133 | } | |
134 | } | |
135 | , | |
136 | }, | |
137 | Succ ess = true | |
138 | }); | |
139 | ||
140 | //Action | |
141 | ActionRe sult resul t = await controller SystemUnde rTest.Load Facilities Admins(1, 0, 1); | |
142 | Redirect ToRouteRes ult redire ctResult = result as RedirectT oRouteResu lt; | |
143 | ||
144 | //Assert | |
145 | Assert.I sNotNull(r esult); | |
146 | Assert.I sInstanceO fType(resu lt, typeof (ActionRes ult)); | |
147 | ||
148 | } | |
149 | ||
150 | ||
151 | [T estMethod( )] | |
152 | pu blic async Task Load Facilities Admin_Dele te_Fail() | |
153 | { | |
154 | ||
155 | mockIFac ilityRegis tryUsersRe pository.S etup(p => p.Removead ministrato r(It.IsAny <int>(),It .IsAny<int >())).Retu rnsAsync(n ew ItemRes ult<Facili tyRegistry User> | |
156 | { | |
157 | Succ ess = fals e, | |
158 | Item = null, | |
159 | ||
160 | }); | |
161 | ||
162 | //loadin g facility admin | |
163 | mockIFac ilityRepos itory.Setu p(p => p.R eadAsync(I t.IsAny<in t>())).Ret urnsAsync( new ItemRe sult<Facil ity> | |
164 | { | |
165 | Succ ess = true , | |
166 | Item = new Fac ility | |
167 | { | |
168 | Id = 2, | |
169 | Parent = n ew Facilit y | |
170 | { | |
171 | Id = 2 , StationN ame = "tes t", Statio nNumber = 900, Short Name = "te st12", | |
172 | Addres s = new Ad dress { Ci ty = "city ", State = "tx", Zip Code = "75 094", Line 1 = "l1", Line2 = "l 2" }, | |
173 | Region = "region ", | |
174 | ||
175 | }, | |
176 | Address = new Addres s { City = "city", S tate = "tx ", ZipCode = "75094" , Line1 = "l1", Line 2 = "l2" } , | |
177 | StationNam e = "test" , Statio nNumber = 900, | |
178 | } | |
179 | ||
180 | }); | |
181 | ||
182 | mockIFac ilityRegis tryUsersRe pository.S etup(p => p.ReadAllU sers(1)).R eturns(new ListResul t<Facility RegistryUs er> | |
183 | { | |
184 | List = new Lis t<Facility RegistryUs er> | |
185 | { | |
186 | new Facil ityRegistr yUser { | |
187 | Regist ryUserId = 1, Facilit y = new Da ta.Common. Facilities .Facility { Id = 1, | |
188 | Addre ss = new A ddress { C ity = "cit y", State = "tx", Zi pCode = "7 5094", Lin e1 = "l1", Line2 = " l2" }, | |
189 | Parent = new Fac ility { Id = 1 }, St ationName = "test", StationNum ber = 900 }, | |
190 | Regist ryUser = n ew Registr yUser | |
191 | { EmailAdd ress = " PII ", PhoneNumbe r = new Ph oneNumber { Number = "972-000- 0000" }, | |
192 | Re gistryUser Name = new PersonNam e { First = "First T est", Last = "Last T est" }, I d=1, Acti ve=true | |
193 | } | |
194 | } | |
195 | , | |
196 | }, | |
197 | Succ ess = true | |
198 | }); | |
199 | ||
200 | //Action | |
201 | ActionRe sult resul t = await controller SystemUnde rTest.Load Facilities Admins(1, 0, 1); | |
202 | Redirect ToRouteRes ult redire ctResult = result as RedirectT oRouteResu lt; | |
203 | ||
204 | //Assert | |
205 | Assert.I sNotNull(r esult); | |
206 | Assert.I sInstanceO fType(resu lt, typeof (ActionRes ult)); | |
207 | ||
208 | } | |
209 | ||
210 | [T estMethod( )] | |
211 | pu blic async Task Load Facilities AdminSucce ss() | |
212 | { | |
213 | //loadin g facility admin | |
214 | mockIFac ilityRepos itory.Setu p(p => p.R eadAsync(I t.IsAny<in t>())).Ret urnsAsync( new ItemRe sult<Facil ity> | |
215 | { | |
216 | Succ ess = true , | |
217 | Item = new Fac ility | |
218 | { | |
219 | Id = 2, | |
220 | Parent = n ew Facilit y | |
221 | { | |
222 | Id = 2 , StationN ame = "tes t", Stati onNumber = 900, Shor tName = "t est12", | |
223 | Addres s = new Ad dress { Ci ty = "city ", State = "tx", Zip Code = "75 094", Line 1 = "l1", Line2 = "l 2" }, | |
224 | Region = "region ", | |
225 | }, | |
226 | Address = new Addres s { City = "city", S tate = "tx ", ZipCode = "75094" , Line1 = "l1", Line 2 = "l2" } , | |
227 | StationNam e = "test" , Station Number = 9 00, | |
228 | } | |
229 | ||
230 | }); | |
231 | ||
232 | mockIFac ilityRegis tryUsersRe pository.S etup(p => p.ReadAllU sers(1)).R eturns(new ListResul t<Facility RegistryUs er> | |
233 | { | |
234 | List = new Lis t<Facility RegistryUs er> | |
235 | { | |
236 | new Facil ityRegistr yUser { | |
237 | Regist ryUserId = 1, Facilit y = new Fa cility { I d = 1, | |
238 | Addres s = new Ad dress { Ci ty = "city ", State = "tx", Zip Code = "75 094", Line 1 = "l1", Line2 = "l 2" }, | |
239 | Parent = new Fac ility { Id = 1 }, St ationName = "test", StationNum ber = 900 }, | |
240 | Regist ryUser = n ew Registr yUser | |
241 | { EmailAddre ss = " PII ", PhoneNumbe r = new Ph oneNumber { Number = "972-000- 0000" }, | |
242 | Re gistryUser Name = new PersonNam e { First = "First T est", Last = "Last T est" }, I d=1, Ac tive=true | |
243 | } | |
244 | } | |
245 | , | |
246 | }, | |
247 | Succ ess = true | |
248 | }); | |
249 | ||
250 | mockIFac ilityRegis tryUsersRe pository.S etup(p => p.Createad min(1, 1)) .ReturnsAs ync(new It emResult<F acilityReg istryUser> | |
251 | { | |
252 | Item = new Fac ilityRegis tryUser | |
253 | { | |
254 | RegistryUs erId = 1, | |
255 | Facility = new Facil ity | |
256 | { | |
257 | Id = 1 , Parent = new Facil ity { Id = 1 }, Stat ionName = "test", St ationNumbe r = 900, | |
258 | Addres s = new Ad dress { Ci ty = "city ", State = "tx", Zip Code = "75 094", Line 1 = "l1", Line2 = "l 2" }, | |
259 | }, | |
260 | RegistryUs er = new R egistryUse r | |
261 | { | |
262 | EmailAddre ss = " PII ", PhoneNu mber = new PhoneNumb er { Numbe r = "972-0 00-0000" } , | |
263 | Regist ryUserName = new Per sonName { First = "F irst Test" , Last = " Last Test" }, | |
264 | }, | |
265 | ||
266 | }, | |
267 | Succ ess = true | |
268 | }); | |
269 | ||
270 | //Action | |
271 | ActionRe sult resul t = await controller SystemUnde rTest.Load Facilities Admins(1, 1, 0); | |
272 | Redirect ToRouteRes ult redire ctResult = result as RedirectT oRouteResu lt; | |
273 | ||
274 | //Assert | |
275 | Assert.I sNotNull(r esult); | |
276 | Assert.I sInstanceO fType(resu lt, typeof (ActionRes ult)); | |
277 | ||
278 | } | |
279 | ||
280 | pu blic async Task Load Facilities Admin_Fail () | |
281 | { | |
282 | //loadin g facility admin | |
283 | mockIFac ilityRepos itory.Setu p(p => p.R eadAsync(I t.IsAny<in t>())).Ret urnsAsync( new ItemRe sult<Facil ity> | |
284 | { | |
285 | Succ ess = fals e, | |
286 | Item = new Fac ility | |
287 | { | |
288 | Id = 2, | |
289 | Parent = n ew Facilit y | |
290 | { | |
291 | Id = 2 , StationN ame = "tes t", Stati onNumber = 900, Shor tName = "t est12", | |
292 | Addres s = new Ad dress { Ci ty = "city ", State = "tx", Zip Code = "75 094", Line 1 = "l1", Line2 = "l 2" }, | |
293 | Region = "region ", | |
294 | }, | |
295 | Address = new Addres s { City = "city", S tate = "tx ", ZipCode = "75094" , Line1 = "l1", Line 2 = "l2" } , | |
296 | StationNam e = "test" , Statio nNumber = 900, | |
297 | } | |
298 | ||
299 | }); | |
300 | ||
301 | mockIFac ilityRegis tryUsersRe pository.S etup(p => p.ReadAllU sers(1)).R eturns(new ListResul t<Facility RegistryUs er> | |
302 | { | |
303 | List = new Lis t<Facility RegistryUs er> | |
304 | { | |
305 | new Facil ityRegistr yUser { | |
306 | Regist ryUserId = 1, Facilit y = new Fa cility { I d = 1, | |
307 | Addres s = new Ad dress { Ci ty = "city ", State = "tx", Zip Code = "75 094", Line 1 = "l1", Line2 = "l 2" }, | |
308 | Parent = new Fac ility { Id = 1 }, St ationName = "test", StationNum ber = 900 }, | |
309 | Regist ryUser = n ew Registr yUser | |
310 | { EmailAddre ss = " PII ", | |
311 | Ph oneNumber = new Phon eNumber { Number = " 972-000-00 00" }, | |
312 | Re gistryUser Name = new PersonNam e { First = "First T est", Last = "Last T est" }, | |
313 | Id =1, Activ e=true | |
314 | } | |
315 | } | |
316 | , | |
317 | }, | |
318 | Succ ess = fals e | |
319 | }); | |
320 | ||
321 | mockIFac ilityRegis tryUsersRe pository.S etup(p => p.Createad min(1, 1)) .ReturnsAs ync(new It emResult<F acilityReg istryUser> | |
322 | { | |
323 | Item = new Fac ilityRegis tryUser | |
324 | { | |
325 | RegistryUs erId = 1, | |
326 | Facility = new Facil ity | |
327 | { | |
328 | Id = 1 , Parent = new Facil ity { Id = 1 }, Stat ionName = "test", St ationNumbe r = 900, | |
329 | Addres s = new Ad dress { Ci ty = "city ", State = "tx", Zip Code = "75 094", Line 1 = "l1", Line2 = "l 2" }, | |
330 | }, | |
331 | RegistryU ser = new RegistryUs er | |
332 | { | |
333 | EmailAddre ss = " PII ", PhoneNumbe r = new Ph oneNumber { Number = "972-000- 0000" }, | |
334 | Regist ryUserName = new Per sonName { First = "F irst Test" , Last = " Last Test" }, | |
335 | }, | |
336 | ||
337 | }, | |
338 | Succ ess = fals e | |
339 | }); | |
340 | ||
341 | //Action | |
342 | ActionRe sult resul t = await controller SystemUnde rTest.Load Facilities Admins(1, 1, 0); | |
343 | Redirect ToRouteRes ult redire ctResult = result as RedirectT oRouteResu lt; | |
344 | ||
345 | //Assert | |
346 | Assert.I sNotNull(r esult); | |
347 | Assert.I sInstanceO fType(resu lt, typeof (ActionRes ult)); | |
348 | ||
349 | } | |
350 | [T estMethod( )] | |
351 | pu blic void FacilityUs ersRoles() { | |
352 | mockIRol esReposito ry.Setup(p => p.Read FacilityRo les(true,I t.IsAny<in t>(), It.I sAny<int>( ), It.IsAn y<ListSort Direction> ())).Retur ns(new Pag edListResu lt<Role> | |
353 | { | |
354 | List = new Lis t<Role> | |
355 | { | |
356 | new Role { Descripti on = "this is a desc ription", RoleName=" Administra tion",Id=1 }, | |
357 | new Role { Descripti on = "this is a desc ription", RoleName=" Staff" , I d=2 }, | |
358 | }, | |
359 | Succ ess = true | |
360 | ||
361 | }); | |
362 | ||
363 | //Action | |
364 | ActionRe sult resul t = contro llerSystem UnderTest. FacilityUs ersRoles(t rue, 15); | |
365 | Redirect ToRouteRes ult redire ctResult = result as RedirectT oRouteResu lt; | |
366 | ||
367 | //Assert | |
368 | Assert.I sNotNull(r esult); | |
369 | Assert.I sInstanceO fType(resu lt, typeof (ViewResul t)); | |
370 | ||
371 | ||
372 | ||
373 | } | |
374 | ||
375 | ||
376 | ||
377 | ||
378 | } | |
379 | } |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.