テストコードの追加(問題)

問題

以下の条件を満たすために適切なコードを1か所に1つずつ選択しなさい。

条件

アプリケーションは、 CalculateInterestLogLine というメソッドを含んでいます。

CalculateInterest() メソッドは、ローンの利子を計算します。

LogLine() メソッドは、コンソール・ウィンドウに診断メッセージを出力します。

CaluculateInterest() メソッドは、すべてのビルド構成で実行する必要がありますが、 LogLine() メソッドは、 DEBUG ビルドでのみ実行する必要があります。

ソースコード

private static decimal CalculateInterest(decimal loanAmount, int loanTerm, decimal loanRate) {
    decimal interestAmount = loanAmount * loanRate * loanTerm;
    [ 1 ]
    LogLine("Interest Amount : ", interestAmount.ToString("c"));
    [ 2 ]
    return interestAmount;
}
public static void LogLine(string message, string detail) => Console.WriteLine("Log: {0} = {1}", message, detail);

選択肢

  • A. [Conditional("DEBUG")]

  • B. [Conditional("RELEASE")]

  • C. #if DEBUG

  • D. #region DEBUG

  • E. #endregion

  • F. #endif

Last updated