ThrowsConstraint is used to test the exception thrown by a delegate by applying a constraint to it.
Inheritance: PrefixConstraint
示例#1
0
 public void SetUp()
 {
     theConstraint = new ThrowsConstraint(
         new InstanceOfTypeConstraint(typeof(TestDelegates.BaseException)));
     expectedDescription  = "instance of <NUnit.TestUtilities.TestDelegates+BaseException>";
     stringRepresentation = "<throws <instanceof NUnit.TestUtilities.TestDelegates+BaseException>>";
 }
 public void SetUp()
 {
     theConstraint = new ThrowsConstraint(
         new InstanceOfTypeConstraint(typeof(ApplicationException)));
     expectedDescription = "instance of <System.ApplicationException>";
     stringRepresentation = "<throws <instanceof System.ApplicationException>>";
 }
示例#3
0
 public void SetUp()
 {
     theConstraint = new ThrowsConstraint(
         new ExceptionTypeConstraint(typeof(ArgumentException)));
     expectedDescription  = "<System.ArgumentException>";
     stringRepresentation = "<throws <typeof System.ArgumentException>>";
 }
 public void SetUp()
 {
     theConstraint = new ThrowsConstraint(
         new ExactTypeConstraint(typeof(ArgumentException)));
     expectedDescription = "<System.ArgumentException>";
     stringRepresentation = "<throws <typeof System.ArgumentException>>";
 }
示例#5
0
 public void SetUp()
 {
     theConstraint = new ThrowsConstraint(
         new InstanceOfTypeConstraint(typeof(ApplicationException)));
     expectedDescription  = "instance of <System.ApplicationException>";
     stringRepresentation = "<throws <instanceof System.ApplicationException>>";
 }
示例#6
0
 public void SetUp()
 {
     theConstraint = new ThrowsConstraint(
         new InstanceOfTypeConstraint(typeof(TestDelegates.BaseException)));
     expectedDescription = "instance of <NUnit.TestUtilities.TestDelegates+BaseException>";
     stringRepresentation = "<throws <instanceof NUnit.TestUtilities.TestDelegates+BaseException>>";
 }
示例#7
0
 public void SetUp()
 {
     theConstraint = new ThrowsConstraint(
         new AndConstraint(
             new ExceptionTypeConstraint(typeof(ArgumentException)),
             new PropertyConstraint("ParamName", new EqualConstraint("myParam"))));
     expectedDescription  = @"<System.ArgumentException> and property ParamName equal to ""myParam""";
     stringRepresentation = @"<throws <and <typeof System.ArgumentException> <property ParamName <equal ""myParam"">>>>";
 }
 public void SetUp()
 {
     theConstraint = new ThrowsConstraint(
         new AndConstraint(
             new ExactTypeConstraint(typeof(ArgumentException)),
             new PropertyConstraint("ParamName", new EqualConstraint("myParam"))));
     expectedDescription = @"<System.ArgumentException> and property ParamName equal to ""myParam""";
     stringRepresentation = @"<throws <and <typeof System.ArgumentException> <property ParamName <equal ""myParam"">>>>";
 }
示例#9
0
            public ThrowsConstraintResult(ThrowsConstraint constraint, Exception caughtException, ConstraintResult baseResult)
                : base(constraint, caughtException)
            {
                if (caughtException != null && baseResult.IsSuccess)
                {
                    Status = ConstraintStatus.Success;
                }
                else
                {
                    Status = ConstraintStatus.Failure;
                }

                this.baseResult = baseResult;
            }
示例#10
0
 public void SetUp()
 {
     Matcher = new ThrowsConstraint(
         new ExactTypeConstraint(typeof(ArgumentException)));
     Description = "<System.ArgumentException>";
     GoodValues = new object[]
     {
         new TestDelegate( TestDelegates.ThrowsArgumentException )
     };
     BadValues = new object[]
     {
         new TestDelegate( TestDelegates.ThrowsApplicationException ),
         new TestDelegate( TestDelegates.ThrowsNothing ),
         new TestDelegate( TestDelegates.ThrowsSystemException )
     };
 }
示例#11
0
 public void SetUp()
 {
     Matcher = new ThrowsConstraint(
         new AndConstraint(
             new ExactTypeConstraint(typeof(ArgumentException)),
             new PropertyConstraint("Message", new SubstringConstraint("myParam"))));
     Description = @"<System.ArgumentException> and property Message String containing ""myParam""";
     GoodValues = new object[]
     {
         new TestDelegate( TestDelegates.ThrowsArgumentException )
     };
     BadValues = new object[]
     {
         new TestDelegate( TestDelegates.ThrowsApplicationException ),
         new TestDelegate( TestDelegates.ThrowsNothing ),
         new TestDelegate( TestDelegates.ThrowsSystemException )
     };
 }