Skip to content
This repository has been archived by the owner on Apr 12, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1117 from cocoa-mhlw/feature/bug-exposure-notify
Browse files Browse the repository at this point in the history
接触通知からの起動時に接触結果が表示できないのを修正
  • Loading branch information
cocoa-dev004 authored Aug 22, 2022
2 parents 33fee3e + b752d95 commit 84ee4d2
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class ContactedNotifyPageViewModel : ViewModelBase
private readonly ILoggerService loggerService;
private readonly IExposureDataRepository _exposureDataRepository;
private readonly IExposureRiskCalculationService _exposureRiskCalculationService;
private readonly IExposureRiskCalculationConfigurationRepository _exposureRiskCalculationConfigurationRepository;

private V1ExposureRiskCalculationConfiguration _exposureRiskCalculationConfiguration;

Expand All @@ -45,12 +46,14 @@ public ContactedNotifyPageViewModel(
INavigationService navigationService,
ILoggerService loggerService,
IExposureDataRepository exposureDataRepository,
IExposureRiskCalculationService exposureRiskCalculationService
IExposureRiskCalculationService exposureRiskCalculationService,
IExposureRiskCalculationConfigurationRepository exposureRiskCalculationConfigurationRepository
) : base(navigationService)
{
this.loggerService = loggerService;
_exposureDataRepository = exposureDataRepository;
_exposureRiskCalculationService = exposureRiskCalculationService;
_exposureRiskCalculationConfigurationRepository = exposureRiskCalculationConfigurationRepository;

Title = AppResources.TitileUserStatusSettings;
}
Expand All @@ -65,6 +68,12 @@ public override async void Initialize(INavigationParameters parameters)

_exposureRiskCalculationConfiguration =
parameters.GetValue<V1ExposureRiskCalculationConfiguration>(ContactedNotifyPage.ExposureRiskCalculationConfigurationKey);
if (_exposureRiskCalculationConfiguration is null)
{
// When transitioned from a exposure notification, it is not passed as a parameter, so it is retrieved.
_exposureRiskCalculationConfiguration =
await _exposureRiskCalculationConfigurationRepository.GetExposureRiskCalculationConfigurationAsync(preferCache: true);
}

var userExposureInformationList = _exposureDataRepository.GetExposureInformationList(AppConstants.TermOfExposureRecordValidityInDays);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class ContactedNotifyPageViewModelTests : IDisposable
private readonly Mock<ILoggerService> mockLoggerService;
private readonly Mock<IExposureRiskCalculationService> mockExposureRiskCalculationService;
private readonly Mock<IExposureDataRepository> mockExposureDataRepository;
private readonly Mock<IExposureRiskCalculationConfigurationRepository> mockExposureRiskCalculationConfigurationRepository;
private readonly CultureInfo originalAppResourceCalture;
private readonly CultureInfo originalThreadCalture;
private readonly CultureInfo originalThreadUICalture;
Expand All @@ -47,6 +48,7 @@ public ContactedNotifyPageViewModelTests()
mockLoggerService = mockRepository.Create<ILoggerService>();
mockExposureRiskCalculationService = mockRepository.Create<IExposureRiskCalculationService>();
mockExposureDataRepository = mockRepository.Create<IExposureDataRepository>();
mockExposureRiskCalculationConfigurationRepository = mockRepository.Create<IExposureRiskCalculationConfigurationRepository>();
}

public void Dispose()
Expand All @@ -63,7 +65,8 @@ private ContactedNotifyPageViewModel CreateViewModel()
mockNavigationService.Object,
mockLoggerService.Object,
mockExposureDataRepository.Object,
mockExposureRiskCalculationService.Object
mockExposureRiskCalculationService.Object,
mockExposureRiskCalculationConfigurationRepository.Object
);
}

Expand Down Expand Up @@ -195,6 +198,51 @@ public void OnClickExposuresTest_Initialize_NoExposureInformation_NoHighRisk()
Assert.Equal("2 件", contactedNotifyViewModel.ExposureCount);
}

[Fact]
public void OnClickExposuresTest_Initialize_NavigationParameter_NotSet()
{
mockExposureDataRepository
.Setup(x => x.GetExposureInformationList(AppConstants.TermOfExposureRecordValidityInDays))
.Returns(new List<UserExposureInfo>()
{
new UserExposureInfo(),
new UserExposureInfo()
});
mockExposureDataRepository
.Setup(x => x.GetDailySummariesAsync(AppConstants.TermOfExposureRecordValidityInDays))
.Returns(Task.FromResult(new List<DailySummary>()
{
new DailySummary()
{
DateMillisSinceEpoch = 1000L * 60 * 60 * 24 * 365
}
}));
mockExposureDataRepository
.Setup(x => x.GetExposureWindowsAsync(AppConstants.TermOfExposureRecordValidityInDays))
.Returns(Task.FromResult(new List<ExposureWindow>()
{
new ExposureWindow()
{
DateMillisSinceEpoch = 1000L * 60 * 60 * 24 * 365,
ScanInstances = new List<ScanInstance>() {
new ScanInstance()
{
SecondsSinceLastScan = 60
}
}
}
}));

mockExposureRiskCalculationConfigurationRepository
.Setup(x => x.GetExposureRiskCalculationConfigurationAsync(true))
.ReturnsAsync(new V1ExposureRiskCalculationConfiguration());

var contactedNotifyViewModel = CreateViewModel();
contactedNotifyViewModel.Initialize(new NavigationParameters());

mockExposureRiskCalculationConfigurationRepository.Verify(x => x.GetExposureRiskCalculationConfigurationAsync(true), Times.Once());
}

[Fact]
public async Task OnExposureListTest()
{
Expand Down

0 comments on commit 84ee4d2

Please sign in to comment.