I have a question that may seem stupid and simple, but I hardly have any idea how to proceed with it.
My question is:
How can I modify the exception message and customize it such that I still have my unit testing passing?
Actually I want to customize the exception message to "Student "Johny" had related files!" and as modified the API exception message, the unit testing failing.
Johny is a variable that may change...
Any help how I can achieve the above. Thanks
In my test class I am having
[ExpectedException(ExceptionType = typeof(Exception), ExpectedMessage = "The DELETE statement conflicted with the REFERENCE constraint \"FK_Issue_Priority\"")]
Actually I am using NHibernate and in my API I am handling exception as follows:
catch (NHibernate.ADOException exception)
{
if (exception.InnerException.GetType().Equals(typeof(System.Data.SqlClient.SqlException)))
{
if (exception.InnerException.Message.Contains("FK_Issue_Priority"))
{
throw new Exception("The DELETE statement conflicted with the REFERENCE constraint \"FK_Issue_Priority\"");
}
else
{
throw new Exception("A database error occurred while trying to add the customer to project relation please the see inner exception for details", exception.InnerException);
}
}
else
{
throw exception;
}
}