move "async Task<RestResponse<T>> ExecuteAsync<T>" from Extension to IRestClient
まだ誰も着手していません。
評価
調査の方向性
リポジトリ内で ExecuteAsync 拡張メソッドと IRestClient インターフェースおよびその実装を特定します。型付きリクエストに関する既存の呼び出しとテストを確認し、そのうえでインターフェースの変更がモックと既存の拡張メソッド利用側にどのような影響を与えるかを判断します。完了条件は、型付き実行を IRestClient 経由で利用でき、関連するテストでシリアライザーのセットアップなしにモックされたレスポンスをカバーできることです。
索引モデルが issue の本文から書いたものです。
説明
The extension-method
async Task<RestResponse<T>> ExecuteAsync<T>
Is the "natural" way to do a Request: everyting is TypeSave. But If you try to Mock IRestClient, you can only mock the Non-Typed Request-Reponse method.
In a Test-Scenario, we have to add the Serializers and use compute to Serialize & Deserialize, there is no full control on the response - the deserializers try to do the work - and an easy workaround with own serializer/deserialiser is not easy.
I had a long look at the sources, but using a custom Serializer did not worked out well. So I ended up with this Blog-Post unittest-with-restsharp
Yes, this works but is not intuitive.
Describe the solution you'd like
Having Task<RestResponse<T>> ExecuteAsync<T> in IRestClient would enable us to simple Mock the call. No additional Setup, No Serialization during the Test.
As far as I see, the ExtensionMethod can be moved to the RestClient-Implementation without breaking anything. All other ExtensionMethods will work, IRestClient-Implementation / Mocks will work.
You could move the method to the IRestClient Implementaion, extend the interface and remove the ExtensionMethod- without any side effects.
Describe alternatives you've considered
Considered? Mocking the Tests is complex. I considered to remove RestSharp - but my time is limited ;-) I did a complex initialization and hope my (future) colleagues will understand this in 2 years...
If I was unclear / any questions - may need some days for me to answer, but I'm here
- 主要言語
- C#
- スター
- 9.8k
- フォーク
- 2.3k
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
restsharp/RestSharp のほかの issue
-
RestClientOptions.UserAgent missing from requests with useClientFactory: true対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
Expose HTTP response trailers on RestResponse対応中かも @Benziza が 16 日前に担当しました。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 68/100
-
RestClient configured with Newtonsoft.Json serializer still instantiates System.Text.Json対応中かも @JiuYue0820 が 57 日前に担当しました。 オープンbug
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
feature-request rfc
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
restsharp/RestSharp の issue をすべて見る
似ている issue
-
python triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/semantic-kernel#14590 ·
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
nkdAgility/azure-devops-migration-tools#3226 ·
メンテナーはふだん 1 日以内に返信
-
t/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
dotnet/maui#39362 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信