Skip to content

Commit e1c4167

Browse files
authored
Merge pull request #2703 from TechnologyEnhancedLearning/Develop/Fixes/TD-3923-DashboardController--refactor
TD 3923 DashboardController Refactor
2 parents 0e0c241 + 1d51d82 commit e1c4167

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

DigitalLearningSolutions.Web.Tests/Controllers/TrackingSystem/Centre/Dashboard/DashboardControllerTests.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace DigitalLearningSolutions.Web.Tests.Controllers.TrackingSystem.Centre.Dashboard
22
{
33
using System.Collections.Generic;
4-
using DigitalLearningSolutions.Data.DataServices;
54
using DigitalLearningSolutions.Data.Models;
65
using DigitalLearningSolutions.Web.Controllers.TrackingSystem.Centre.Dashboard;
76
using DigitalLearningSolutions.Web.Helpers;
@@ -21,16 +20,16 @@ public class DashboardControllerTests
2120

2221
private DashboardController dashboardController = null!;
2322
private IDashboardInformationService dashboardInformationService = null!;
24-
private ISystemNotificationsDataService systemNotificationsDataService = null!;
23+
private ISystemNotificationsService systemNotificationsService = null!;
2524

2625
[SetUp]
2726
public void Setup()
2827
{
2928
dashboardInformationService = A.Fake<IDashboardInformationService>();
30-
systemNotificationsDataService = A.Fake<ISystemNotificationsDataService>();
29+
systemNotificationsService = A.Fake<ISystemNotificationsService>();
3130
dashboardController = new DashboardController(
3231
dashboardInformationService,
33-
systemNotificationsDataService
32+
systemNotificationsService
3433
).WithMockHttpContext(httpRequest, response: httpResponse)
3534
.WithMockUser(true)
3635
.WithMockServices()
@@ -41,7 +40,7 @@ public void Setup()
4140
public void Index_redirects_to_Notifications_page_when_unacknowledged_notifications_have_not_been_skipped()
4241
{
4342
// Given
44-
A.CallTo(() => systemNotificationsDataService.GetUnacknowledgedSystemNotifications(A<int>._))
43+
A.CallTo(() => systemNotificationsService.GetUnacknowledgedSystemNotifications(A<int>._))
4544
.Returns(new List<SystemNotification> { SystemNotificationTestHelper.GetDefaultSystemNotification() });
4645

4746
// When
@@ -61,7 +60,7 @@ public void Index_redirects_to_Notifications_page_when_unacknowledged_notificati
6160
public void Index_goes_to_Index_page_when_unacknowledged_notifications_have_been_skipped()
6261
{
6362
// Given
64-
A.CallTo(() => systemNotificationsDataService.GetUnacknowledgedSystemNotifications(A<int>._))
63+
A.CallTo(() => systemNotificationsService.GetUnacknowledgedSystemNotifications(A<int>._))
6564
.Returns(new List<SystemNotification> { SystemNotificationTestHelper.GetDefaultSystemNotification() });
6665
A.CallTo(() => httpRequest.Cookies).Returns(
6766
ControllerContextHelper.SetUpFakeRequestCookieCollection(SystemNotificationCookieHelper.CookieName, "7")
@@ -89,7 +88,7 @@ public void Index_goes_to_Index_page_when_unacknowledged_notifications_have_been
8988
public void Index_returns_not_found_when_dashboard_information_is_null()
9089
{
9190
// Given
92-
A.CallTo(() => systemNotificationsDataService.GetUnacknowledgedSystemNotifications(A<int>._))
91+
A.CallTo(() => systemNotificationsService.GetUnacknowledgedSystemNotifications(A<int>._))
9392
.Returns(new List<SystemNotification>());
9493
A.CallTo(() => dashboardInformationService.GetDashboardInformationForCentre(A<int>._, A<int>._)).Returns(
9594
null
@@ -106,7 +105,7 @@ public void Index_returns_not_found_when_dashboard_information_is_null()
106105
public void Index_goes_to_Index_page_when_no_unacknowledged_notifications_exist()
107106
{
108107
// Given
109-
A.CallTo(() => systemNotificationsDataService.GetUnacknowledgedSystemNotifications(A<int>._))
108+
A.CallTo(() => systemNotificationsService.GetUnacknowledgedSystemNotifications(A<int>._))
110109
.Returns(new List<SystemNotification>());
111110
A.CallTo(() => dashboardInformationService.GetDashboardInformationForCentre(A<int>._, A<int>._)).Returns(
112111
new CentreDashboardInformation(

DigitalLearningSolutions.Web/Controllers/TrackingSystem/Centre/Dashboard/DashboardController.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace DigitalLearningSolutions.Web.Controllers.TrackingSystem.Centre.Dashboard
22
{
33
using System.Linq;
4-
using DigitalLearningSolutions.Data.DataServices;
54
using DigitalLearningSolutions.Data.Enums;
65
using DigitalLearningSolutions.Web.Attributes;
76
using DigitalLearningSolutions.Web.Helpers;
@@ -20,22 +19,22 @@
2019
public class DashboardController : Controller
2120
{
2221
private readonly IDashboardInformationService dashboardInformationService;
23-
private readonly ISystemNotificationsDataService systemNotificationsDataService;
22+
private readonly ISystemNotificationsService systemNotificationsService;
2423

2524
public DashboardController(
2625
IDashboardInformationService dashboardInformationService,
27-
ISystemNotificationsDataService systemNotificationsDataService
26+
ISystemNotificationsService systemNotificationsService
2827
)
2928
{
3029
this.dashboardInformationService = dashboardInformationService;
31-
this.systemNotificationsDataService = systemNotificationsDataService;
30+
this.systemNotificationsService = systemNotificationsService;
3231
}
3332

3433
public IActionResult Index()
3534
{
3635
var adminId = User.GetAdminId()!.Value;
3736
var unacknowledgedNotifications =
38-
systemNotificationsDataService.GetUnacknowledgedSystemNotifications(adminId).ToList();
37+
systemNotificationsService.GetUnacknowledgedSystemNotifications(adminId).ToList();
3938

4039
if (!Request.Cookies.HasSkippedNotificationsCookie(adminId) && unacknowledgedNotifications.Any())
4140
{

0 commit comments

Comments
 (0)