Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 7 additions & 12 deletions DigitalLearningSolutions.Data.Tests/Services/EnrolServiceTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using DigitalLearningSolutions.Data.Models.User;
using DigitalLearningSolutions.Data.Models.Courses;
using DigitalLearningSolutions.Data.Models.Email;
using DigitalLearningSolutions.Data.DataServices.UserDataService;

namespace DigitalLearningSolutions.Data.Tests.Services
{
Expand All @@ -18,8 +19,8 @@ public partial class EnrolServiceTest
private IEnrolService enrolService = null!;
private ITutorialContentDataService tutorialContentDataService = null!;
private IProgressDataService progressDataService = null!;
private IUserService userService = null!;
private ICourseService courseService = null!;
private IUserDataService userDataService = null!;
private ICourseDataService courseDataService = null!;
private IConfiguration configuration = null!;
private IEmailService emailService = null!;

Expand All @@ -38,27 +39,21 @@ public void Setup()
clockService = A.Fake<IClockService>();
tutorialContentDataService = A.Fake<ITutorialContentDataService>();
progressDataService = A.Fake<IProgressDataService>();
userService = A.Fake<IUserService>();
courseService = A.Fake<ICourseService>();
userDataService = A.Fake<IUserDataService>();
courseDataService = A.Fake<ICourseDataService>();
emailService = A.Fake<IEmailService>();
enrolService = new EnrolService(
clockService,
tutorialContentDataService,
progressDataService,
userService,
courseService,
userDataService,
courseDataService,
configuration,
emailService
);
A.CallTo(() => configuration["AppRootPath"]).Returns("baseUrl");
// DatabaseModificationsDoNothing();
}

//private void DatabaseModificationsDoNothing()
//{
// A.CallTo(() => emailService.ScheduleEmail(A<Email>._, A<string>._)).DoesNothing();
//}

[Test]
public void EnrolDelegateOnCourse_With_All_Details()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Linq;
using DigitalLearningSolutions.Data.DataServices;
using DigitalLearningSolutions.Data.DataServices.UserDataService;
using DigitalLearningSolutions.Data.Enums;
using DigitalLearningSolutions.Data.Models.CustomPrompts;
using DigitalLearningSolutions.Data.Models.DelegateGroups;
Expand Down Expand Up @@ -51,8 +52,8 @@ public partial class GroupsServiceTests
private ILogger<IGroupsService> logger = null!;
private IProgressDataService progressDataService = null!;
private ITutorialContentDataService tutorialContentDataService = null!;
private IUserService userService = null!;
private ICourseService courseService = null!;
private IUserDataService userDataService = null!;
private ICourseDataService courseDataService = null!;
[SetUp]
public void Setup()
{
Expand All @@ -65,22 +66,21 @@ public void Setup()
centreRegistrationPromptsService = A.Fake<ICentreRegistrationPromptsService>();
logger = A.Fake<ILogger<IGroupsService>>();
jobGroupsDataService = A.Fake<IJobGroupsDataService>(x => x.Strict());
userService = A.Fake<IUserService>();
courseService = A.Fake<ICourseService>();
userDataService = A.Fake<IUserDataService>();
courseDataService = A.Fake<ICourseDataService>();
enrolService = new EnrolService(
clockService,
tutorialContentDataService,
tutorialContentDataService,
progressDataService,
userService,
courseService,
userDataService,
courseDataService,
configuration,
emailService
);
groupsService = new GroupsService(
groupsDataService,
clockService,
jobGroupsDataService,
configuration,
centreRegistrationPromptsService,
enrolService,
logger
Expand Down
17 changes: 9 additions & 8 deletions DigitalLearningSolutions.Data/Services/EnrolService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using DigitalLearningSolutions.Data.DataServices;
using DigitalLearningSolutions.Data.DataServices.UserDataService;
using DigitalLearningSolutions.Data.Extensions;
using DigitalLearningSolutions.Data.Models.Courses;
using DigitalLearningSolutions.Data.Models.DelegateGroups;
Expand Down Expand Up @@ -39,35 +40,35 @@ public class EnrolService : IEnrolService
private readonly IClockService clockService;
private readonly IProgressDataService progressDataService;
private readonly ITutorialContentDataService tutorialContentDataService;
private readonly IUserService userService;
private readonly ICourseService courseService;
private readonly IUserDataService userDataService;
private readonly ICourseDataService courseDataService;
private readonly IConfiguration configuration;
private readonly IEmailService emailService;

public EnrolService(
IClockService clockService,
ITutorialContentDataService tutorialContentDataService,
IProgressDataService progressDataService,
IUserService userService,
ICourseService courseService,
IUserDataService userDataService,
ICourseDataService courseDataService,
IConfiguration configuration,
IEmailService emailService
)
{
this.clockService = clockService;
this.tutorialContentDataService = tutorialContentDataService;
this.progressDataService = progressDataService;
this.userService = userService;
this.courseService = courseService;
this.userDataService = userDataService;
this.courseDataService = courseDataService;
this.configuration = configuration;
this.emailService = emailService;
}
public void EnrolDelegateOnCourse(int delegateId, int customisationId, int customisationVersion, int enrollmentMethodId, int? enrolledByAdminId, DateTime? completeByDate, int? supervisorAdminId, string addedByProcess, string? delegateName, string? delegateEmail)
{
var course = courseService.GetCourseNameAndApplication(customisationId);
var course = courseDataService.GetCourseNameAndApplication(customisationId);
if (delegateName == null || delegateEmail == null)
{
var delegateUser = userService.GetDelegateUserById(delegateId);
var delegateUser = userDataService.GetDelegateUserById(delegateId);
if (delegateUser == null || course == null) return;
delegateEmail = delegateUser.EmailAddress;
delegateName = delegateUser.FirstName + " " + delegateUser.LastName;
Expand Down
3 changes: 0 additions & 3 deletions DigitalLearningSolutions.Data/Services/GroupsService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public class GroupsService : IGroupsService
private const string AddCourseToGroupAddedByProcess = "AddCourseToDelegateGroup_Refactor";
private readonly ICentreRegistrationPromptsService centreRegistrationPromptsService;
private readonly IClockService clockService;
private readonly IConfiguration configuration;
private readonly IGroupsDataService groupsDataService;
private readonly IJobGroupsDataService jobGroupsDataService;
private readonly ILogger<IGroupsService> logger;
Expand All @@ -108,7 +107,6 @@ public GroupsService(
IGroupsDataService groupsDataService,
IClockService clockService,
IJobGroupsDataService jobGroupsDataService,
IConfiguration configuration,
ICentreRegistrationPromptsService centreRegistrationPromptsService,
IEnrolService enrolService,
ILogger<IGroupsService> logger
Expand All @@ -117,7 +115,6 @@ ILogger<IGroupsService> logger
this.groupsDataService = groupsDataService;
this.clockService = clockService;
this.jobGroupsDataService = jobGroupsDataService;
this.configuration = configuration;
this.centreRegistrationPromptsService = centreRegistrationPromptsService;
this.enrolService = enrolService;
this.logger = logger;
Expand Down