-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace static list on start page by organization data
- Loading branch information
Showing
8 changed files
with
176 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.Extensions.Logging; | ||
using NRZMyk.Components.Helpers; | ||
using NRZMyk.Services.Data.Entities; | ||
using NRZMyk.Services.Services; | ||
|
||
namespace NRZMyk.Components.Pages | ||
{ | ||
public class IndexBase : BlazorComponent | ||
{ | ||
[Inject] | ||
private IAccountService AccountService { get; set; } = default!; | ||
|
||
[Inject] | ||
private ILogger<IndexBase> Logger { get; set; } = default!; | ||
|
||
internal ICollection<Organization> Organizations { get; set; } = default!; | ||
|
||
internal SaveState SaveState { get; set; } | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
Logger.LogInformation("Now loading... /Index"); | ||
Organizations = await AccountService.ListOrganizations().ConfigureAwait(true); | ||
await base.OnInitializedAsync().ConfigureAwait(true); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,59 +6,35 @@ | |
using FluentAssertions; | ||
using NRZMyk.Services.Services; | ||
|
||
namespace NRZMyk.Services.Tests.Data; | ||
namespace NRZMyk.Services.Tests.Services; | ||
|
||
public class OrganizationTests | ||
public class ReminderServiceTests | ||
{ | ||
[Test] | ||
public void CheckDataAndSendReminders_NoDataEntered_Last12Months_SendEmail() | ||
{ | ||
var org = new Organization | ||
{ | ||
Id = 0, | ||
Name = null, | ||
Members = null, | ||
Email = null, | ||
DispatchMonth = MonthToDispatch.None, | ||
LatestDataEntryDate = default, | ||
LatestStrainArrivalDate = default | ||
}; | ||
org.Email = "[email protected]"; | ||
org.DispatchMonth = MonthToDispatch.January; | ||
org.LatestDataEntryDate = new DateTime(2022, 1, 1); | ||
org.LatestStrainArrivalDate = new DateTime(2022, 1, 15); | ||
|
||
var emailService = Substitute.For<IEmailNotificationService>(); | ||
|
||
org.CheckDataAndSendReminders(emailService); | ||
|
||
emailService.Received(1).SendEmail("[email protected]", "No data was entered during the last 12 months."); | ||
} | ||
|
||
[Test] | ||
public void CheckDataAndSendReminders_DataEntered_NoStrainArrived_SendEmail() | ||
{ | ||
var emailNotificationServiceMock = Substitute.For<IEmailNotificationService>(); | ||
var sut = CreateSut(emailNotificationServiceMock); | ||
var org = CreateOrganization(); | ||
org.DispatchMonth = MonthToDispatch.January; | ||
org.LatestDataEntryDate = new DateTime(2023, 1, 5); | ||
org.LatestStrainArrivalDate = new DateTime(2022, 12, 20); | ||
|
||
var emailService = Substitute.For<IEmailNotificationService>(); | ||
|
||
org.CheckDataAndSendReminders(emailService); | ||
sut.CheckDataAndSendReminders(org); | ||
|
||
emailService.Received(1).SendEmail("[email protected]", "Data was entered, but no strain has arrived yet."); | ||
emailNotificationServiceMock.Received(1).SendEmail("[email protected]", "Data was entered, but no strain has arrived yet."); | ||
} | ||
|
||
[Test] | ||
public void WhenExpectedNextSendingIsThisMonth_ShowsHumanReadableInformation() | ||
{ | ||
var sut = CreateSut(); | ||
var org = CreateOrganization(); | ||
var today = DateTime.Today; | ||
org.DispatchMonth = (MonthToDispatch)today.Month; | ||
org.LatestStrainArrivalDate = today.Subtract(TimeSpan.FromDays(200)); | ||
|
||
org.ExpectedNextSending.Should().Be("diesen Monat"); | ||
sut.HumanReadableExpectedNextSending(org).Should().Be("diesen Monat"); | ||
} | ||
|
||
[TestCase(1, 6, "in 5 Monaten")] | ||
|
@@ -74,12 +50,13 @@ public void WhenExpectedNextSendingIsThisMonth_ShowsHumanReadableInformation() | |
[TestCase(10, 2, "in einem Monat")] | ||
public void WhenExpectedNextSendingIsChecked_ShowsHumanReadableInformation(int monthSinceLatestStrainArrival, int monthUntilNextArrival, string expectedNextSending) | ||
{ | ||
var sut = CreateSut(); | ||
var org = CreateOrganization(); | ||
var todayInSixMonths = DateTime.Today.AddMonths(monthUntilNextArrival); | ||
org.DispatchMonth = (MonthToDispatch)todayInSixMonths.Month; | ||
org.LatestStrainArrivalDate = DateTime.Today.AddMonths(-1*monthSinceLatestStrainArrival); | ||
org.LatestStrainArrivalDate = DateTime.Today.AddMonths(-1 * monthSinceLatestStrainArrival); | ||
|
||
org.ExpectedNextSending.Should().Be(expectedNextSending); | ||
sut.HumanReadableExpectedNextSending(org).Should().Be(expectedNextSending); | ||
} | ||
|
||
private static Organization CreateOrganization() | ||
|
@@ -93,4 +70,9 @@ private static Organization CreateOrganization() | |
DispatchMonth = MonthToDispatch.None, | ||
}; | ||
} | ||
|
||
private ReminderService CreateSut(IEmailNotificationService emailNotificationServiceMock = null) | ||
{ | ||
return new ReminderService(emailNotificationServiceMock ?? Substitute.For<IEmailNotificationService>()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
namespace NRZMyk.Services.Services; | ||
|
||
public interface IReminderService | ||
{ | ||
} |
Oops, something went wrong.