~adam-rpconnelly/nunit-3.0/bug-483845

« back to all changes in this revision

Viewing changes to src/framework/Api/Test.cs

  • Committer: Charlie Poole
  • Date: 2010-01-08 17:21:03 UTC
  • Revision ID: charlie@nunit.com-20100108172103-o065jps8sbft4hhq
Further simplification of API and internals: Removing TestInfo and NUnitFramework classes, eliminating all references to the framework from the test runner and using xml to communicate results back to the runner.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
        using System.Reflection;
31
31
 
32
32
        /// <summary>
33
 
        ///             Test Class.
 
33
        /// The Test abstract class represents a test within the framework.
34
34
        /// </summary>
35
35
        public abstract class Test : ITest, IComparable
36
36
    {
162
162
            set { name = value; }
163
163
        }
164
164
 
 
165
        /// <summary>
 
166
        /// Gets or sets the fully qualified name of the test
 
167
        /// </summary>
 
168
        /// <value></value>
165
169
        public string FullName
166
170
        {
167
171
            get { return fullName; }
347
351
                        return this.FullName.CompareTo( other.FullName );
348
352
                }
349
353
                #endregion
 
354
 
 
355
        /// <summary>
 
356
        /// Modify a newly constructed test by applying any of NUnit's common
 
357
        /// attributes, based on an input array of attributes. This method checks
 
358
        /// for all attributes, relying on the fact that specific attributes can only
 
359
        /// occur on those constructs on which they are allowed.
 
360
        /// </summary>
 
361
        /// <param name="attributes">An array of attributes possibly including NUnit attributes</param>
 
362
        public void ApplyCommonAttributes(Attribute[] attributes)
 
363
        {
 
364
            foreach (Attribute attribute in attributes)
 
365
            {
 
366
                Type attributeType = attribute.GetType();
 
367
                string attributeName = attributeType.FullName;
 
368
                bool isValid = this.RunState != RunState.NotRunnable;
 
369
 
 
370
                if (attribute is TestFixtureAttribute)
 
371
                {
 
372
                    if (this.Description == null)
 
373
                        this.Description = ((TestFixtureAttribute)attribute).Description;
 
374
                }
 
375
                else if (attribute is TestAttribute)
 
376
                {
 
377
                    if (this.Description == null)
 
378
                        this.Description = ((TestAttribute)attribute).Description;
 
379
                }
 
380
                else if (attribute is ISetRunState)
 
381
                {
 
382
                    if (isValid)
 
383
                    {
 
384
                        ISetRunState irs = (ISetRunState)attribute;
 
385
                        this.RunState = irs.GetRunState();
 
386
                        this.IgnoreReason = irs.GetReason();
 
387
                    }
 
388
                }
 
389
                else if (attribute is CategoryAttribute)
 
390
                {
 
391
                    this.Categories.Add(((CategoryAttribute)attribute).Name);
 
392
                }
 
393
                else if (attribute is PropertyAttribute)
 
394
                {
 
395
                    IDictionary props = ((PropertyAttribute)attribute).Properties;
 
396
                    if (props != null)
 
397
                        foreach (DictionaryEntry entry in props)
 
398
                            this.Properties.Add(entry.Key, entry.Value);
 
399
                }
 
400
            }
 
401
        }
350
402
        }
351
403
}