I'm trying to validate the exception and message returned, but i have a file name in this message that is variable. Is possible to do that using unit test in just one method?
public static string FileName
{
get
{
return "EXT_RF_ITAUVEST_201605091121212";
}
}
[TestMethod()]
[ExpectedException(typeof(Exception), String.Format("Error on file {0}", FileName))]
public void ValidarNomeArquivo_DataNomeIncorreta_Mensagem()
{
throw new Exception(String.Format("Error on file {0}", FileName));
}
The code above return the error "An attribute argument must be constant expression, typeof expression or array creation expression of an attribute parameter type.".