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
// ****************************************************************
8
using System.Threading;
10
namespace NUnit.Framework
13
/// Used on a method, marks the test with a timeout value in milliseconds.
14
/// The test will be run in a separate thread and is cancelled if the timeout
15
/// is exceeded. Used on a method or assembly, sets the default timeout
16
/// for all contained test methods.
18
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited=false)]
19
public class TimeoutAttribute : PropertyAttribute
22
/// Construct a TimeoutAttribute given a time in milliseconds
24
/// <param name="timeout">The timeout value in milliseconds</param>
25
public TimeoutAttribute(int timeout)
30
/// Marks a test that must run in the STA, causing it
31
/// to run in a separate thread if necessary.
33
/// On methods, you may also use STAThreadAttribute
34
/// to serve the same purpose.
36
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited=false)]
37
public class RequiresSTAAttribute : PropertyAttribute
40
/// Construct a RequiresSTAAttribute
42
public RequiresSTAAttribute()
44
this.Properties.Add("APARTMENT_STATE", ApartmentState.STA);
49
/// Marks a test that must run in the MTA, causing it
50
/// to run in a separate thread if necessary.
52
/// On methods, you may also use MTAThreadAttribute
53
/// to serve the same purpose.
55
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited=false)]
56
public class RequiresMTAAttribute : PropertyAttribute
59
/// Construct a RequiresMTAAttribute
61
public RequiresMTAAttribute()
63
this.Properties.Add("APARTMENT_STATE", ApartmentState.MTA);
68
/// Marks a test that must run on a separate thread.
70
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited=false)]
71
public class RequiresThreadAttribute : PropertyAttribute
74
/// Construct a RequiresThreadAttribute
76
public RequiresThreadAttribute()
80
/// Construct a RequiresThreadAttribute, specifying the apartment
82
public RequiresThreadAttribute(ApartmentState apartment)
85
this.Properties.Add("APARTMENT_STATE", apartment);
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
// ****************************************************************
8
using System.Threading;
10
namespace NUnit.Framework
13
/// Used on a method, marks the test with a timeout value in milliseconds.
14
/// The test will be run in a separate thread and is cancelled if the timeout
15
/// is exceeded. Used on a method or assembly, sets the default timeout
16
/// for all contained test methods.
18
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited=false)]
19
public class TimeoutAttribute : PropertyAttribute
22
/// Construct a TimeoutAttribute given a time in milliseconds
24
/// <param name="timeout">The timeout value in milliseconds</param>
25
public TimeoutAttribute(int timeout)
30
/// Marks a test that must run in the STA, causing it
31
/// to run in a separate thread if necessary.
33
/// On methods, you may also use STAThreadAttribute
34
/// to serve the same purpose.
36
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited=false)]
37
public class RequiresSTAAttribute : PropertyAttribute
40
/// Construct a RequiresSTAAttribute
42
public RequiresSTAAttribute()
44
this.Properties.Add("APARTMENT_STATE", ApartmentState.STA);
49
/// Marks a test that must run in the MTA, causing it
50
/// to run in a separate thread if necessary.
52
/// On methods, you may also use MTAThreadAttribute
53
/// to serve the same purpose.
55
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited=false)]
56
public class RequiresMTAAttribute : PropertyAttribute
59
/// Construct a RequiresMTAAttribute
61
public RequiresMTAAttribute()
63
this.Properties.Add("APARTMENT_STATE", ApartmentState.MTA);
68
/// Marks a test that must run on a separate thread.
70
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class | AttributeTargets.Assembly, AllowMultiple = false, Inherited=false)]
71
public class RequiresThreadAttribute : PropertyAttribute
74
/// Construct a RequiresThreadAttribute
76
public RequiresThreadAttribute()
80
/// Construct a RequiresThreadAttribute, specifying the apartment
82
public RequiresThreadAttribute(ApartmentState apartment)
85
this.Properties.Add("APARTMENT_STATE", apartment);