Author: spouliot
Date: 2008-02-15 13:18:43 -0500 (Fri, 15 Feb 2008)
New Revision: 95780
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/ChangeLog
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/DoubleCheckLockingTest.cs
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/NonConstantStaticFieldsShouldNotBeVisibleTest.cs
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/WriteStaticFieldFromInstanceMethodTest.cs
Log:
2008-02-15 Sebastien Pouliot <[EMAIL PROTECTED]>
* DoubleCheckLockingTest.cs
* NonConstantStaticFieldsShouldNotBeVisibleTest.cs
* WriteStaticFieldFromInstanceMethodTest.cs:
Update unit tests wrt framework changes.
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/ChangeLog
===================================================================
--- trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/ChangeLog
2008-02-15 18:17:23 UTC (rev 95779)
+++ trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/ChangeLog
2008-02-15 18:18:43 UTC (rev 95780)
@@ -1,3 +1,10 @@
+2008-02-15 Sebastien Pouliot <[EMAIL PROTECTED]>
+
+ * DoubleCheckLockingTest.cs
+ * NonConstantStaticFieldsShouldNotBeVisibleTest.cs
+ * WriteStaticFieldFromInstanceMethodTest.cs:
+ Update unit tests wrt framework changes.
+
2008-01-21 Sebastien Pouliot <[EMAIL PROTECTED]>
* NonConstantStaticFieldsShouldNotBeVisibleTest.cs: New. Unit tests
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/DoubleCheckLockingTest.cs
===================================================================
---
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/DoubleCheckLockingTest.cs
2008-02-15 18:17:23 UTC (rev 95779)
+++
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/DoubleCheckLockingTest.cs
2008-02-15 18:18:43 UTC (rev 95780)
@@ -6,7 +6,7 @@
// Sebastien Pouliot <[EMAIL PROTECTED]>
//
// Copyright (C) 2005 Aaron Tomb
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2006-2008 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -86,18 +86,18 @@
}
private IMethodRule rule;
+ private TestRunner runner;
private AssemblyDefinition assembly;
private TypeDefinition type;
- private ModuleDefinition module;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
string unit = Assembly.GetExecutingAssembly ().Location;
assembly = AssemblyFactory.GetAssembly (unit);
- module = assembly.MainModule;
- type =
module.Types["Test.Rules.Concurrency.DoubleCheckLockingTest/Singleton"];
+ type = assembly.MainModule.Types
["Test.Rules.Concurrency.DoubleCheckLockingTest/Singleton"];
rule = new DoubleCheckLockingRule ();
+ runner = new TestRunner (rule);
}
private MethodDefinition GetTest (string name)
@@ -113,22 +113,22 @@
[Test]
public void SingleCheckBefore ()
{
- MethodDefinition method = GetTest
("SingleCheckBefore");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ MethodDefinition method = GetTest ("SingleCheckBefore");
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void SingleCheckAfter ()
{
- MethodDefinition method = GetTest ("SingleCheckAfter");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ MethodDefinition method = GetTest ("SingleCheckAfter");
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
}
[Test]
public void DoubleCheck ()
{
- MethodDefinition method = GetTest ("DoubleCheck");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner ()));
+ MethodDefinition method = GetTest ("DoubleCheck");
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
}
}
}
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/NonConstantStaticFieldsShouldNotBeVisibleTest.cs
===================================================================
---
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/NonConstantStaticFieldsShouldNotBeVisibleTest.cs
2008-02-15 18:17:23 UTC (rev 95779)
+++
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/NonConstantStaticFieldsShouldNotBeVisibleTest.cs
2008-02-15 18:18:43 UTC (rev 95780)
@@ -3,8 +3,10 @@
//
// Authors:
// Andreas Noever <[EMAIL PROTECTED]>
+// Sebastien Pouliot <[EMAIL PROTECTED]>
//
// (C) 2008 Andreas Noever
+// Copyright (C) 2008 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -68,6 +70,7 @@
public class NonConstantStaticFieldsShouldNotBeVisibleTest {
private NonConstantStaticFieldsShouldNotBeVisibleRule rule;
+ private TestRunner runner;
private AssemblyDefinition assembly;
@@ -77,6 +80,7 @@
string unit = Assembly.GetExecutingAssembly ().Location;
assembly = AssemblyFactory.GetAssembly (unit);
rule = new
NonConstantStaticFieldsShouldNotBeVisibleRule ();
+ runner = new TestRunner (rule);
}
public TypeDefinition GetTest (string name)
@@ -88,49 +92,49 @@
public void TestHasPublicConst ()
{
TypeDefinition type = GetTest
("Test.Rules.Concurrency.HasPublicConst");
- Assert.IsNull (rule.CheckType (type, new MinimalRunner
()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckType
(type));
}
[Test]
public void TestHasPublicNonConstantStaticField ()
{
TypeDefinition type = GetTest
("Test.Rules.Concurrency.HasPublicNonConstantStaticField");
- Assert.IsNotNull (rule.CheckType (type, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckType
(type));
}
[Test]
public void TestHasProtectedNonConstantStaticField ()
{
TypeDefinition type = GetTest
("Test.Rules.Concurrency.HasProtectedNonConstantStaticField");
- Assert.IsNotNull (rule.CheckType (type, new
MinimalRunner ()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckType
(type));
}
[Test]
public void TestHasInternalNonConstantStaticField ()
{
TypeDefinition type = GetTest
("Test.Rules.Concurrency.HasInternalNonConstantStaticField");
- Assert.IsNull (rule.CheckType (type, new MinimalRunner
()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckType
(type));
}
[Test]
public void TestHasPublicConstantStaticField ()
{
TypeDefinition type = GetTest
("Test.Rules.Concurrency.HasPublicConstantStaticField");
- Assert.IsNull (rule.CheckType (type, new MinimalRunner
()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckType
(type));
}
[Test]
public void TestHasPrivateNonConstantStaticField ()
{
TypeDefinition type = GetTest
("Test.Rules.Concurrency.HasPrivateNonConstantStaticField");
- Assert.IsNull (rule.CheckType (type, new MinimalRunner
()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckType
(type));
}
[Test]
public void TestHasPublicNonConstantField ()
{
TypeDefinition type = GetTest
("Test.Rules.Concurrency.HasPublicNonConstantField");
- Assert.IsNull (rule.CheckType (type, new MinimalRunner
()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckType
(type));
}
}
}
Modified:
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/WriteStaticFieldFromInstanceMethodTest.cs
===================================================================
---
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/WriteStaticFieldFromInstanceMethodTest.cs
2008-02-15 18:17:23 UTC (rev 95779)
+++
trunk/mono-tools/gendarme/rules/Gendarme.Rules.Concurrency/Test/WriteStaticFieldFromInstanceMethodTest.cs
2008-02-15 18:18:43 UTC (rev 95780)
@@ -4,7 +4,7 @@
// Authors:
// Sebastien Pouliot <[EMAIL PROTECTED]>
//
-// Copyright (C) 2006 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2006-2008 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
@@ -93,19 +93,19 @@
private IMethodRule rule;
private AssemblyDefinition assembly;
- private ModuleDefinition module;
private TypeDefinition type;
+ private TestRunner runner;
[TestFixtureSetUp]
public void FixtureSetUp ()
{
string unit = Assembly.GetExecutingAssembly ().Location;
assembly = AssemblyFactory.GetAssembly (unit);
- module = assembly.MainModule;
type =
assembly.MainModule.Types["Test.Rules.Correctness.WriteStaticFieldFromInstanceMethodTest/TestCase"];
rule = new WriteStaticFieldFromInstanceMethodRule ();
+ runner = new TestRunner (rule);
}
-
+
private MethodDefinition GetTest (string name)
{
foreach (MethodDefinition md in type.Methods) {
@@ -123,57 +123,64 @@
public void GetConstField ()
{
MethodDefinition method = GetTest ("GetConstField");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
+ Assert.AreEqual (0, runner.Defects.Count, "Count");
}
[Test]
public void GetStaticField ()
{
MethodDefinition method = GetTest ("GetStaticField");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
+ Assert.AreEqual (0, runner.Defects.Count, "Count");
}
[Test]
public void SetStaticField ()
{
MethodDefinition method = GetTest ("SetStaticField");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
+ Assert.AreEqual (1, runner.Defects.Count, "Count");
}
[Test]
public void Append ()
{
MethodDefinition method = GetTest ("Append");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner()));
+ Assert.AreEqual (RuleResult.Success, runner.CheckMethod
(method));
+ Assert.AreEqual (0, runner.Defects.Count, "Count");
}
[Test]
public void AppendChange ()
{
MethodDefinition method = GetTest ("AppendChange");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
+ Assert.AreEqual (1, runner.Defects.Count, "Count");
}
[Test]
public void MultipleChanges ()
{
MethodDefinition method = GetTest ("MultipleChanges");
- MessageCollection mc = rule.CheckMethod (method, new
MinimalRunner ());
- Assert.AreEqual (2, mc.Count, "Count");
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
+ Assert.AreEqual (2, runner.Defects.Count, "Count");
}
[Test]
public void StaticConstructor ()
{
MethodDefinition method = GetTest (".cctor");
- Assert.IsNull (rule.CheckMethod (method, new
MinimalRunner()));
+ Assert.AreEqual (RuleResult.DoesNotApply,
runner.CheckMethod (method));
+ Assert.AreEqual (0, runner.Defects.Count, "Count");
}
[Test]
public void Constructor ()
{
MethodDefinition method = GetTest (".ctor");
- Assert.IsNotNull (rule.CheckMethod (method, new
MinimalRunner()));
+ Assert.AreEqual (RuleResult.Failure, runner.CheckMethod
(method));
+ Assert.AreEqual (1, runner.Defects.Count, "Count");
}
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches