From 5160f91146a65540325025cc8998c9dfbd02fe5b Mon Sep 17 00:00:00 2001 From: Oleg Deribas Date: Wed, 7 Sep 2011 14:40:47 +0200 Subject: [PATCH] Add failing test for CheckNewThreadWithoutStartRule for case when thread reference is stored in local array. --- .../Test/CheckNewThreadWithoutStartTest.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gendarme/rules/Gendarme.Rules.BadPractice/Test/CheckNewThreadWithoutStartTest.cs b/gendarme/rules/Gendarme.Rules.BadPractice/Test/CheckNewThreadWithoutStartTest.cs index 5f5431be6..05bcdd861 100644 --- a/gendarme/rules/Gendarme.Rules.BadPractice/Test/CheckNewThreadWithoutStartTest.cs +++ b/gendarme/rules/Gendarme.Rules.BadPractice/Test/CheckNewThreadWithoutStartTest.cs @@ -125,6 +125,21 @@ public void TestLocalVariable () Assert.AreEqual (0, runner.Defects.Count, "Count"); } + public void LocalArray() + { + var threads = new Thread[1]; + threads[0] = new Thread(ThreadStart); + threads[0].Start(); + } + + [Test] + public void TestLocalArray() + { + MethodDefinition method = GetTest("LocalArray"); + Assert.AreEqual(RuleResult.Success, runner.CheckMethod(method), "RuleResult"); + Assert.AreEqual(0, runner.Defects.Count, "Count"); + } + public object Return () { Thread a = new Thread (ThreadStart);