Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
2008-08-06 Peter Johanson <peter@peterjohanson.com>
Browse files Browse the repository at this point in the history
	* AvoidPublicInstanceFieldsTest.cs: Test nested types
	with various visibilities. The rule does not apply
	to private or internal nested types.


svn path=/branches/mono-2-0/mono-tools/; revision=109808
  • Loading branch information
Sebastien Pouliot committed Aug 7, 2008
1 parent 6f9b3e2 commit bb6deb4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Expand Up @@ -67,6 +67,24 @@ public class ReadOnlySpecialCase {
public readonly int x = 1;
}

public class NestedParent {
public class NestedPublic {
public string name;
}

protected class NestedProtected {
public string name;
}

private class NestedPrivate {
public string name;
}

internal class NestedInternal {
public string name;
}
}

public enum Enum {
Zero,
One
Expand Down Expand Up @@ -140,6 +158,26 @@ public void TestFlags ()
Assert.AreEqual (0, runner.Defects.Count, "Count");
}

[Test]
public void TestNonPublicNested ()
{
TypeDefinition type = GetTest ("NestedParent/NestedPublic");
Assert.AreEqual (RuleResult.Failure, runner.CheckType (type), "RuleResult1");
Assert.AreEqual (1, runner.Defects.Count, "Count");

type = GetTest ("NestedParent/NestedProtected");
Assert.AreEqual (RuleResult.Failure, runner.CheckType (type), "RuleResult2");
Assert.AreEqual (1, runner.Defects.Count, "Count");

type = GetTest ("NestedParent/NestedPrivate");
Assert.AreEqual (RuleResult.DoesNotApply, runner.CheckType (type), "RuleResult3");
Assert.AreEqual (0, runner.Defects.Count, "Count");

type = GetTest ("NestedParent/NestedInternal");
Assert.AreEqual (RuleResult.DoesNotApply, runner.CheckType (type), "RuleResult4");
Assert.AreEqual (0, runner.Defects.Count, "Count");
}

[Test]
public void TestStaticSpecialCase ()
{
Expand Down
6 changes: 6 additions & 0 deletions gendarme/rules/Gendarme.Rules.Design/Test/ChangeLog
@@ -1,3 +1,9 @@
2008-08-06 Peter Johanson <peter@peterjohanson.com>

* AvoidPublicInstanceFieldsTest.cs: Test nested types
with various visibilities. The rule does not apply
to private or internal nested types.

2008-08-02 Sebastien Pouliot <sebastien@ximian.com>

* ConsiderConvertingFieldToNullableTest.cs: Add test case for
Expand Down

0 comments on commit bb6deb4

Please sign in to comment.