Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

[Android/iOS]アプリの通信処理の Mock 化 #553

Merged
merged 9 commits into from Jun 22, 2020

Conversation

amay077
Copy link
Contributor

@amay077 amay077 commented Jun 21, 2020

Purpose

以下を行いました。

  1. HttpDataService からインターフェースを切り出して IHttpDataService を作成する
  2. 現在 HttpDataService に依存している箇所(UserDataService など)は、依存を IHttpDataService に変える
  3. IHttpDataService を実装したモッククラス HttpDataServiceMock を作成する
  4. App.xasml.cs の依存性の注入で、containerRegistry.RegisterSingleton<HttpDataService>(); の代わりに containerRegistry.RegisterSingleton<IHttpDataService, HttpDataService>(); を使用する

また Configuration に Debug_Mock を追加しました。
こちらを選択すると、HttpDataServiceMock が使われ、また ExposureNotification の TestNativeImplementation も使用されます。

Visual Studio 2019

image

Visual Studio for Mac

image

Does this introduce a breaking change?

[ ] Yes
[x] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

What to Check

Verify that the following are valid

  1. Open Covid19Radar.sln
  2. Change configuration to Debug_Mock
  3. Start Debugging

Other Information

  • HttpDataServiceMock.cs がモックとして何を返却すべきかは、一考の余地があります(とりあえず空っぽい値を返しています)

@runceel
Copy link
Member

runceel commented Jun 22, 2020

@amay077 さん

ありがとうございます。マージしようとしたのですが、master ブランチのほうで HttpDataService の PutSelfExposureKeysAsync のメソッドシグネチャーが Task<HttpStatusCode> PutSelfExposureKeysAsync(DiagnosisSubmissionParameter request); に変わった関係で、そのままだとビルドエラーになるので、そこだけ対応していただいてもいいですか??

引数と戻り値の型を変えて、モックのほうの Task.Factory.StartNew の中で HttpStatusCode.OK を return しらもらえるようにしてもらえれば大丈夫だと思います。

@runceel runceel self-assigned this Jun 22, 2020
@amay077
Copy link
Contributor Author

amay077 commented Jun 22, 2020

ビルドエラー

対応しました!

また Debug_Mock を選択したときに Android のデバッグ実行が動作しなかったので、そちらも修正しました。

@runceel runceel merged commit 2daa7da into Covid-19Radar:master Jun 22, 2020
@runceel
Copy link
Member

runceel commented Jun 22, 2020

Thanks!

kazumihirose pushed a commit that referenced this pull request Jun 22, 2020
[Android/iOS]アプリの通信処理の Mock 化
kazumihirose pushed a commit that referenced this pull request Jun 22, 2020
[Android/iOS]アプリの通信処理の Mock 化
kazumihirose pushed a commit that referenced this pull request Jun 22, 2020
[Android/iOS]アプリの通信処理の Mock 化
kazumihirose pushed a commit that referenced this pull request Jun 22, 2020
[Android/iOS]アプリの通信処理の Mock 化
kazumihirose pushed a commit that referenced this pull request Jun 22, 2020
[Android/iOS]アプリの通信処理の Mock 化
kazumihirose pushed a commit that referenced this pull request Jun 22, 2020
[Android/iOS]アプリの通信処理の Mock 化
@amay077 amay077 deleted the feature/issue-539 branch June 24, 2020 03:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants