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:
authorNéstor Salceda <nestor@mono-cvs.ximian.com>2008-02-06 22:07:33 +0300
committerNéstor Salceda <nestor@mono-cvs.ximian.com>2008-02-06 22:07:33 +0300
commit832e83908de84133fa3a591ecb36dda0d313da92 (patch)
treecd8fd3aabbec6032cbd42013dd2d3388da2c14e9 /gendarme/rules/Gendarme.Rules.Smells/Test
parentb0387482299ae9c1966f67a0ae43e89442eb2f4c (diff)
2008-02-06 Nestor Salceda <nestor.salceda@gmail.com>
* AvoidLongMethods.cs: The rule shouldn't be applied to static constructors. * AvoidLongMethodsTest.cs: Added a test for static constructors. This rule shouldn't be applied to static constructors. svn path=/trunk/mono-tools/; revision=95061
Diffstat (limited to 'gendarme/rules/Gendarme.Rules.Smells/Test')
-rw-r--r--gendarme/rules/Gendarme.Rules.Smells/Test/AvoidLongMethodsTest.cs80
-rw-r--r--gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog5
2 files changed, 85 insertions, 0 deletions
diff --git a/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidLongMethodsTest.cs b/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidLongMethodsTest.cs
index 4ba5ac0e..ff9ae6b9 100644
--- a/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidLongMethodsTest.cs
+++ b/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidLongMethodsTest.cs
@@ -52,6 +52,78 @@ namespace Gtk {
namespace Test.Rules.Smells {
+ public class LongStaticConstructor {
+ static LongStaticConstructor () {
+ Console.WriteLine ("I'm writting a test, and I will fill a screen with some useless code");
+ IList list = new ArrayList ();
+ list.Add ("Foo");
+ list.Add (4);
+ list.Add (6);
+
+ IEnumerator listEnumerator = list.GetEnumerator ();
+ while (listEnumerator.MoveNext ())
+ Console.WriteLine (listEnumerator.Current);
+
+ try {
+ list.Add ("Bar");
+ list.Add ('a');
+ }
+ catch (NotSupportedException exception) {
+ Console.WriteLine (exception.Message);
+ Console.WriteLine (exception);
+ }
+
+ foreach (object value in list) {
+ Console.Write (value);
+ Console.Write (Environment.NewLine);
+ }
+
+ int x = 0;
+
+ for (int i = 0; i < 100; i++)
+ x++;
+ Console.WriteLine (x);
+
+ string useless = "Useless String";
+
+ if (useless.Equals ("Other useless")) {
+ useless = String.Empty;
+ Console.WriteLine ("Other useless string");
+ }
+
+ useless = String.Concat (useless," 1");
+
+ for (int j = 0; j < useless.Length; j++) {
+ if (useless[j] == 'u')
+ Console.WriteLine ("I have detected an u char");
+ else
+ Console.WriteLine ("I have detected an useless char");
+ }
+
+ try {
+ foreach (string environmentVariable in Environment.GetEnvironmentVariables ().Keys)
+ Console.WriteLine (environmentVariable);
+ }
+ catch (System.Security.SecurityException exception) {
+ Console.WriteLine (exception.Message);
+ Console.WriteLine (exception);
+ }
+
+ Console.WriteLine ("I will add more useless code !!");
+
+ try {
+ if (!(File.Exists ("foo.txt"))) {
+ File.Create ("foo.txt");
+ File.Delete ("foo.txt");
+ }
+ }
+ catch (IOException exception) {
+ Console.WriteLine (exception.Message);
+ Console.WriteLine (exception);
+ }
+ }
+ }
+
public class MainWidget : Gtk.Bin {
protected virtual void Build ()
{
@@ -1003,5 +1075,13 @@ namespace Test.Rules.Smells {
Assert.IsNotNull (messageCollection);
Assert.AreEqual (1, messageCollection.Count);
}
+
+ [Test]
+ public void LongStaticConstructorTest ()
+ {
+ MethodDefinition staticConstructor = assembly.MainModule.Types["Test.Rules.Smells.LongStaticConstructor"].Constructors.GetConstructor (true,Type.EmptyTypes);
+ messageCollection = rule.CheckMethod (staticConstructor, new MinimalRunner ());
+ Assert.IsNull (messageCollection);
+ }
}
}
diff --git a/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog b/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog
index 16afb322..4ed885e8 100644
--- a/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog
+++ b/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog
@@ -1,3 +1,8 @@
+2008-02-06 Nestor Salceda <nestor.salceda@gmail.com>
+
+ * AvoidLongMethodsTest.cs: Added a test for static constructors. This
+ rule shouldn't be applied to static constructors.
+
2008-01-16 Nestor Salceda <nestor.salceda@gmail.com>
* AvoidLargeClassesTest.cs: Added tests for skip the enums. This rule