C#字符串插值传递值
我在一个类中有一个只读字符串:C#字符串插值传递值,c#,string-interpolation,C#,String Interpolation,我在一个类中有一个只读字符串: public static class XssProtectionConstants { /// <summary> /// {0} specifies the report url, including protocol /// </summary> public static readonly string Report = "1; report={0}"; } 这引发了: Expected:<1
public static class XssProtectionConstants {
/// <summary>
/// {0} specifies the report url, including protocol
/// </summary>
public static readonly string Report = "1; report={0}";
}
这引发了:
Expected:<1; report=www.reportMyErrors.com>. Actual:<1; report={0}>. www.reportMyErrors.com
应为:。实际值:。www.reportMyErrors.com
如何更新断言以使其等于
“1;report=www.reportMyErrors.com>”
?使用string.Format。更改字符串的代码是什么?您只是在附加它。请使用string.Format。更改字符串的代码是什么?你只是在附加它。
Expected:<1; report=www.reportMyErrors.com>. Actual:<1; report={0}>. www.reportMyErrors.com
Assert.AreEqual(_policyValue, string.Format(XssProtectionConstants.Report,"www.reportMyErrors.com" ) );