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