25
25
using System.Threading;
26
26
using NUnit.Framework;
27
using NUnit.Framework.Api;
27
28
using NUnit.TestData.ThreadingFixture;
28
29
using NUnit.TestUtilities;
30
namespace NUnit.Core.Tests
31
namespace NUnit.Framework.Attributes
32
33
//[Platform(Exclude = "Mono", Reason = "Runner hangs at end when these are run")]
33
34
public class ThreadingTests
66
67
[Platform(Exclude = "Mono", Reason = "Runner hangs at end when this is run")]
67
68
public void TestWithInfiniteLoopTimesOut()
69
TestResult result = TestBuilder.RunTestCase(
70
ITestResult result = TestBuilder.RunTestCase(
70
71
typeof(ThreadingFixture), "InfiniteLoopWith50msTimeout");
71
72
Assert.That(result.ResultState, Is.EqualTo(ResultState.Failure));
72
73
Assert.That(result.Message, Contains.Substring("50ms"));
76
public void TestWithSTAThreadRunsInSTA()
78
Assert.That(Thread.CurrentThread.ApartmentState, Is.EqualTo(ApartmentState.STA));
79
if (parentThreadApartment == ApartmentState.STA)
80
Assert.That(Thread.CurrentThread, Is.EqualTo(parentThread));
77
//public void TestWithSTAThreadRunsInSTA()
79
// Assert.That(Thread.CurrentThread.ApartmentState, Is.EqualTo(ApartmentState.STA));
80
// if (parentThreadApartment == ApartmentState.STA)
81
// Assert.That(Thread.CurrentThread, Is.EqualTo(parentThread));
84
public void TestWithMTAThreadRunsInMTA()
86
Assert.That(Thread.CurrentThread.ApartmentState, Is.EqualTo(ApartmentState.MTA));
87
if (parentThreadApartment == ApartmentState.MTA)
88
Assert.That(Thread.CurrentThread, Is.EqualTo(parentThread));
85
//public void TestWithMTAThreadRunsInMTA()
87
// Assert.That(Thread.CurrentThread.ApartmentState, Is.EqualTo(ApartmentState.MTA));
88
// if (parentThreadApartment == ApartmentState.MTA)
89
// Assert.That(Thread.CurrentThread, Is.EqualTo(parentThread));
91
92
[Test, RequiresSTA]
92
93
public void TestWithRequiresSTARunsInSTA()
134
135
[Platform(Exclude = "Mono", Reason = "Runner hangs at end when this is run")]
135
136
public void TimeoutCanBeSetOnTestFixture()
137
TestResult result = TestBuilder.RunTestFixture(typeof(ThreadingFixtureWithTimeout));
138
ITestResult result = TestBuilder.RunTestFixture(typeof(ThreadingFixtureWithTimeout));
138
139
Assert.That(result.ResultState, Is.EqualTo(ResultState.Failure));
139
140
result = TestFinder.Find("Test2WithInfiniteLoop", result, false);
140
141
Assert.That(result.ResultState, Is.EqualTo(ResultState.Failure));