-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment6Marking.cs
1077 lines (947 loc) · 40.7 KB
/
Assignment6Marking.cs
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
using CareerCloud.gRPC.Protos;
using CareerCloud.Pocos;
using CareerCloud.gRPC.Services;
using Google.Protobuf.WellKnownTypes;
using Grpc.Core;
using Grpc.Net.Client;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Net.Http;
using CareerCloud.WebAPI.Controllers;
using Microsoft.AspNetCore.Mvc;
namespace CareerCloudCore.UnitTests.Assignment6
{
[TestClass]
public class Assignment6Marking
{
const string Address_gRPC_HOST = "https://localhost:5002"; // the host address where gRPC service is on
private GrpcChannel _channel;
private SystemCountryCodePoco _systemCountry;
private ApplicantEducationPoco _applicantEducation;
private ApplicantProfilePoco _applicantProfile;
private ApplicantJobApplicationPoco _applicantJobApplication;
private CompanyJobPoco _companyJob;
private CompanyProfilePoco _companyProfile;
private CompanyDescriptionPoco _companyDescription;
private SystemLanguageCodePoco _systemLangCode;
private ApplicantResumePoco _applicantResume;
private ApplicantSkillPoco _applicantSkills;
private ApplicantWorkHistoryPoco _appliantWorkHistory;
private CompanyJobEducationPoco _companyJobEducation;
private CompanyJobSkillPoco _companyJobSkill;
private CompanyJobDescriptionPoco _companyJobDescription;
private CompanyLocationPoco _companyLocation;
private SecurityLoginPoco _securityLogin;
private SecurityLoginsLogPoco _securityLoginLog;
private SecurityRolePoco _securityRole;
private SecurityLoginsRolePoco _securityLoginRole;
[TestInitialize]
public void Initialize()
{
var httpHandler = new HttpClientHandler();
// Return `true` to allow certificates that are untrusted/invalid
httpHandler.ServerCertificateCustomValidationCallback =
HttpClientHandler.DangerousAcceptAnyServerCertificateValidator;
_channel = GrpcChannel.ForAddress(Address_gRPC_HOST,
new GrpcChannelOptions { HttpHandler = httpHandler });
Init_Pocos();
}
public void Init_Pocos()
{
SystemCountry_Init();
CompanyProfile_Init();
SystemLangCode_Init();
CompanyDescription_Init();
CompanyJob_Init();
CompanyJobEducation_Init();
CompanyJobSkill_Init();
CompanyJobDescription_Init();
CompanyLocation_Init();
SecurityLogin_Init();
ApplicantProfile_Init();
SecurityLoginLog_Init();
SecurityRole_Init();
SecurityLoginRole_Init();
ApplicantEducation_Init();
ApplicantResume_Init();
ApplicantSkills_Init();
AappliantWorkHistory_Init();
ApplicantJobApplication_Init();
}
#region PocoInitialization
private void ApplicantJobApplication_Init()
{
_applicantJobApplication = new ApplicantJobApplicationPoco()
{
Id = Guid.NewGuid(),
ApplicationDate = Faker.Date.Recent(),
Applicant = _applicantProfile.Id,
Job = _companyJob.Id
};
}
private void AappliantWorkHistory_Init()
{
_appliantWorkHistory = new ApplicantWorkHistoryPoco()
{
Id = Guid.NewGuid(),
Applicant = _applicantProfile.Id,
CompanyName = Truncate(Faker.Lorem.Sentence(), 150),
CountryCode = _systemCountry.Code,
EndMonth = 12,
EndYear = 1999,
JobDescription = Truncate(Faker.Lorem.Sentence(), 500),
JobTitle = Truncate(Faker.Lorem.Sentence(), 50),
Location = Faker.Address.StreetName(),
StartMonth = 1,
StartYear = 1999
};
}
private void ApplicantSkills_Init()
{
_applicantSkills = new ApplicantSkillPoco()
{
Applicant = _applicantProfile.Id,
Id = Guid.NewGuid(),
EndMonth = 12,
EndYear = 1999,
Skill = Truncate(Faker.Lorem.Sentence(), 100),
SkillLevel = Truncate(Faker.Lorem.Sentence(), 10),
StartMonth = 1,
StartYear = 1999
};
}
private void ApplicantResume_Init()
{
_applicantResume = new ApplicantResumePoco()
{
Applicant = _applicantProfile.Id,
Id = Guid.NewGuid(),
Resume = Faker.Lorem.Paragraph(),
LastUpdated = Faker.Date.Recent()
};
}
private void ApplicantEducation_Init()
{
_applicantEducation = new ApplicantEducationPoco()
{
Id = Guid.NewGuid(),
Applicant = _applicantProfile.Id,
Major = Faker.Education.Major(),
CertificateDiploma = Faker.Education.Major(),
StartDate = Faker.Date.Past(3),
TimeStamp = new Byte[5],
CompletionDate = Faker.Date.Forward(1),
CompletionPercent = (byte)Faker.Number.RandomNumber(1)
};
}
private void SecurityLoginRole_Init()
{
_securityLoginRole = new SecurityLoginsRolePoco()
{
Id = Guid.NewGuid(),
Login = _securityLogin.Id,
Role = _securityRole.Id
};
}
private void SecurityRole_Init()
{
_securityRole = new SecurityRolePoco()
{
Id = Guid.NewGuid(),
IsInactive = true,
Role = Truncate(Faker.Company.Industry(), 50)
};
}
private void SecurityLoginLog_Init()
{
_securityLoginLog = new SecurityLoginsLogPoco()
{
Id = Guid.NewGuid(),
IsSuccesful = true,
Login = _securityLogin.Id,
LogonDate = Faker.Date.PastWithTime(),
SourceIP = Faker.Internet.IPv4().PadRight(15)
};
}
private void ApplicantProfile_Init()
{
_applicantProfile = new ApplicantProfilePoco
{
Id = Guid.NewGuid(),
Login = _securityLogin.Id,
City = Faker.Address.CityPrefix(),
Country = _systemCountry.Code,
Currency = "CAN".PadRight(10),
CurrentRate = 71.25M,
CurrentSalary = 67500,
Province = Truncate(Faker.Address.Province(), 10).PadRight(10),
Street = Truncate(Faker.Address.StreetName(), 100),
PostalCode = Truncate(Faker.Address.CanadianZipCode(), 20).PadRight(20)
};
}
private void SecurityLogin_Init()
{
_securityLogin = new SecurityLoginPoco()
{
Login = Faker.User.Email(),
AgreementAccepted = Faker.Date.PastWithTime(),
Created = Faker.Date.PastWithTime(),
EmailAddress = Faker.User.Email(),
ForceChangePassword = false,
FullName = Faker.Name.FullName(),
Id = Guid.NewGuid(),
IsInactive = false,
IsLocked = false,
Password = "SoMePassWord#&@",
PasswordUpdate = Faker.Date.Forward(),
PhoneNumber = "555-416-9889",
PrefferredLanguage = "EN".PadRight(10)
};
}
private void CompanyLocation_Init()
{
_companyLocation = new CompanyLocationPoco()
{
Id = Guid.NewGuid(),
City = Faker.Address.CityPrefix(),
Company = _companyProfile.Id,
CountryCode = _systemCountry.Code,
Province = Faker.Address.ProvinceAbbreviation(),
Street = Faker.Address.StreetName(),
PostalCode = Faker.Address.CanadianZipCode()
};
}
private void CompanyJobDescription_Init()
{
_companyJobDescription = new CompanyJobDescriptionPoco()
{
Id = Guid.NewGuid(),
Job = _companyJob.Id,
JobDescriptions = Truncate(Faker.Lorem.Paragraph(), 999),
JobName = Truncate(Faker.Lorem.Sentence(), 99)
};
}
private void CompanyJobSkill_Init()
{
_companyJobSkill = new CompanyJobSkillPoco()
{
Id = Guid.NewGuid(),
Importance = 2,
Job = _companyJob.Id,
Skill = Truncate(Faker.Lorem.Sentence(), 100),
SkillLevel = String.Concat(Faker.Lorem.Letters(10))
};
}
private void CompanyJobEducation_Init()
{
_companyJobEducation = new CompanyJobEducationPoco()
{
Id = Guid.NewGuid(),
Importance = 2,
Job = _companyJob.Id,
Major = Truncate(Faker.Lorem.Sentence(), 100)
};
}
private void CompanyJob_Init()
{
_companyJob = new CompanyJobPoco()
{
Id = Guid.NewGuid(),
Company = _companyProfile.Id,
IsCompanyHidden = false,
IsInactive = false,
ProfileCreated = Faker.Date.Past()
};
}
private void CompanyDescription_Init()
{
_companyDescription = new CompanyDescriptionPoco()
{
Id = Guid.NewGuid(),
CompanyDescription = Faker.Company.CatchPhrase(),
CompanyName = Faker.Company.CatchPhrasePos(),
LanguageId = _systemLangCode.LanguageID,
Company = _companyProfile.Id
};
}
private void SystemLangCode_Init()
{
_systemLangCode = new SystemLanguageCodePoco()
{
LanguageID = String.Concat(Faker.Lorem.Letters(10)),
NativeName = Truncate(Faker.Lorem.Sentence(), 50),
Name = Truncate(Faker.Lorem.Sentence(), 50)
};
}
private void CompanyProfile_Init()
{
_companyProfile = new CompanyProfilePoco()
{
CompanyWebsite = "www.humber.ca",
ContactName = Faker.Name.FullName(),
ContactPhone = "416-555-8799",
RegistrationDate = Faker.Date.Past(),
Id = Guid.NewGuid(),
CompanyLogo = new byte[10]
};
}
private void SystemCountry_Init()
{
_systemCountry = new SystemCountryCodePoco
{
Code = String.Concat(Faker.Lorem.Letters(10)),
Name = Truncate(Faker.Name.FullName(), 50)
};
}
#endregion PocoInitialization
[TestMethod]
public void Assignment6_DeepDive_CRUD_Test()
{
SystemCountryCodeAdd();
SystemLanguageCode_CRU_Test();
CompanyProfileAdd();
CompanyDescription_CRU_Test();
CompanyJob_CRU_Test();
CompanyJobEducation_CRU_Test();
SecurityLogin_CRU_Test();
SecurityLoginsLog_CRU_Test();
ApplicantProfile_CRU_Test();
ApplicantEducation_CRU_Test();
ApplicantJobApplication_CRU_Test();
// &&&&&&&&&&&&&&&&&&&&&&&&&
#region cleanup
ApplicantJobApplication_D_Test();
ApplicantEducation_D_Test();
ApplicantProfile_D_Test();
SecurityLoginsLog_D_Test();
SecurityLogin_D_Test();
CompanyJobEducation_D_Test();
CompanyJob_D_Test();
CompanyDescription_D_Test();
CompanyProfileRemove();
SystemLanguageCode_D_Test();
SystemCountryCodeRemove();
#endregion cleanup
}
#region SystemLanguageCode_Block
private void SystemLanguageCode_CRU_Test()
{
var client = new SystemLanguageCode.SystemLanguageCodeClient(_channel);
// add
SystemLanguageCodeProto proto = ProtoMapper.MapFromSystemLanguageCodePoco(_systemLangCode);
SystemLanguageCodeList protos = new SystemLanguageCodeList();
protos.Items.Add(proto);
client.AddSystemLanguageCode(protos);
CheckGetSystemLanguageCode(client, new SystemLanguageCodeKey() { LanguageID = proto.LanguageID }, proto);
// check List
protos = client.GetSystemLanguageCodes(new Empty());
Assert.IsTrue(protos.Items.Count > 0);
// check update
proto.Name = Truncate(Faker.Lorem.Sentence(), 50);
proto.NativeName = Truncate(Faker.Lorem.Sentence(), 50);
protos = new SystemLanguageCodeList();
protos.Items.Add(proto);
client.UpdateSystemLanguageCode(protos);
CheckGetSystemLanguageCode(client, new SystemLanguageCodeKey() { LanguageID = proto.LanguageID }, proto);
}
private void SystemLanguageCode_D_Test()
{
var client = new SystemLanguageCode.SystemLanguageCodeClient(_channel);
SystemLanguageCodeProto proto = client.GetSystemLanguageCode(new SystemLanguageCodeKey() { LanguageID = _systemLangCode.LanguageID });
SystemLanguageCodeList protos = new SystemLanguageCodeList();
protos.Items.Add(proto);
client.DeleteSystemLanguageCode(protos);
proto = null;
try
{
proto = client.GetSystemLanguageCode(new SystemLanguageCodeKey() { LanguageID = _systemLangCode.LanguageID });
}
catch (RpcException)
{
}
Assert.IsNull(proto);
}
private SystemLanguageCodeProto CheckGetSystemLanguageCode(SystemLanguageCode.SystemLanguageCodeClient client
, SystemLanguageCodeKey key, SystemLanguageCodeProto compare = null)
{
SystemLanguageCodeProto proto = null;
try
{
proto = client.GetSystemLanguageCode(key);
}
catch (RpcException)
{
Assert.Fail();
}
Assert.IsNotNull(proto);
Assert.AreEqual(proto.LanguageID, key.LanguageID);
if(compare != null)
{
Assert.AreEqual(proto.Name, compare.Name);
Assert.AreEqual(proto.NativeName, compare.NativeName);
}
return proto;
}
#endregion SystemLanguageCode_Block
#region CompanyDescription_Block
private void CompanyDescription_CRU_Test()
{
var client = new CompanyDescription.CompanyDescriptionClient(_channel);
// add
CompanyDescriptionProto proto = ProtoMapper.MapFromCompanyDescriptionPoco(_companyDescription);
CompanyDescriptionList protos = new CompanyDescriptionList();
protos.Items.Add(proto);
client.AddCompanyDescription(protos);
proto = CheckGetCompanyDescription(client, new CompanyDescriptionKey() { Id = proto.Id }, proto);
// check List
protos = client.GetCompanyDescriptions(new Empty());
Assert.IsTrue(protos.Items.Count > 0);
// check update
proto.CompanyDescription = Truncate(Faker.Lorem.Paragraph(), 500);
proto.CompanyName = Truncate(Faker.Lorem.Sentence(), 50);
protos = new CompanyDescriptionList();
protos.Items.Add(proto);
client.UpdateCompanyDescription(protos);
CheckGetCompanyDescription(client, new CompanyDescriptionKey() { Id = proto.Id }, proto);
}
private void CompanyDescription_D_Test()
{
var client = new CompanyDescription.CompanyDescriptionClient(_channel);
CompanyDescriptionProto proto = client.GetCompanyDescription(new CompanyDescriptionKey() { Id = _companyDescription.Id.ToString() });
CompanyDescriptionList protos = new CompanyDescriptionList();
protos.Items.Add(proto);
client.DeleteCompanyDescription(protos);
proto = null;
try
{
proto = client.GetCompanyDescription(new CompanyDescriptionKey() { Id = _companyDescription.Id.ToString() });
}
catch (RpcException)
{
}
Assert.IsNull(proto);
}
private CompanyDescriptionProto CheckGetCompanyDescription(CompanyDescription.CompanyDescriptionClient client
, CompanyDescriptionKey key, CompanyDescriptionProto compare = null)
{
CompanyDescriptionProto proto = null;
try
{
proto = client.GetCompanyDescription(key);
}
catch (RpcException)
{
Assert.Fail();
}
Assert.IsNotNull(proto);
Assert.AreEqual(proto.Id, key.Id);
if (compare != null)
{
Assert.AreEqual(proto.Company, compare.Company);
Assert.AreEqual(proto.LanguageId, compare.LanguageId);
Assert.AreEqual(proto.CompanyName, compare.CompanyName);
Assert.AreEqual(proto.CompanyDescription, compare.CompanyDescription);
}
return proto;
}
#endregion CompanyJob_Block
#region CompanyJob_Block
private void CompanyJob_CRU_Test()
{
var client = new CompanyJob.CompanyJobClient(_channel);
// add
CompanyJobProto proto = ProtoMapper.MapFromCompanyJobPoco(_companyJob);
CompanyJobList protos = new CompanyJobList();
protos.Items.Add(proto);
client.AddCompanyJob(protos);
proto = CheckGetCompanyJob(client, new CompanyJobKey() { Id = proto.Id }, proto);
// check List
protos = client.GetCompanyJobs(new Empty());
Assert.IsTrue(protos.Items.Count > 0);
// check update
proto.IsCompanyHidden = true;
proto.IsInactive = true;
proto.ProfileCreated = ConvertDateTime2TimeStamp(Faker.Date.Past());
protos = new CompanyJobList();
protos.Items.Add(proto);
client.UpdateCompanyJob(protos);
CheckGetCompanyJob(client, new CompanyJobKey() { Id = proto.Id }, proto);
}
private void CompanyJob_D_Test()
{
var client = new CompanyJob.CompanyJobClient(_channel);
CompanyJobProto proto = client.GetCompanyJob(new CompanyJobKey() { Id = _companyJob.Id.ToString() });
CompanyJobList protos = new CompanyJobList();
protos.Items.Add(proto);
client.DeleteCompanyJob(protos);
proto = null;
try
{
proto = client.GetCompanyJob(new CompanyJobKey() { Id = _companyJob.Id.ToString() });
}
catch (RpcException)
{
}
Assert.IsNull(proto);
}
private CompanyJobProto CheckGetCompanyJob(CompanyJob.CompanyJobClient client
, CompanyJobKey key, CompanyJobProto compare = null)
{
CompanyJobProto proto = null;
try
{
proto = client.GetCompanyJob(key);
}
catch (RpcException)
{
Assert.Fail();
}
Assert.IsNotNull(proto);
Assert.AreEqual(proto.Id, key.Id);
if (compare != null)
{
Assert.AreEqual(proto.Company, compare.Company);
Assert.AreEqual(proto.ProfileCreated, compare.ProfileCreated);
Assert.AreEqual(proto.IsInactive, compare.IsInactive);
Assert.AreEqual(proto.IsCompanyHidden, compare.IsCompanyHidden);
}
return proto;
}
#endregion CompanyJob_Block
#region CompanyJobEducation_Block
private void CompanyJobEducation_CRU_Test()
{
var client = new CompanyJobEducation.CompanyJobEducationClient(_channel);
// add
CompanyJobEducationProto proto = ProtoMapper.MapFromCompanyJobEducationPoco(_companyJobEducation);
CompanyJobEducationList protos = new CompanyJobEducationList();
protos.Items.Add(proto);
client.AddCompanyJobEducation(protos);
proto = CheckGetCompanyJobEducation(client, new CompanyJobEducationKey() { Id = proto.Id }, proto);
// check List
protos = client.GetCompanyJobEducations(new Empty());
Assert.IsTrue(protos.Items.Count > 0);
// check update
proto.Importance = 1;
proto.Major = Truncate(Faker.Lorem.Sentence(), 100);
protos = new CompanyJobEducationList();
protos.Items.Add(proto);
client.UpdateCompanyJobEducation(protos);
CheckGetCompanyJobEducation(client, new CompanyJobEducationKey() { Id = proto.Id }, proto);
}
private void CompanyJobEducation_D_Test()
{
var client = new CompanyJobEducation.CompanyJobEducationClient(_channel);
CompanyJobEducationProto proto = client.GetCompanyJobEducation(new CompanyJobEducationKey() { Id = _companyJobEducation.Id.ToString() });
CompanyJobEducationList protos = new CompanyJobEducationList();
protos.Items.Add(proto);
client.DeleteCompanyJobEducation(protos);
proto = null;
try
{
proto = client.GetCompanyJobEducation(new CompanyJobEducationKey() { Id = _companyJobEducation.Id.ToString() });
}
catch (RpcException)
{
}
Assert.IsNull(proto);
}
private CompanyJobEducationProto CheckGetCompanyJobEducation(CompanyJobEducation.CompanyJobEducationClient client
, CompanyJobEducationKey key, CompanyJobEducationProto compare = null)
{
CompanyJobEducationProto proto = null;
try
{
proto = client.GetCompanyJobEducation(key);
}
catch (RpcException)
{
Assert.Fail();
}
Assert.IsNotNull(proto);
Assert.AreEqual(proto.Id, key.Id);
if (compare != null)
{
Assert.AreEqual(proto.Job, compare.Job);
Assert.AreEqual(proto.Major, compare.Major);
Assert.AreEqual(proto.Importance, compare.Importance);
}
return proto;
}
#endregion CompanyJobEducation_Block
#region SecurityLogin_Block
private void SecurityLogin_CRU_Test()
{
var client = new SecurityLogin.SecurityLoginClient(_channel);
// add
SecurityLoginProto proto = ProtoMapper.MapFromSecurityLoginPoco(_securityLogin);
SecurityLoginList protos = new SecurityLoginList();
protos.Items.Add(proto);
client.AddSecurityLogin(protos);
proto = CheckGetSecurityLogin(client, new SecurityLoginKey() { Id = proto.Id }, proto);
// check List
protos = client.GetSecurityLogins(new Empty());
Assert.IsTrue(protos.Items.Count > 0);
// check update
proto.Login = Faker.User.Email();
proto.AgreementAccepted = ConvertDateTime2TimeStamp(Faker.Date.PastWithTime());
proto.Created = ConvertDateTime2TimeStamp(Faker.Date.PastWithTime());
proto.EmailAddress = Faker.User.Email();
proto.ForceChangePassword = true;
proto.FullName = Faker.Name.FullName();
proto.IsInactive = true;
proto.IsLocked = true;
proto.Password = "SoMePassWord@&@";
proto.PasswordUpdate = ConvertDateTime2TimeStamp(Faker.Date.Forward());
proto.PhoneNumber = "416-416-9889";
proto.PrefferredLanguage = "FR".PadRight(10);
protos = new SecurityLoginList();
protos.Items.Add(proto);
client.UpdateSecurityLogin(protos);
CheckGetSecurityLogin(client, new SecurityLoginKey() { Id = proto.Id }, proto);
}
private void SecurityLogin_D_Test()
{
var client = new SecurityLogin.SecurityLoginClient(_channel);
SecurityLoginProto proto = client.GetSecurityLogin(new SecurityLoginKey() { Id = _securityLogin.Id.ToString() });
SecurityLoginList protos = new SecurityLoginList();
protos.Items.Add(proto);
client.DeleteSecurityLogin(protos);
proto = null;
try
{
proto = client.GetSecurityLogin(new SecurityLoginKey() { Id = _securityLogin.Id.ToString() });
}
catch (RpcException)
{
}
Assert.IsNull(proto);
}
private SecurityLoginProto CheckGetSecurityLogin(SecurityLogin.SecurityLoginClient client
, SecurityLoginKey key, SecurityLoginProto compare = null)
{
SecurityLoginProto proto = null;
try
{
proto = client.GetSecurityLogin(key);
}
catch (RpcException)
{
Assert.Fail();
}
Assert.IsNotNull(proto);
Assert.AreEqual(proto.Id, key.Id);
if (compare != null)
{
Assert.AreEqual(proto.Login, compare.Login);
// Assert.AreEqual(proto.PasswordUpdate, compare.PasswordUpdate);
Assert.AreEqual(proto.AgreementAccepted, compare.AgreementAccepted);
// Assert.AreEqual(proto.IsLocked, compare.IsLocked);
// Assert.AreEqual(proto.IsInactive, compare.IsInactive);
Assert.AreEqual(proto.EmailAddress, compare.EmailAddress);
Assert.AreEqual(proto.PhoneNumber, compare.PhoneNumber);
Assert.AreEqual(proto.FullName, compare.FullName);
// Assert.AreEqual(proto.ForceChangePassword, compare.ForceChangePassword);
Assert.AreEqual(proto.PrefferredLanguage, compare.PrefferredLanguage);
}
return proto;
}
#endregion SecurityLogin_Block
#region SecurityLoginsLog_Block
private void SecurityLoginsLog_CRU_Test()
{
var client = new SecurityLoginsLog.SecurityLoginsLogClient(_channel);
// add
SecurityLoginsLogProto proto = ProtoMapper.MapFromSecurityLoginsLogPoco(_securityLoginLog);
SecurityLoginsLogList protos = new SecurityLoginsLogList();
protos.Items.Add(proto);
client.AddSecurityLoginsLog(protos);
proto = CheckGetSecurityLoginsLog(client, new SecurityLoginsLogKey() { Id = proto.Id }, proto);
// check List
protos = client.GetSecurityLoginsLogs(new Empty());
Assert.IsTrue(protos.Items.Count > 0);
// check update
proto.IsSuccesful = false;
proto.LogonDate = ConvertDateTime2TimeStamp(Faker.Date.PastWithTime());
proto.SourceIP = Faker.Internet.IPv4().PadRight(15);
protos = new SecurityLoginsLogList();
protos.Items.Add(proto);
client.UpdateSecurityLoginsLog(protos); // e9261fa9-f0c3-4603-b400-63a5f26952c7
CheckGetSecurityLoginsLog(client, new SecurityLoginsLogKey() { Id = proto.Id }, proto);
}
private void SecurityLoginsLog_D_Test()
{
var client = new SecurityLoginsLog.SecurityLoginsLogClient(_channel);
SecurityLoginsLogProto proto = client.GetSecurityLoginsLog(new SecurityLoginsLogKey() { Id = _securityLoginLog.Id.ToString() });
SecurityLoginsLogList protos = new SecurityLoginsLogList();
protos.Items.Add(proto);
client.DeleteSecurityLoginsLog(protos);
proto = null;
try
{
proto = client.GetSecurityLoginsLog(new SecurityLoginsLogKey() { Id = _securityLoginLog.Id.ToString() });
}
catch (RpcException)
{
}
Assert.IsNull(proto);
}
private SecurityLoginsLogProto CheckGetSecurityLoginsLog(SecurityLoginsLog.SecurityLoginsLogClient client
, SecurityLoginsLogKey key, SecurityLoginsLogProto compare = null)
{
SecurityLoginsLogProto proto = null;
try
{
proto = client.GetSecurityLoginsLog(key);
}
catch (RpcException)
{
Assert.Fail();
}
Assert.IsNotNull(proto);
Assert.AreEqual(proto.Id, key.Id);
if (compare != null)
{
Assert.AreEqual(proto.Login, compare.Login);
Assert.AreEqual(proto.SourceIP, compare.SourceIP);
Assert.AreEqual(proto.LogonDate.ToDateTime().Date, compare.LogonDate.ToDateTime().Date);
}
return proto;
}
#endregion SecurityLoginsLog_Block
#region ApplicantProfile_Block
private void ApplicantProfile_CRU_Test()
{
var client = new ApplicantProfile.ApplicantProfileClient(_channel);
// add
ApplicantProfileProto proto = ProtoMapper.MapFromApplicantProfilePoco(_applicantProfile);
ApplicantProfileList protos = new ApplicantProfileList();
protos.Items.Add(proto);
client.AddApplicantProfile(protos);
proto = CheckGetApplicantProfile(client, new ApplicantProfileKey() { Id = proto.Id }, proto);
// check List
protos = client.GetApplicantProfiles(new Empty());
Assert.IsTrue(protos.Items.Count > 0);
// check update
proto.City = Faker.Address.CityPrefix();
proto.Currency = "US".PadRight(10);
proto.CurrentRate = proto.CurrentRate.ConvertFrom(61.25M);
proto.CurrentSalary = proto.CurrentSalary.ConvertFrom(77500);
proto.Province = Truncate(Faker.Address.Province(), 10).PadRight(10);
proto.Street = Truncate(Faker.Address.StreetName(), 100);
proto.PostalCode = Truncate(Faker.Address.CanadianZipCode(), 20).PadRight(20);
protos = new ApplicantProfileList();
protos.Items.Add(proto);
client.UpdateApplicantProfile(protos); // e9261fa9-f0c3-4603-b400-63a5f26952c7
CheckGetApplicantProfile(client, new ApplicantProfileKey() { Id = proto.Id }, proto);
}
private void ApplicantProfile_D_Test()
{
var client = new ApplicantProfile.ApplicantProfileClient(_channel);
ApplicantProfileProto proto = client.GetApplicantProfile(new ApplicantProfileKey() { Id = _applicantProfile.Id.ToString() });
ApplicantProfileList protos = new ApplicantProfileList();
protos.Items.Add(proto);
client.DeleteApplicantProfile(protos);
proto = null;
try
{
proto = client.GetApplicantProfile(new ApplicantProfileKey() { Id = _applicantProfile.Id.ToString() });
}
catch (RpcException)
{
}
Assert.IsNull(proto);
}
private ApplicantProfileProto CheckGetApplicantProfile(ApplicantProfile.ApplicantProfileClient client
, ApplicantProfileKey key, ApplicantProfileProto compare = null)
{
ApplicantProfileProto proto = null;
try
{
proto = client.GetApplicantProfile(key);
}
catch (RpcException)
{
Assert.Fail();
}
Assert.IsNotNull(proto);
Assert.AreEqual(proto.Id, key.Id);
if (compare != null)
{
Assert.AreEqual(proto.Login, compare.Login);
Assert.AreEqual(proto.CurrentSalary, compare.CurrentSalary);
Assert.AreEqual(proto.CurrentRate, compare.CurrentRate);
Assert.AreEqual(proto.Currency, compare.Currency);
Assert.AreEqual(proto.Country, compare.Country);
Assert.AreEqual(proto.Province, compare.Province);
Assert.AreEqual(proto.Street, compare.Street);
Assert.AreEqual(proto.City, compare.City);
Assert.AreEqual(proto.PostalCode, compare.PostalCode);
}
return proto;
}
#endregion ApplicantProfile_Block
#region ApplicantEducation_Block
private void ApplicantEducation_CRU_Test()
{
var client = new ApplicantEducation.ApplicantEducationClient(_channel);
// add
ApplicantEducationProto proto = ProtoMapper.MapFromApplicantEducationPoco(_applicantEducation);
ApplicantEducationList protos = new ApplicantEducationList();
protos.Items.Add(proto);
client.AddApplicantEducation(protos);
proto = CheckGetApplicantEducation(client, new ApplicantEducationKey() { Id = proto.Id }, proto);
// check List
protos = client.GetApplicantEducations(new Empty());
Assert.IsTrue(protos.Items.Count > 0);
// check update
proto.Major = Faker.Education.Major();
proto.CertificateDiploma = Faker.Education.Major();
proto.StartDate = ConvertDateTime2TimeStamp(Faker.Date.Past(3));
proto.CompletionDate = ConvertDateTime2TimeStamp(Faker.Date.Forward(1));
proto.CompletionPercent = (byte)Faker.Number.RandomNumber(1);
protos = new ApplicantEducationList();
protos.Items.Add(proto);
client.UpdateApplicantEducation(protos); // e9261fa9-f0c3-4603-b400-63a5f26952c7
CheckGetApplicantEducation(client, new ApplicantEducationKey() { Id = proto.Id }, proto);
}
private void ApplicantEducation_D_Test()
{
var client = new ApplicantEducation.ApplicantEducationClient(_channel);
ApplicantEducationProto proto = client.GetApplicantEducation(new ApplicantEducationKey() { Id = _applicantEducation.Id.ToString() });
ApplicantEducationList protos = new ApplicantEducationList();
protos.Items.Add(proto);
client.DeleteApplicantEducation(protos);
proto = null;
try
{
proto = client.GetApplicantEducation(new ApplicantEducationKey() { Id = _applicantEducation.Id.ToString() });
}
catch (RpcException)
{
}
Assert.IsNull(proto);
}
private ApplicantEducationProto CheckGetApplicantEducation(ApplicantEducation.ApplicantEducationClient client
, ApplicantEducationKey key, ApplicantEducationProto compare = null)
{
ApplicantEducationProto proto = null;
try
{
proto = client.GetApplicantEducation(key);
}
catch (RpcException)
{
Assert.Fail();
}
Assert.IsNotNull(proto);
Assert.AreEqual(proto.Id, key.Id);
if (compare != null)
{
Assert.AreEqual(proto.Applicant, compare.Applicant);
Assert.AreEqual(proto.Major, compare.Major);
Assert.AreEqual(proto.CertificateDiploma, compare.CertificateDiploma);
Assert.AreEqual(proto.StartDate.ToDateTime().Date, compare.StartDate.ToDateTime().Date);
Assert.AreEqual(proto.CompletionDate.ToDateTime().Date, compare.CompletionDate.ToDateTime().Date);
Assert.AreEqual(proto.CompletionPercent, compare.CompletionPercent);
}
return proto;
}
#endregion ApplicantEducation_Block
#region ApplicantJobApplication_Block
private void ApplicantJobApplication_CRU_Test()
{
var client = new ApplicantJobApplication.ApplicantJobApplicationClient(_channel);
// add
ApplicantJobApplicationProto proto = ProtoMapper.MapFromApplicantJobApplicationPoco(_applicantJobApplication);
ApplicantJobApplicationList protos = new ApplicantJobApplicationList();
protos.Items.Add(proto);
client.AddApplicantJobApplication(protos);
proto = CheckGetApplicantJobApplication(client, new ApplicantJobApplicationKey() { Id = proto.Id }, proto);
// check List
protos = client.GetApplicantJobApplications(new Empty());
Assert.IsTrue(protos.Items.Count > 0);
// check update
proto.ApplicationDate = ConvertDateTime2TimeStamp(Faker.Date.Recent());
protos = new ApplicantJobApplicationList();
protos.Items.Add(proto);
client.UpdateApplicantJobApplication(protos); // e9261fa9-f0c3-4603-b400-63a5f26952c7
CheckGetApplicantJobApplication(client, new ApplicantJobApplicationKey() { Id = proto.Id }, proto);
}
private void ApplicantJobApplication_D_Test()
{
var client = new ApplicantJobApplication.ApplicantJobApplicationClient(_channel);
ApplicantJobApplicationProto proto = client.GetApplicantJobApplication(new ApplicantJobApplicationKey() { Id = _applicantJobApplication.Id.ToString() });
ApplicantJobApplicationList protos = new ApplicantJobApplicationList();
protos.Items.Add(proto);