diff --git a/Covid19Radar.sln b/Covid19Radar.sln
index 35d00353..77c18bc6 100644
--- a/Covid19Radar.sln
+++ b/Covid19Radar.sln
@@ -23,6 +23,9 @@ Global
AppStore|Any CPU = AppStore|Any CPU
AppStore|iPhone = AppStore|iPhone
AppStore|iPhoneSimulator = AppStore|iPhoneSimulator
+ Debug_Mock|Any CPU = Debug_Mock|Any CPU
+ Debug_Mock|iPhone = Debug_Mock|iPhone
+ Debug_Mock|iPhoneSimulator = Debug_Mock|iPhoneSimulator
Debug|Any CPU = Debug|Any CPU
Debug|iPhone = Debug|iPhone
Debug|iPhoneSimulator = Debug|iPhoneSimulator
@@ -43,6 +46,12 @@ Global
{554EE1AB-B447-480C-90E5-C4F040891DE6}.AppStore|iPhone.Build.0 = Debug|Any CPU
{554EE1AB-B447-480C-90E5-C4F040891DE6}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{554EE1AB-B447-480C-90E5-C4F040891DE6}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
+ {554EE1AB-B447-480C-90E5-C4F040891DE6}.Debug_Mock|Any CPU.ActiveCfg = Debug_Mock|Any CPU
+ {554EE1AB-B447-480C-90E5-C4F040891DE6}.Debug_Mock|Any CPU.Build.0 = Debug_Mock|Any CPU
+ {554EE1AB-B447-480C-90E5-C4F040891DE6}.Debug_Mock|iPhone.ActiveCfg = Debug_Mock|Any CPU
+ {554EE1AB-B447-480C-90E5-C4F040891DE6}.Debug_Mock|iPhone.Build.0 = Debug_Mock|Any CPU
+ {554EE1AB-B447-480C-90E5-C4F040891DE6}.Debug_Mock|iPhoneSimulator.ActiveCfg = Debug_Mock|Any CPU
+ {554EE1AB-B447-480C-90E5-C4F040891DE6}.Debug_Mock|iPhoneSimulator.Build.0 = Debug_Mock|Any CPU
{554EE1AB-B447-480C-90E5-C4F040891DE6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{554EE1AB-B447-480C-90E5-C4F040891DE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{554EE1AB-B447-480C-90E5-C4F040891DE6}.Debug|iPhone.ActiveCfg = Debug|Any CPU
@@ -69,6 +78,15 @@ Global
{92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
{92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.AppStore|iPhoneSimulator.Deploy.0 = Release|Any CPU
+ {92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug_Mock|Any CPU.ActiveCfg = Debug_Mock|Any CPU
+ {92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug_Mock|Any CPU.Build.0 = Debug_Mock|Any CPU
+ {92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug_Mock|Any CPU.Deploy.0 = Debug_Mock|Any CPU
+ {92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug_Mock|iPhone.ActiveCfg = Debug_Mock|Any CPU
+ {92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug_Mock|iPhone.Build.0 = Debug_Mock|Any CPU
+ {92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug_Mock|iPhone.Deploy.0 = Debug_Mock|Any CPU
+ {92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug_Mock|iPhoneSimulator.ActiveCfg = Debug_Mock|Any CPU
+ {92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug_Mock|iPhoneSimulator.Build.0 = Debug_Mock|Any CPU
+ {92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug_Mock|iPhoneSimulator.Deploy.0 = Debug_Mock|Any CPU
{92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92B1EC8F-ECF4-403A-B6F4-5EC80F43A69A}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
@@ -103,6 +121,11 @@ Global
{3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.AppStore|iPhone.Deploy.0 = AppStore|iPhone
{3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.AppStore|iPhoneSimulator.ActiveCfg = AppStore|iPhoneSimulator
{3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.AppStore|iPhoneSimulator.Build.0 = AppStore|iPhoneSimulator
+ {3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.Debug_Mock|Any CPU.ActiveCfg = Debug_Mock|iPhone
+ {3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.Debug_Mock|iPhone.ActiveCfg = Debug_Mock|iPhone
+ {3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.Debug_Mock|iPhone.Build.0 = Debug_Mock|iPhone
+ {3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.Debug_Mock|iPhoneSimulator.ActiveCfg = Debug_Mock|iPhoneSimulator
+ {3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.Debug_Mock|iPhoneSimulator.Build.0 = Debug_Mock|iPhoneSimulator
{3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.Debug|Any CPU.ActiveCfg = Debug|iPhone
{3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.Debug|Any CPU.Build.0 = Debug|iPhone
{3104A081-8DF8-4EDB-A40A-38DE78AA63AC}.Debug|Any CPU.Deploy.0 = Debug|iPhone
@@ -127,6 +150,11 @@ Global
{4223EE63-A661-4465-BBB0-08DD80DB2256}.AppStore|iPhone.Build.0 = Release|Any CPU
{4223EE63-A661-4465-BBB0-08DD80DB2256}.AppStore|iPhoneSimulator.ActiveCfg = Release|Any CPU
{4223EE63-A661-4465-BBB0-08DD80DB2256}.AppStore|iPhoneSimulator.Build.0 = Release|Any CPU
+ {4223EE63-A661-4465-BBB0-08DD80DB2256}.Debug_Mock|Any CPU.ActiveCfg = Debug_Mock|Any CPU
+ {4223EE63-A661-4465-BBB0-08DD80DB2256}.Debug_Mock|iPhone.ActiveCfg = Debug_Mock|Any CPU
+ {4223EE63-A661-4465-BBB0-08DD80DB2256}.Debug_Mock|iPhone.Build.0 = Debug_Mock|Any CPU
+ {4223EE63-A661-4465-BBB0-08DD80DB2256}.Debug_Mock|iPhoneSimulator.ActiveCfg = Debug_Mock|Any CPU
+ {4223EE63-A661-4465-BBB0-08DD80DB2256}.Debug_Mock|iPhoneSimulator.Build.0 = Debug_Mock|Any CPU
{4223EE63-A661-4465-BBB0-08DD80DB2256}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4223EE63-A661-4465-BBB0-08DD80DB2256}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{4223EE63-A661-4465-BBB0-08DD80DB2256}.Debug|iPhone.Build.0 = Debug|Any CPU
diff --git a/Covid19Radar/Covid19Radar.Android/Covid19Radar.Android.csproj b/Covid19Radar/Covid19Radar.Android/Covid19Radar.Android.csproj
index 2f2f3587..6860209c 100644
--- a/Covid19Radar/Covid19Radar.Android/Covid19Radar.Android.csproj
+++ b/Covid19Radar/Covid19Radar.Android/Covid19Radar.Android.csproj
@@ -91,6 +91,23 @@
+
+ true
+ bin\Debug_Mock\
+ DEBUG;USE_MOCK
+ full
+ AnyCPU
+ Off
+ 8.0
+ prompt
+ MinimumRecommendedRules.ruleset
+ true
+ false
+ true
+ apk
+ true
+ CJK
+
diff --git a/Covid19Radar/Covid19Radar.iOS/Covid19Radar.iOS.csproj b/Covid19Radar/Covid19Radar.iOS/Covid19Radar.iOS.csproj
index 8bf87c06..6e0aa427 100644
--- a/Covid19Radar/Covid19Radar.iOS/Covid19Radar.iOS.csproj
+++ b/Covid19Radar/Covid19Radar.iOS/Covid19Radar.iOS.csproj
@@ -66,8 +66,6 @@
true
Covid19radar
--optimize=experimental-xforms-product-type --weak-framework=ExposureNotification
-
-
true
NSUrlSessionHandler
cjk
@@ -84,8 +82,7 @@
-all
-
-
+ DEBUG;__IOS__;__MOBILE__;__UNIFIED__;
DEBUG;__IOS__;__MOBILE__;__UNIFIED__;
none
true
@@ -125,8 +122,6 @@
cjk
latest
--optimize=experimental-xforms-product-type --weak-framework=ExposureNotification
-
-
true
true
@@ -173,6 +168,37 @@
true
+
+ true
+ bin\iPhoneSimulator\Debug_Mock\
+ DEBUG;__IOS__;__MOBILE__;__UNIFIED__;ENABLE_TEST_CLOUD;USE_MOCK;
+ full
+ AnyCPU
+ false
+ latest
+ prompt
+ MinimumRecommendedRules.ruleset
+ iPhone Developer
+ true
+ true
+ true
+ --optimize=experimental-xforms-product-type --weak-framework=ExposureNotification --weak-framework=ExposureNotification
+ true
+ x86_64
+ false
+ SdkOnly
+
+
+ true
+ bin\iPhone\Debug_Mock\
+ __IOS__;__MOBILE__;__UNIFIED__;DEBUG;USE_MOCK;
+ full
+ false
+ latest
+ prompt
+ MinimumRecommendedRules.ruleset
+ARM64
+
diff --git a/Covid19Radar/Covid19Radar/App.xaml.cs b/Covid19Radar/Covid19Radar/App.xaml.cs
index cd18f76e..a77bd6c6 100644
--- a/Covid19Radar/Covid19Radar/App.xaml.cs
+++ b/Covid19Radar/Covid19Radar/App.xaml.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Prism;
using Prism.DryIoc;
using Prism.Ioc;
@@ -49,10 +49,10 @@ protected override async void OnInitialized()
{
InitializeComponent();
-#if DEBUG
+#if USE_MOCK
// For debug mode, set the mock api provider to interact
// with some fake data
- //Xamarin.ExposureNotifications.ExposureNotification.OverrideNativeImplementation(new Services.TestNativeImplementation());
+ Xamarin.ExposureNotifications.ExposureNotification.OverrideNativeImplementation(new Services.TestNativeImplementation());
#endif
Xamarin.ExposureNotifications.ExposureNotification.Init();
@@ -142,7 +142,11 @@ protected override void RegisterTypes(IContainerRegistry containerRegistry)
// Services
containerRegistry.RegisterSingleton();
containerRegistry.RegisterSingleton();
- containerRegistry.RegisterSingleton();
+#if USE_MOCK
+ containerRegistry.RegisterSingleton();
+#else
+ containerRegistry.RegisterSingleton();
+#endif
}
protected override void OnStart()
diff --git a/Covid19Radar/Covid19Radar/Covid19Radar.csproj b/Covid19Radar/Covid19Radar/Covid19Radar.csproj
index a09a2c2f..c052cfb1 100644
--- a/Covid19Radar/Covid19Radar/Covid19Radar.csproj
+++ b/Covid19Radar/Covid19Radar/Covid19Radar.csproj
@@ -5,6 +5,8 @@
en-US
true
true
+ true
+ Debug;Release;Debug_Mock
netstandard2.1
@@ -20,6 +22,9 @@
DEBUG;TRACE
+
+ TRACE;DEBUG;USE_MOCK
+
diff --git a/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs b/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs
index 9910966a..81eeb14c 100644
--- a/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs
+++ b/Covid19Radar/Covid19Radar/Services/ExposureNotificationHandler.cs
@@ -20,14 +20,14 @@ namespace Covid19Radar.Services
[Xamarin.Forms.Internals.Preserve] // Ensure this isn't linked out
public class ExposureNotificationHandler : IExposureNotificationHandler
{
- private readonly HttpDataService httpDataService;
+ private readonly IHttpDataService httpDataService;
private readonly UserDataService userDataService;
private UserDataModel userData;
private Configuration configuration;
public ExposureNotificationHandler()
{
- this.httpDataService = Xamarin.Forms.DependencyService.Resolve();
+ this.httpDataService = Xamarin.Forms.DependencyService.Resolve();
this.userDataService = Xamarin.Forms.DependencyService.Resolve();
userData = this.userDataService.Get();
}
diff --git a/Covid19Radar/Covid19Radar/Services/ExposureNotificationService.cs b/Covid19Radar/Covid19Radar/Services/ExposureNotificationService.cs
index b60f52fb..8e893a9e 100644
--- a/Covid19Radar/Covid19Radar/Services/ExposureNotificationService.cs
+++ b/Covid19Radar/Covid19Radar/Services/ExposureNotificationService.cs
@@ -17,7 +17,7 @@ namespace Covid19Radar.Services
{
public class ExposureNotificationService
{
- private readonly HttpDataService httpDataService;
+ private readonly IHttpDataService httpDataService;
private readonly UserDataService userDataService;
private readonly INavigationService navigationService;
public string CurrentStatusMessage { get; set; } = "初期状態";
@@ -26,7 +26,7 @@ public class ExposureNotificationService
private SecondsTimer _downloadTimer;
private UserDataModel userData;
- public ExposureNotificationService(INavigationService navigationService, UserDataService userDataService, HttpDataService httpDataService)
+ public ExposureNotificationService(INavigationService navigationService, UserDataService userDataService, IHttpDataService httpDataService)
{
this.httpDataService = httpDataService;
this.navigationService = navigationService;
diff --git a/Covid19Radar/Covid19Radar/Services/HttpDataService.cs b/Covid19Radar/Covid19Radar/Services/HttpDataService.cs
index d3ad4514..4890f8ed 100644
--- a/Covid19Radar/Covid19Radar/Services/HttpDataService.cs
+++ b/Covid19Radar/Covid19Radar/Services/HttpDataService.cs
@@ -13,7 +13,7 @@
namespace Covid19Radar.Services
{
- public class HttpDataService
+ public class HttpDataService: IHttpDataService
{
private readonly HttpClient httpClient;
private readonly HttpClient downloadClient;
diff --git a/Covid19Radar/Covid19Radar/Services/HttpDataServiceMock.cs b/Covid19Radar/Covid19Radar/Services/HttpDataServiceMock.cs
new file mode 100644
index 00000000..a5fe5252
--- /dev/null
+++ b/Covid19Radar/Covid19Radar/Services/HttpDataServiceMock.cs
@@ -0,0 +1,55 @@
+using Covid19Radar.Model;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using Xamarin.Forms;
+
+namespace Covid19Radar.Services
+{
+ class HttpDataServiceMock : IHttpDataService
+ {
+ Task IHttpDataService.GetTemporaryExposureKey(string url, CancellationToken cancellationToken)
+ {
+ return Task.Factory.StartNew(() => {
+ Debug.WriteLine("HttpDataServiceMock::GetTemporaryExposureKey called");
+ return new MemoryStream();
+ });
+ }
+
+ Task> IHttpDataService.GetTemporaryExposureKeyList(string region, CancellationToken cancellationToken)
+ {
+ return Task.Factory.StartNew>(() => {
+ Debug.WriteLine("HttpDataServiceMock::GetTemporaryExposureKeyList called");
+ return new List();
+ });
+ }
+
+ async Task IHttpDataService.PostRegisterUserAsync()
+ {
+ Debug.WriteLine("HttpDataServiceMock::PostRegisterUserAsync called");
+
+ UserDataModel userData = new UserDataModel();
+ userData.Secret = "dummy secret";
+ userData.UserUuid = "dummy uuid";
+ userData.JumpConsistentSeed = 999;
+ userData.IsOptined = true;
+ Application.Current.Properties["Secret"] = userData.Secret;
+ await Application.Current.SavePropertiesAsync();
+ return userData;
+ }
+
+ Task IHttpDataService.PutSelfExposureKeysAsync(DiagnosisSubmissionParameter request)
+ {
+ return Task.Factory.StartNew(() =>
+ {
+ Debug.WriteLine("HttpDataServiceMock::PutSelfExposureKeysAsync called");
+ return HttpStatusCode.OK;
+ });
+ }
+ }
+}
diff --git a/Covid19Radar/Covid19Radar/Services/IHttpDataService.cs b/Covid19Radar/Covid19Radar/Services/IHttpDataService.cs
new file mode 100644
index 00000000..750817fb
--- /dev/null
+++ b/Covid19Radar/Covid19Radar/Services/IHttpDataService.cs
@@ -0,0 +1,22 @@
+using Covid19Radar.Model;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Net;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Covid19Radar.Services
+{
+ public interface IHttpDataService
+ {
+ Task PostRegisterUserAsync();
+
+ Task PutSelfExposureKeysAsync(DiagnosisSubmissionParameter request);
+
+ Task> GetTemporaryExposureKeyList(string region, CancellationToken cancellationToken);
+
+ Task GetTemporaryExposureKey(string url, CancellationToken cancellationToken);
+ }
+}
diff --git a/Covid19Radar/Covid19Radar/Services/UserDataService.cs b/Covid19Radar/Covid19Radar/Services/UserDataService.cs
index f2765072..cb850d5b 100644
--- a/Covid19Radar/Covid19Radar/Services/UserDataService.cs
+++ b/Covid19Radar/Covid19Radar/Services/UserDataService.cs
@@ -11,11 +11,11 @@ namespace Covid19Radar.Services
///
public class UserDataService
{
- private readonly HttpDataService httpDataService;
+ private readonly IHttpDataService httpDataService;
private UserDataModel current;
public event EventHandler UserDataChanged;
- public UserDataService(HttpDataService httpDataService)
+ public UserDataService(IHttpDataService httpDataService)
{
this.httpDataService = httpDataService;
current = Get();
diff --git a/Covid19Radar/Tests/Covid19Radar.UITest/Covid19Radar.UITest.csproj b/Covid19Radar/Tests/Covid19Radar.UITest/Covid19Radar.UITest.csproj
index 75980e5c..cf53dd33 100644
--- a/Covid19Radar/Tests/Covid19Radar.UITest/Covid19Radar.UITest.csproj
+++ b/Covid19Radar/Tests/Covid19Radar.UITest/Covid19Radar.UITest.csproj
@@ -34,6 +34,16 @@
prompt
MinimumRecommendedRules.ruleset
+
+ true
+ bin\Debug_Mock\
+ DEBUG;USE_MOCK;
+ full
+ AnyCPU
+ 7.3
+ prompt
+ MinimumRecommendedRules.ruleset
+