Skip to content

Commit c427e6d

Browse files
Merge branch 'Release-2024.32' into Develop/Features/TD-3903-RegisterAdminController-refactor(Controller-Service-Repositorypattern)
2 parents c715058 + ad90f3b commit c427e6d

File tree

19 files changed

+384
-355
lines changed

19 files changed

+384
-355
lines changed

DigitalLearningSolutions.Data/DataServices/RoleProfileService.cs renamed to DigitalLearningSolutions.Data/DataServices/RoleProfileDataService.cs

Lines changed: 197 additions & 197 deletions
Large diffs are not rendered by default.

DigitalLearningSolutions.Web.Tests/Controllers/Login/LoginControllerTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ internal class LoginControllerTests
4141
private ILoginService loginService = null!;
4242
private ISessionService sessionService = null!;
4343
private IUrlHelper urlHelper = null!;
44-
private IConfigDataService configDataService = null!;
44+
private IConfigService configService = null!;
4545
private IUserService userService = null!;
4646
private IConfiguration config = null!;
4747
private ILearningHubUserApiClient apiClient = null!;
@@ -54,7 +54,7 @@ public void SetUp()
5454
logger = A.Fake<ILogger<LoginController>>();
5555
userService = A.Fake<IUserService>();
5656
urlHelper = A.Fake<IUrlHelper>();
57-
configDataService = A.Fake<IConfigDataService>();
57+
configService = A.Fake<IConfigService>();
5858
clockUtility = A.Fake<IClockUtility>();
5959
config = A.Fake<IConfiguration>();
6060
apiClient = A.Fake<ILearningHubUserApiClient>();
@@ -68,7 +68,7 @@ public void SetUp()
6868
logger,
6969
userService,
7070
clockUtility,
71-
configDataService,
71+
configService,
7272
config,
7373
apiClient
7474
)
@@ -89,7 +89,7 @@ public void SetUp()
8989
logger,
9090
userService,
9191
clockUtility,
92-
configDataService,
92+
configService,
9393
config,
9494
apiClient
9595
)
@@ -760,7 +760,7 @@ public void AccountInactive_ReturnsViewResult()
760760
{
761761
// Arrange
762762
var supportEmail = "[email protected]";
763-
A.CallTo(() => configDataService
763+
A.CallTo(() => configService
764764
.GetConfigValue(ConfigConstants.SupportEmail))
765765
.Returns(supportEmail);
766766

@@ -791,7 +791,7 @@ public void RemoteFailure_ReturnsViewResult()
791791
{
792792
// Arrange
793793
var supportEmail = "[email protected]";
794-
A.CallTo(() => configDataService
794+
A.CallTo(() => configService
795795
.GetConfigValue(ConfigConstants.SupportEmail))
796796
.Returns(supportEmail);
797797

@@ -866,7 +866,7 @@ public void ForgotPassword_MultipleUsers_ReturnsMultipleUsersView()
866866
logger,
867867
userService,
868868
clockUtility,
869-
configDataService,
869+
configService,
870870
config,
871871
apiClient
872872
)
@@ -904,7 +904,7 @@ public void ForgotPassword_ReturnsForgotPasswordFailure()
904904
logger,
905905
userService,
906906
clockUtility,
907-
configDataService,
907+
configService,
908908
config,
909909
apiClient
910910
)
@@ -942,7 +942,7 @@ public void ForgotPassword_ReturnsForgotPasswordAcknowledgement()
942942
logger,
943943
userService,
944944
clockUtility,
945-
configDataService,
945+
configService,
946946
config,
947947
apiClient
948948
)

DigitalLearningSolutions.Web.Tests/Controllers/Register/RegisterAtNewCentreControllerTests.cs

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
using System.Collections.Generic;
44
using System.Linq;
55
using System.Threading.Tasks;
6-
using DigitalLearningSolutions.Data.DataServices;
7-
using DigitalLearningSolutions.Data.DataServices.UserDataService;
86
using DigitalLearningSolutions.Data.Enums;
97
using DigitalLearningSolutions.Data.Exceptions;
108
using DigitalLearningSolutions.Data.Models.Register;
11-
using DigitalLearningSolutions.Data.Models.User;
9+
using DigitalLearningSolutions.Data.Models.User;
1210
using DigitalLearningSolutions.Web.Controllers.Register;
1311
using DigitalLearningSolutions.Web.Extensions;
1412
using DigitalLearningSolutions.Web.Helpers;
@@ -33,7 +31,7 @@ public class RegisterAtNewCentreControllerTests
3331
{
3432
private const string IpAddress = "1.1.1.1";
3533
private const int UserId = 2;
36-
private ICentresDataService centresDataService = null!;
34+
private ICentresService centresService = null!;
3735
private IConfiguration config = null!;
3836
private RegisterAtNewCentreController controller = null!;
3937
private IEmailVerificationService emailVerificationService = null!;
@@ -42,17 +40,15 @@ public class RegisterAtNewCentreControllerTests
4240
private IRegistrationService registrationService = null!;
4341
private HttpRequest request = null!;
4442
private ISupervisorDelegateService supervisorDelegateService = null!;
45-
private IUserDataService userDataService = null!;
4643
private IUserService userService = null!;
4744
private ISupervisorService supervisorService = null!;
4845

4946
[SetUp]
5047
public void Setup()
5148
{
52-
centresDataService = A.Fake<ICentresDataService>();
49+
centresService = A.Fake<ICentresService>();
5350
registrationService = A.Fake<IRegistrationService>();
5451
userService = A.Fake<IUserService>();
55-
userDataService = A.Fake<IUserDataService>();
5652
supervisorService = A.Fake<ISupervisorService>();
5753
promptsService = A.Fake<PromptsService>();
5854
featureManager = A.Fake<IFeatureManager>();
@@ -62,15 +58,14 @@ public void Setup()
6258
request = A.Fake<HttpRequest>();
6359

6460
controller = new RegisterAtNewCentreController(
65-
centresDataService,
61+
centresService,
6662
config,
6763
emailVerificationService,
6864
featureManager,
6965
promptsService,
7066
registrationService,
7167
supervisorDelegateService,
7268
userService,
73-
userDataService,
7469
supervisorService
7570
)
7671
.WithDefaultContext()
@@ -85,13 +80,13 @@ public void IndexGet_with_invalid_centreId_param_shows_error()
8580
{
8681
// Given
8782
const int centreId = 7;
88-
A.CallTo(() => centresDataService.GetCentreName(centreId)).Returns(null);
83+
A.CallTo(() => centresService.GetCentreName(centreId)).Returns(null);
8984

9085
// When
9186
var result = controller.Index(centreId);
9287

9388
// Then
94-
A.CallTo(() => centresDataService.GetCentreName(centreId)).MustHaveHappened(1, Times.Exactly);
89+
A.CallTo(() => centresService.GetCentreName(centreId)).MustHaveHappened(1, Times.Exactly);
9590
result.Should().BeNotFoundResult();
9691
}
9792

@@ -100,13 +95,13 @@ public void IndexGet_with_valid_centreId_param_sets_data_correctly()
10095
{
10196
// Given
10297
const int centreId = 7;
103-
A.CallTo(() => centresDataService.GetCentreName(centreId)).Returns("Some centre");
98+
A.CallTo(() => centresService.GetCentreName(centreId)).Returns("Some centre");
10499

105100
// When
106101
var result = controller.Index(centreId);
107102

108103
// Then
109-
A.CallTo(() => centresDataService.GetCentreName(centreId)).MustHaveHappened(1, Times.Exactly);
104+
A.CallTo(() => centresService.GetCentreName(centreId)).MustHaveHappened(1, Times.Exactly);
110105
var data = controller.TempData.Peek<InternalDelegateRegistrationData>()!;
111106
data.Centre.Should().Be(centreId);
112107
data.IsCentreSpecificRegistration.Should().BeTrue();
@@ -120,7 +115,7 @@ public void IndexGet_with_no_centreId_param_allows_normal_registration()
120115
var result = controller.Index();
121116

122117
// Then
123-
A.CallTo(() => centresDataService.GetCentreName(A<int>._)).MustNotHaveHappened();
118+
A.CallTo(() => centresService.GetCentreName(A<int>._)).MustNotHaveHappened();
124119
var data = controller.TempData.Peek<InternalDelegateRegistrationData>()!;
125120
data.Centre.Should().BeNull();
126121
data.IsCentreSpecificRegistration.Should().BeFalse();
@@ -140,7 +135,7 @@ public void PersonalInformationPost_with_invalid_emails_fails_validation()
140135
CentreSpecificEmail = "centre email",
141136
};
142137
A.CallTo(
143-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
138+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
144139
model.CentreSpecificEmail!,
145140
centreId,
146141
userAccount.Id
@@ -187,7 +182,7 @@ public void PersonalInformationPost_with_null_centre_email_skips_email_validatio
187182

188183
// Then
189184
A.CallTo(
190-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
185+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
191186
A<string>._,
192187
A<int>._,
193188
A<int>._
@@ -207,7 +202,7 @@ public void PersonalInformationPost_with_valid_emails_is_allowed()
207202
CentreSpecificEmail = "centre email",
208203
};
209204
A.CallTo(
210-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
205+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
211206
model.CentreSpecificEmail!,
212207
model.Centre!.Value,
213208
UserId

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/EditDelegateControllerTests.cs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
namespace DigitalLearningSolutions.Web.Tests.Controllers.TrackingSystem.Delegates
22
{
33
using System.Linq;
4-
using DigitalLearningSolutions.Data.DataServices;
5-
using DigitalLearningSolutions.Data.DataServices.UserDataService;
6-
using DigitalLearningSolutions.Data.Models.User;
4+
using DigitalLearningSolutions.Data.Models.User;
75
using DigitalLearningSolutions.Web.Controllers.TrackingSystem.Delegates;
86
using DigitalLearningSolutions.Web.Helpers;
97
using DigitalLearningSolutions.Web.Services;
@@ -21,20 +19,18 @@ public class EditDelegateControllerTests
2119
{
2220
private const int DelegateId = 1;
2321
private EditDelegateController controller = null!;
24-
private IJobGroupsDataService jobGroupsDataService = null!;
22+
private IJobGroupsService jobGroupsService = null!;
2523
private PromptsService promptsService = null!;
2624
private IUserService userService = null!;
27-
private IUserDataService userDataService = null!;
2825

2926
[SetUp]
3027
public void SetUp()
3128
{
3229
promptsService = A.Fake<PromptsService>();
33-
jobGroupsDataService = A.Fake<IJobGroupsDataService>();
30+
jobGroupsService = A.Fake<IJobGroupsService>();
3431
userService = A.Fake<IUserService>();
35-
userDataService = A.Fake<IUserDataService>();
3632

37-
controller = new EditDelegateController(userService, userDataService, jobGroupsDataService, promptsService)
33+
controller = new EditDelegateController(userService, jobGroupsService, promptsService)
3834
.WithDefaultContext()
3935
.WithMockUser(true);
4036
}
@@ -120,7 +116,7 @@ public void Index_post_returns_view_with_model_error_with_duplicate_email()
120116

121117
A.CallTo(() => userService.GetDelegateById(DelegateId)).Returns(delegateEntity);
122118
A.CallTo(
123-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
119+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
124120
email,
125121
delegateEntity.DelegateAccount.CentreId,
126122
delegateEntity.UserAccount.Id
@@ -134,7 +130,7 @@ public void Index_post_returns_view_with_model_error_with_duplicate_email()
134130
using (new AssertionScope())
135131
{
136132
A.CallTo(
137-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
133+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
138134
email,
139135
delegateEntity.DelegateAccount.CentreId,
140136
delegateEntity.UserAccount.Id
@@ -168,7 +164,7 @@ public void Index_post_returns_view_with_model_error_with_invalid_prn()
168164
using (new AssertionScope())
169165
{
170166
A.CallTo(
171-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
167+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
172168
A<string>._,
173169
A<int>._,
174170
A<int>._
@@ -204,7 +200,7 @@ public void Index_post_calls_userServices_and_redirects_with_no_validation_error
204200

205201
A.CallTo(() => userService.GetDelegateById(DelegateId)).Returns(delegateEntity);
206202
A.CallTo(
207-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
203+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
208204
centreSpecificEmail,
209205
delegateEntity.DelegateAccount.CentreId,
210206
delegateEntity.UserAccount.Id
@@ -219,7 +215,7 @@ public void Index_post_calls_userServices_and_redirects_with_no_validation_error
219215
{
220216
A.CallTo(() => userService.GetDelegateById(DelegateId)).MustHaveHappenedOnceExactly();
221217
A.CallTo(
222-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
218+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
223219
centreSpecificEmail,
224220
delegateEntity.DelegateAccount.CentreId,
225221
delegateEntity.UserAccount.Id
@@ -267,7 +263,7 @@ public void Index_post_does_not_if_check_email_is_in_use_if_email_is_unchanged()
267263
{
268264
A.CallTo(() => userService.GetDelegateById(DelegateId)).MustHaveHappenedOnceExactly();
269265
A.CallTo(
270-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
266+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
271267
A<string>._,
272268
A<int>._,
273269
A<int>._
@@ -315,7 +311,7 @@ public void Index_post_saves_centre_specific_email_as_null_if_same_as_primary_em
315311
using (new AssertionScope())
316312
{
317313
A.CallTo(
318-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
314+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
319315
A<string>._,
320316
A<int>._,
321317
A<int>._
@@ -365,7 +361,7 @@ public void
365361
using (new AssertionScope())
366362
{
367363
A.CallTo(
368-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
364+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
369365
A<string>._,
370366
A<int>._,
371367
A<int>._
@@ -410,7 +406,7 @@ public void
410406
A.CallTo(() => userService.GetDelegateById(DelegateId)).Returns(delegateEntity);
411407

412408
A.CallTo(
413-
() => userDataService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
409+
() => userService.CentreSpecificEmailIsInUseAtCentreByOtherUser(
414410
newCentreSpecificEmail,
415411
delegateEntity.DelegateAccount.CentreId,
416412
delegateEntity.UserAccount.Id

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/EnrolControllerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using DigitalLearningSolutions.Web.Services;
22
using DigitalLearningSolutions.Data.Models.SessionData.Tracking.Delegate.Enrol;
3-
using DigitalLearningSolutions.Data.DataServices;
43
using DigitalLearningSolutions.Web.Controllers.TrackingSystem.Delegates;
54
using DigitalLearningSolutions.Web.Tests.ControllerHelpers;
65
using FakeItEasy;

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Delegates/PromoteToAdminControllerTests.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
namespace DigitalLearningSolutions.Web.Tests.Controllers.TrackingSystem.Delegates
22
{
3-
using DigitalLearningSolutions.Data.DataServices;
4-
using DigitalLearningSolutions.Data.DataServices.UserDataService;
53
using DigitalLearningSolutions.Data.Exceptions;
64
using DigitalLearningSolutions.Data.Models;
75
using DigitalLearningSolutions.Data.Models.Email;
@@ -22,28 +20,24 @@ public class PromoteToAdminControllerTests
2220
{
2321
private ICentreContractAdminUsageService centreContractAdminUsageService = null!;
2422
private PromoteToAdminController controller = null!;
25-
private ICourseCategoriesDataService courseCategoriesDataService = null!;
23+
private ICourseCategoriesService courseCategoriesService = null!;
2624
private IRegistrationService registrationService = null!;
27-
private IUserDataService userDataService = null!;
2825
private IUserService userService = null!;
2926
private IEmailGenerationService emailGenerationService = null!;
3027
private IEmailService emailService = null!;
3128

3229
[SetUp]
3330
public void Setup()
3431
{
35-
userDataService = A.Fake<IUserDataService>();
36-
userService = A.Fake<IUserService>();
3732
centreContractAdminUsageService = A.Fake<ICentreContractAdminUsageService>();
38-
courseCategoriesDataService = A.Fake<ICourseCategoriesDataService>();
33+
courseCategoriesService = A.Fake<ICourseCategoriesService>();
3934
registrationService = A.Fake<IRegistrationService>();
4035
userService = A.Fake<IUserService>();
4136
emailGenerationService = A.Fake<IEmailGenerationService>();
4237
emailService = A.Fake<IEmailService>();
4338

4439
controller = new PromoteToAdminController(
45-
userDataService,
46-
courseCategoriesDataService,
40+
courseCategoriesService,
4741
centreContractAdminUsageService,
4842
registrationService,
4943
new NullLogger<PromoteToAdminController>(),
@@ -78,7 +72,7 @@ public void Summary_post_registers_delegate_with_expected_values()
7872
delegateEntity.UserAccount.FirstName = "TestUserName";
7973
delegateEntity.UserAccount.PrimaryEmail = "[email protected]";
8074

81-
A.CallTo(() => userDataService.GetDelegateById(delegateId)).Returns(delegateEntity);
75+
A.CallTo(() => userService.GetDelegateById(delegateId)).Returns(delegateEntity);
8276

8377
AdminUser returnedAdminUser = new AdminUser()
8478
{

0 commit comments

Comments
 (0)