public void ToString_IFormattableNull_IsNull() { string act = TestStruct.ToString((IFormattable)null); string exp = null; Assert.AreEqual(exp, act); }
public void ToString_IFormattableNull_IsNull() { IFormattable formatter = null; string act = TestStruct.ToString(formatter); string exp = null; Assert.AreEqual(exp, act); }
/// <summary>Formats the object using the formatting arguments.</summary> /// <param name="formattable"> /// The object to format. /// </param> /// <param name="arguments"> /// The formatting arguments /// </param> /// <returns> /// A formatted string representing the object. /// </returns> public static string ToString(this IFormattable formattable, FormattingArguments arguments) { if (formattable == null) { return(null); } return(arguments.ToString(formattable)); }
/// <summary>Formats the object using the formatting arguments.</summary> /// <param name="formattable"> /// The object to format. /// </param> /// <param name="arguments"> /// The formatting arguments /// </param> /// <returns> /// A formatted string representing the object. /// </returns> public static string ToString(this IFormattable formattable, FormattingArguments arguments) { if (formattable == null) { #pragma warning disable S2225 // "ToString()" method should not return null // if the origin is null, it should not become string.Empty. return(null); #pragma warning restore S2225 } return(arguments.ToString(formattable)); }