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

Commit

Permalink
Add debug
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-dev004 committed Jul 8, 2022
1 parent 2e65f95 commit 6c6d00e
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using Covid19Radar.Services;
using Covid19Radar.Views;
using Prism.Navigation;
using Xamarin.CommunityToolkit.ObjectModel;
using Xamarin.Essentials;
using Xamarin.Forms;

Expand All @@ -34,6 +35,8 @@ public class DebugPageViewModel : ViewModelBase
private readonly ICloseApplicationService _closeApplicationService;
private readonly IServerConfigurationRepository _serverConfigurationRepository;
private readonly ILocalNotificationService _localNotificationService;
private readonly ISendEventLogStateRepository _sendEventLogStateRepository;
private readonly IEventLogRepository _eventLogRepository;

private string _debugInfo;
public string DebugInfo
Expand Down Expand Up @@ -154,7 +157,9 @@ public DebugPageViewModel(
AbsExposureDetectionBackgroundService exposureDetectionBackgroundService,
ICloseApplicationService closeApplicationService,
IServerConfigurationRepository serverConfigurationRepository,
ILocalNotificationService localNotificationService
ILocalNotificationService localNotificationService,
ISendEventLogStateRepository sendEventLogStateRepository,
IEventLogRepository eventLogRepository
) : base(navigationService)
{
Title = "Title:Debug";
Expand All @@ -167,6 +172,8 @@ ILocalNotificationService localNotificationService
_closeApplicationService = closeApplicationService;
_serverConfigurationRepository = serverConfigurationRepository;
_localNotificationService = localNotificationService;
_sendEventLogStateRepository = sendEventLogStateRepository;
_eventLogRepository = eventLogRepository;
}

public override async void Initialize(INavigationParameters parameters)
Expand Down Expand Up @@ -309,6 +316,19 @@ private string ConvertSha256(string text)
_ = await NavigationService.NavigateAsync("/" + nameof(ReAgreePrivacyPolicyPage), navigationParams);
});

public IAsyncCommand OnClickAddEventNotifiedIfNeeded => new AsyncCommand(async () =>
{
if (_sendEventLogStateRepository.GetSendEventLogState(EventType.ExposureNotified) == SendEventLogState.Enable)
{
await _eventLogRepository.AddEventNotifiedAsync();
}
});

public IAsyncCommand OnClickAddEventNotifiedForce => new AsyncCommand(async () =>
{
await _eventLogRepository.AddEventNotifiedAsync();
});

public Command OnClickQuit => new Command(() =>
{
Application.Current.Quit();
Expand Down
10 changes: 9 additions & 1 deletion Covid19Radar/Covid19Radar/Views/Settings/DebugPage.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
Expand Down Expand Up @@ -108,6 +108,14 @@
Command="{Binding Path=OnClickRemoveAllUpdateDate}"
Style="{StaticResource DefaultButton}"
Text="RemoveAllUpdateDate" />
<Button
Command="{Binding Path=OnClickAddEventNotifiedIfNeeded}"
Style="{StaticResource DefaultButton}"
Text="AddEventNotified(If needed)" />
<Button
Command="{Binding Path=OnClickAddEventNotifiedForce}"
Style="{StaticResource DefaultButton}"
Text="AddEventNotified(Force)" />
<Button
Command="{Binding Path=OnClickQuit}"
Style="{StaticResource DefaultButton}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,17 @@ public void AppVerTest()
Assert.Equal("1.2.3", unitUnderTest.AppVer);
}

[Fact]
public void InitializeTest()
{
_mockEventLogRepository.Setup(x => x.IsExist()).ReturnsAsync(true);

SettingsPageViewModel unitUnderTest = CreateViewModel();
unitUnderTest.Initialize(new NavigationParameters());

_mockLoggerService.Verify(x => x.Info("isExistEventLogs: True", It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>()), Times.Once());
}

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

0 comments on commit 6c6d00e

Please sign in to comment.