Moq and throwing a SqlException
问题 I have the following code to test that when a certain name is passed to my method, it throws a SQL exception (there is reason to that one, although it sounds a little odd). mockAccountDAL.Setup(m => m.CreateAccount(It.IsAny<string>(), "Display Name 2", It.IsAny<string>())).Throws<SqlException>(); However, this won't compile because SqlException's constructor is internal: 'System.Data.SqlClient.SqlException' must be a non-abstract type with a public parameterless constructor in order to use it