Skip to content

Instantly share code, notes, and snippets.

@martinjw
martinjw / SqlExceptionMocker.cs
Last active October 16, 2022 21:02 — forked from timabell/SqlExceptionMocker.cs
Create a SqlException for testing
using System.Data.SqlClient;
using System.Reflection;
namespace HorribleThingsInHere
{
/// <summary>
/// Workaround completely test-unfriendly sql error classes.
/// Copy-paste from http://stackoverflow.com/a/1387030/10245
/// Adjusted with updates in comments
/// Adjusted to not use ctor indexes