diff options
author | Chris Chambers <C.Chambers@Fugro.com.au> | 2012-02-14 12:04:51 +0400 |
---|---|---|
committer | Chris Chambers <C.Chambers@Fugro.com.au> | 2012-02-14 12:07:23 +0400 |
commit | bf759037e37123373ff57ceb898d70fc15be3a35 (patch) | |
tree | 50adb1bb03f119f0b97d9b5f2c95417a400f6d61 /gendarme | |
parent | 595d7a92127f4770a62baecb83ebc5aec57c6790 (diff) |
Add unit tests for IAECRule
Diffstat (limited to 'gendarme')
-rw-r--r-- | gendarme/rules/Gendarme.Rules.Exceptions/Test/InstantiateArgumentExceptionCorrectlyTest.cs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/gendarme/rules/Gendarme.Rules.Exceptions/Test/InstantiateArgumentExceptionCorrectlyTest.cs b/gendarme/rules/Gendarme.Rules.Exceptions/Test/InstantiateArgumentExceptionCorrectlyTest.cs index 8727b8b9..d53501de 100644 --- a/gendarme/rules/Gendarme.Rules.Exceptions/Test/InstantiateArgumentExceptionCorrectlyTest.cs +++ b/gendarme/rules/Gendarme.Rules.Exceptions/Test/InstantiateArgumentExceptionCorrectlyTest.cs @@ -777,5 +777,49 @@ namespace Test.Rules.Exceptions { AssertRuleSuccess<InstantiateArgumentExceptionCorrectlyTest> ("get_Item"); AssertRuleSuccess<InstantiateArgumentExceptionCorrectlyTest> ("set_Item"); } + + public void ArgumentNullExceptionWithBranchInMessageSelectionAndIncorrectParameterName(int parameter) + { + throw new ArgumentNullException("asdf", parameter > 0 ? "little parameter " : "big parameter"); + } + + public void ArgumentOutOfRangeExceptionWithBranchInMessageSelectionAndIncorrectParameterName(int parameter) + { + throw new ArgumentOutOfRangeException("asdf", parameter > 0 ? "little parameter " : "big parameter"); + } + + public void DuplicateWaitObjectExceptionWithBranchInMessageSelectionAndIncorrectParameterName(int parameter) + { + throw new DuplicateWaitObjectException("asdf", parameter > 0 ? "little parameter " : "big parameter"); + } + + public void ArgumentNullExceptionWithBranchInMessageSelectionAndCorrectParameterName(int parameter) + { + throw new ArgumentNullException("parameter", parameter > 0 ? "little parameter " : "big parameter"); + } + + public void ArgumentOutOfRangeExceptionWithBranchInMessageSelectionAndCorrectParameterName(int parameter) + { + throw new ArgumentOutOfRangeException("parameter", parameter > 0 ? "little parameter " : "big parameter"); + } + + public void DuplicateWaitObjectExceptionWithBranchInMessageSelectionAndCorrectParameterName(int parameter) + { + throw new DuplicateWaitObjectException("parameter", parameter > 0 ? "little parameter " : "big parameter"); + } + + [Test] + public void ArgumentExceptionsWithBranchInMessageSelectionDoesNotThrow() + { + AssertRuleSuccess<InstantiateArgumentExceptionCorrectlyTest>("ArgumentNullExceptionWithBranchInMessageSelectionAndCorrectParameterName"); + AssertRuleSuccess<InstantiateArgumentExceptionCorrectlyTest>("ArgumentOutOfRangeExceptionWithBranchInMessageSelectionAndCorrectParameterName"); + AssertRuleSuccess<InstantiateArgumentExceptionCorrectlyTest>("DuplicateWaitObjectExceptionWithBranchInMessageSelectionAndCorrectParameterName"); + + //Ideally the rules below would be AssertRuleFailure - but better to incorrectly pass than to throw an unhandled exception + // If the handling code is changed a better resolution here may be possible + AssertRuleSuccess<InstantiateArgumentExceptionCorrectlyTest>("ArgumentNullExceptionWithBranchInMessageSelectionAndIncorrectParameterName"); + AssertRuleSuccess<InstantiateArgumentExceptionCorrectlyTest>("ArgumentOutOfRangeExceptionWithBranchInMessageSelectionAndIncorrectParameterName"); + AssertRuleSuccess<InstantiateArgumentExceptionCorrectlyTest>("DuplicateWaitObjectExceptionWithBranchInMessageSelectionAndIncorrectParameterName"); + } } } |