示例#1
0
 private static T AssertThrows <T>(ref RefStruct1 rs1, RefStruct1Action action)
     where T : Exception
 {
     if (action == null)
     {
         throw new ArgumentNullException(nameof(action));
     }
     try
     {
         action(ref rs1);
     }
     catch (Exception ex)
     {
         if (ex.GetType() == typeof(T))
         {
             return((T)ex);
         }
         throw new Xunit.Sdk.ThrowsException(typeof(T), ex);
     }
     throw new Xunit.Sdk.ThrowsException(typeof(T));
 }
示例#2
0
    public void MethodThatThrows_Always_ThrowsNotImplementedException(int x)
    {
        var refStruct1 = new RefStruct1();

        AssertThrows <NotImplementedException>(ref refStruct1, (ref RefStruct1 rs1) => rs1.MethodThatThrows(x));
    }