PageRenderTime 9ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/src/NUnit/framework/Attributes/TestCaseSourceAttribute.cs

#
C# | 59 lines | 27 code | 6 blank | 26 comment | 0 complexity | 7edc0765a7269adfda7bda2dd09d99dc MD5 | raw file
 1// ****************************************************************
 2// Copyright 2008, Charlie Poole
 3// This is free software licensed under the NUnit license. You may
 4// obtain a copy of the license at http://nunit.org
 5// ****************************************************************
 6
 7using System;
 8
 9namespace NUnit.Framework
10{
11    /// <summary>
12    /// FactoryAttribute indicates the source to be used to
13    /// provide test cases for a test method.
14    /// </summary>
15    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = false)]
16    public class TestCaseSourceAttribute : Attribute
17    {
18        private readonly string sourceName;
19        private readonly Type sourceType;
20
21        /// <summary>
22        /// Construct with the name of the factory - for use with languages
23        /// that don't support params arrays.
24        /// </summary>
25        /// <param name="sourceName">An array of the names of the factories that will provide data</param>
26        public TestCaseSourceAttribute(string sourceName)
27        {
28            this.sourceName = sourceName;
29        }
30
31        /// <summary>
32        /// Construct with a Type and name - for use with languages
33        /// that don't support params arrays.
34        /// </summary>
35        /// <param name="sourceType">The Type that will provide data</param>
36        /// <param name="sourceName">The name of the method, property or field that will provide data</param>
37        public TestCaseSourceAttribute(Type sourceType, string sourceName)
38        {
39            this.sourceType = sourceType;
40            this.sourceName = sourceName;
41        }
42
43        /// <summary>
44        /// The name of a the method, property or fiend to be used as a source
45        /// </summary>
46        public string SourceName
47        {
48            get { return sourceName; }   
49        }
50
51        /// <summary>
52        /// A Type to be used as a source
53        /// </summary>
54        public Type SourceType
55        {
56            get { return sourceType;  }
57        }
58    }
59}