Ejemplo n.º 1
0
    public void Ctor_ThrowsOnNull()
    {
        assert.Throws <System.ArgumentNullException>(() =>
        {
            _ = new DataConnection(null, null);
        });

        assert.Throws <System.ArgumentNullException>(() =>
        {
            _ = new DataConnection(new FakeDbConnection(), null);
        });
    }
Ejemplo n.º 2
0
 /// <summary>
 /// Verifies that the exact exception is thrown (and not a derived exception type).
 /// Generally used to test property accessors.
 /// </summary>
 /// <typeparam name="T">The type of the exception expected to be thrown</typeparam>
 /// <param name="testCode">A delegate to the code to be tested</param>
 /// <returns>The exception that was thrown, when successful</returns>
 /// <exception cref="ThrowsException">Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown</exception>
 public static T Throws <T>(this IAssert assert, Func <object> testCode)
     where T : Exception
 {
     return((T)assert.Throws(typeof(T), testCode));
 }