Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastien Pouliot <sebastien@ximian.com>2008-02-15 21:18:43 +0300
committerSebastien Pouliot <sebastien@ximian.com>2008-02-15 21:18:43 +0300
commit277bf030575d57019d129c544e9909bbe91bcd40 (patch)
tree3cb99d678079848255ac86be39567e28164a5371 /gendarme/rules
parent87c07c530de82f3a76a2004cde9a3cd87858bcf8 (diff)
2008-02-15 Sebastien Pouliot <sebastien@ximian.com>
* DoubleCheckLockingTest.cs * NonConstantStaticFieldsShouldNotBeVisibleTest.cs * WriteStaticFieldFromInstanceMethodTest.cs: Update unit tests wrt framework changes. svn path=/trunk/mono-tools/; revision=95780
Diffstat (limited to 'gendarme/rules')
-rw-r--r--gendarme/rules/Gendarme.Rules.Concurrency/Test/ChangeLog7
-rw-r--r--gendarme/rules/Gendarme.Rules.Concurrency/Test/DoubleCheckLockingTest.cs20
-rw-r--r--gendarme/rules/Gendarme.Rules.Concurrency/Test/NonConstantStaticFieldsShouldNotBeVisibleTest.cs18
-rw-r--r--gendarme/rules/Gendarme.Rules.Concurrency/Test/WriteStaticFieldFromInstanceMethodTest.cs33
4 files changed, 48 insertions, 30 deletions
diff --git a/gendarme/rules/Gendarme.Rules.Concurrency/Test/ChangeLog b/gendarme/rules/Gendarme.Rules.Concurrency/Test/ChangeLog
index 09489525..80825f91 100644
--- a/gendarme/rules/Gendarme.Rules.Concurrency/Test/ChangeLog
+++ b/gendarme/rules/Gendarme.Rules.Concurrency/Test/ChangeLog
@@ -1,3 +1,10 @@
+2008-02-15 Sebastien Pouliot <sebastien@ximian.com>
+
+ * DoubleCheckLockingTest.cs
+ * NonConstantStaticFieldsShouldNotBeVisibleTest.cs
+ * WriteStaticFieldFromInstanceMethodTest.cs:
+ Update unit tests wrt framework changes.
+
2008-01-21 Sebastien Pouliot <sebastien@ximian.com>
* NonConstantStaticFieldsShouldNotBeVisibleTest.cs: New. Unit tests
diff --git a/gendarme/rules/Gendarme.Rules.Concurrency/Test/DoubleCheckLockingTest.cs b/gendarme/rules/Gendarme.Rules.Concurrency/Test/DoubleCheckLockingTest.cs
index 8176176d..72aa8cf7 100644
--- a/gendarme/rules/Gendarme.Rules.Concurrency/Test/DoubleCheckLockingTest.cs
+++ b/gendarme/rules/Gendarme.Rules.Concurrency/Test/DoubleCheckLockingTest.cs
@@ -6,7 +6,7 @@
// Sebastien Pouliot <sebastien@ximian.com>
//
// 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 @@ namespace Test.Rules.Concurrency {
}
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 @@ namespace Test.Rules.Concurrency {
[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));
}
}
}
diff --git a/gendarme/rules/Gendarme.Rules.Concurrency/Test/NonConstantStaticFieldsShouldNotBeVisibleTest.cs b/gendarme/rules/Gendarme.Rules.Concurrency/Test/NonConstantStaticFieldsShouldNotBeVisibleTest.cs
index 3937770c..48451ae1 100644
--- a/gendarme/rules/Gendarme.Rules.Concurrency/Test/NonConstantStaticFieldsShouldNotBeVisibleTest.cs
+++ b/gendarme/rules/Gendarme.Rules.Concurrency/Test/NonConstantStaticFieldsShouldNotBeVisibleTest.cs
@@ -3,8 +3,10 @@
//
// Authors:
// Andreas Noever <andreas.noever@gmail.com>
+// Sebastien Pouliot <sebastien@ximian.com>
//
// (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 @@ namespace Test.Rules.Concurrency {
public class NonConstantStaticFieldsShouldNotBeVisibleTest {
private NonConstantStaticFieldsShouldNotBeVisibleRule rule;
+ private TestRunner runner;
private AssemblyDefinition assembly;
@@ -77,6 +80,7 @@ namespace Test.Rules.Concurrency {
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 @@ namespace Test.Rules.Concurrency {
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));
}
}
}
diff --git a/gendarme/rules/Gendarme.Rules.Concurrency/Test/WriteStaticFieldFromInstanceMethodTest.cs b/gendarme/rules/Gendarme.Rules.Concurrency/Test/WriteStaticFieldFromInstanceMethodTest.cs
index 36059d16..96ff214e 100644
--- a/gendarme/rules/Gendarme.Rules.Concurrency/Test/WriteStaticFieldFromInstanceMethodTest.cs
+++ b/gendarme/rules/Gendarme.Rules.Concurrency/Test/WriteStaticFieldFromInstanceMethodTest.cs
@@ -4,7 +4,7 @@
// Authors:
// Sebastien Pouliot <sebastien@ximian.com>
//
-// 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 @@ namespace Test.Rules.Correctness {
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 @@ namespace Test.Rules.Correctness {
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");
}
}
}