public void Setup() { var connection = ServiceTestHelper.GetDatabaseConnection(); systemNotificationsDataService = new SystemNotificationsDataService(connection); systemNotificationTestHelper = new SystemNotificationTestHelper(connection); }
public void Index_sets_cookie_when_unacknowledged_notifications_exist() { // Given var testDate = new DateTime(2021, 8, 23); A.CallTo(() => clockService.UtcNow).Returns(testDate); var expectedExpiry = testDate.AddHours(24); A.CallTo(() => systemNotificationsDataService.GetUnacknowledgedSystemNotifications(A <int> ._)) .Returns(new List <SystemNotification> { SystemNotificationTestHelper.GetDefaultSystemNotification() }); // When var result = controller.Index(); // Then using (new AssertionScope()) { result.Should().BeViewResult().WithDefaultViewName(); A.CallTo( () => httpResponse.Cookies.Append( SystemNotificationCookieHelper.CookieName, "7", A <CookieOptions> .That.Matches(co => co.Expires == expectedExpiry) ) ).MustHaveHappened(); } }
public void Index_goes_to_Index_page_when_unacknowledged_notifications_have_been_skipped() { // Given A.CallTo(() => systemNotificationsDataService.GetUnacknowledgedSystemNotifications(A <int> ._)) .Returns(new List <SystemNotification> { SystemNotificationTestHelper.GetDefaultSystemNotification() }); A.CallTo(() => httpRequest.Cookies).Returns( ControllerContextHelper.SetUpFakeRequestCookieCollection(SystemNotificationCookieHelper.CookieName, "7") ); A.CallTo(() => dashboardInformationService.GetDashboardInformationForCentre(A <int> ._, A <int> ._)).Returns( new CentreDashboardInformation( CentreTestHelper.GetDefaultCentre(), UserTestHelper.GetDefaultAdminUser(), 1, 1, 1, 1, 1 ) ); // When var result = dashboardController.Index(); // Then result.Should().BeViewResult().WithDefaultViewName(); }
public void Index_redirects_to_Notifications_page_when_unacknowledged_notifications_have_not_been_skipped() { // Given A.CallTo(() => systemNotificationsDataService.GetUnacknowledgedSystemNotifications(A <int> ._)) .Returns(new List <SystemNotification> { SystemNotificationTestHelper.GetDefaultSystemNotification() }); // When var result = dashboardController.Index(); // Then result.Should().BeRedirectToActionResult().WithControllerName("SystemNotifications") .WithActionName("Index"); }