diff options
author | Néstor Salceda <nestor@mono-cvs.ximian.com> | 2008-12-23 00:09:43 +0300 |
---|---|---|
committer | Néstor Salceda <nestor@mono-cvs.ximian.com> | 2008-12-23 00:09:43 +0300 |
commit | f53522831ba68759794d4fbcb980ae92208a4f25 (patch) | |
tree | a04e4684284bc2debcee63e3c5e7ce5bb90dd3fb /gendarme/rules/Gendarme.Rules.Smells/Test | |
parent | ea84e0834ae3dc463426d5ff64c1fc6e4cd11154 (diff) |
2008-12-22 Néstor Salceda <nestor.salceda@gmail.com>
* AvoidSwitchStatementsTest.cs: Added a test for table-driven
comparisons, by example with strings.
svn path=/trunk/mono-tools/; revision=122010
Diffstat (limited to 'gendarme/rules/Gendarme.Rules.Smells/Test')
-rw-r--r-- | gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs | 17 | ||||
-rw-r--r-- | gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog | 5 |
2 files changed, 22 insertions, 0 deletions
diff --git a/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs b/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs index e8660ac5..2ce507e0 100644 --- a/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs +++ b/gendarme/rules/Gendarme.Rules.Smells/Test/AvoidSwitchStatementsTest.cs @@ -94,5 +94,22 @@ namespace Test.Rules.Smells { { AssertRuleDoesNotApply (Type.GetType ("Test.Rules.Smells.AvoidSwitchStatementsTest+<MethodWithoutSwitchAndGenerator>c__Iterator0"), "MoveNext"); } + + void SwitchWithStrings (string sample) + { + switch (sample) { + case "Foo": + case "Bar": + return; + case "Baz": + throw new ArgumentException ("sample"); + } + } + + [Test] + public void FailOnSwitchWithStringsTest () + { + AssertRuleFailure<AvoidSwitchStatementsTest> ("SwitchWithStrings", 1); + } } } diff --git a/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog b/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog index 8d8c89e6..7b90e337 100644 --- a/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog +++ b/gendarme/rules/Gendarme.Rules.Smells/Test/ChangeLog @@ -1,5 +1,10 @@ 2008-12-22 Néstor Salceda <nestor.salceda@gmail.com> + * AvoidSwitchStatementsTest.cs: Added a test for table-driven + comparisons, by example with strings. + +2008-12-22 Néstor Salceda <nestor.salceda@gmail.com> + * AvoidSwitchStatementsTest.cs: New. Unit tests for AvoidSwitchStatementsRule. |