ThrowsConstraint is used to test the exception thrown by a delegate by applying a constraint to it.
Inheritance: PrefixConstraint
Exemple #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>>";
 }
Exemple #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>>";
 }
Exemple #5
0
 public void SetUp()
 {
     theConstraint = new ThrowsConstraint(
         new InstanceOfTypeConstraint(typeof(ApplicationException)));
     expectedDescription  = "instance of <System.ApplicationException>";
     stringRepresentation = "<throws <instanceof System.ApplicationException>>";
 }
Exemple #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>>";
 }
Exemple #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"">>>>";
 }
            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;
            }
 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 )
     };
 }
 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 )
     };
 }