Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ExpectExceptionAttribute.cs « NUnitCore « src « nunit « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 401049da41622b8caaab682af0c4b084581868b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
namespace NUnit.Framework {
    using System;

    /// <summary>
    /// The given exception should be thrown by the annotated method.
    /// </summary>
    /// <remarks>
    /// To use this attribute, attach it to a method in a
    /// <see cref="TestCase"/> subclass.
    /// <example>Here is an example:
    /// <code>
    /// public class FooTest : TestCase {
    ///   public ExpectExceptionTest(string name) : base(name) {}
    ///   [ExpectException(typeof(ArgumentException))]
    ///   [ExpectException(typeof(IndexOutOfRangeException))]
    ///   public void TestBar() {
    ///     throw new ArgumentException("bad argument");
    ///   }
    /// }
    /// </code>
    /// </example>
    /// </remarks>
    [AttributeUsage(AttributeTargets.Method, AllowMultiple=true)]
    public class ExpectExceptionAttribute : Attribute {
        private Type expected;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="exceptionExpected"></param>
        public ExpectExceptionAttribute(Type exceptionExpected) {
            this.expected = exceptionExpected;
        }
		/// <summary>
		/// 
		/// </summary>
		/// <returns></returns>
        public override string ToString() {
            return expected.ToString();
        }
		/// <summary>
		/// 
		/// </summary>
        public Type ExceptionExpected {
            get { return expected; }
        }
    }
}