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

接触通知からの起動時に接触結果が表示できないのを修正 #1117

Merged
1 commit merged into from
Aug 22, 2022
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
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