Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

No FAA0001 when `?.` is followed by `Should().BeApproximately`

オープン
#405 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
68/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
静か
技術スタック
csharp
領域
testing-qa

調査の方向性

まず、actual?.Amount.Should().BeApproximately(3.14, 0.01) を使用した C# の例で問題を再現し、次に BeApproximately に対する FAA0001 の処理を BeGreaterThan、BePositive、BeInRange と比較します。BeApproximately のケースでアナライザーが FAA0001 を報告し、他の assertions では既存の動作が維持されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Suppose for the sake of this bug report that we have the following type:

public interface IExample {
    double Amount { get; }
}

Then if we write the following incorrect test:

public void TestMethod() {
    IExample? actual = null;

    actual?.Amount.Should().BeApproximately(3.14, 0.01);   // no FAA0001 here?!
}

then we get no message from FluentAssertions.Analyzers about the wrong code.

For other assertions, this works fine. For example:

    actual?.Amount.Should().BeGreaterThan(3.1);  // good, we get 'FAA0001: Use .Should() instead of ?.Should()'

or:

    actual?.Amount.Should().BePositive();  // good, we get 'FAA0001: Use .Should() instead of ?.Should()'

or:

    actual?.Amount.Should().BeInRange(3.1, 3.2);  // good, we get 'FAA0001: Use .Should() instead of ?.Should()'

We need the FAA0001 with .BeApproximately(3.14, 0.01) as well. Without it, the author may think his tests proves actual is an instance where Amount equals 3.14 within a tolerance of 0.01 when in fact actual is a null reference (and no Amount exists).

主要言語
C#
スター
131
フォーク
25
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

fluentassertions/fluentassertions.analyzers のほかの issue

fluentassertions/fluentassertions.analyzers の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。