Assert.That on a null non-generic IEnumerable throws ArgumentNullException, so IsNull() cannot pass
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
非ジェネリック IEnumerable 用の Assert.That オーバーロードから始め、その null の処理をジェネリックな IEnumerable<T> 用および object 用のオーバーロードと比較してください。関連する IsNull() や他のアサーションの経路を確認し、null 値と null でない値のテストを追加してください。IsNull() が null の IEnumerable に対して成功し、他のアサーションが ArgumentNullException ではなくアサーション失敗を報告すれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Assert.That(x).IsNull() throws ArgumentNullException when x is a null non-generic IEnumerable, so the assertion can never pass. With TUnit 1.79.0:
IEnumerable? renderings = null;
await Assert.That(renderings).IsNull(); // ArgumentNullException: Value cannot be null. (Parameter 'source')
The generic and object overloads accept the same null value:
IEnumerable<int>? items = null;
await Assert.That(items).IsNull(); // passes
object? value = null;
await Assert.That(value).IsNull(); // passes
The overload taking a non-generic IEnumerable also declares its parameter non-nullable, so the compiler warns (CS8604) at the call above. Casting the value to object? makes the assertion pass.
Expected: IsNull() passes for a null non-generic IEnumerable, as it does for IEnumerable<T>. Other assertions on a null value should fail with an assertion failure rather than ArgumentNullException.
Found while migrating an xUnit suite, where Assert.Null(renderings) on a non-generic IEnumerable passed.
- 主要言語
- C#
- スター
- 4k
- フォーク
- 139
- 平均マージ
- 7時間 16分
- マージ済み PR(30日)
- 355
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
thomhurst/TUnit のほかの issue
-
bug P3
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
thomhurst/TUnit#7585 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
Mock and core generator test restores report vulnerable System.Security.Cryptography.Pkcs versionsオープンdependencies P2
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
thomhurst/TUnit#7412 · コメント 8 件 ·
メンテナーはふだん 1 日以内に返信
-
enhancement P3 performance
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
thomhurst/TUnit#7380 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug github_actions P2
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
thomhurst/TUnit#7229 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
benchmarks enhancement P3 performance
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
thomhurst/TUnit#7683 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
thomhurst/TUnit の issue をすべて見る
似ている issue
-
bug frontend ui
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
agentic-workflows
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
documentation trivial
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[辞書] 同梱辞書追加オープン提案 辞書
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
yksr-melt/Meltype#1651 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
dotnet/wpf#12108 · リアクション 3 件 ·
メンテナーはふだん 1 日以内に返信