1 // *********************************************************************** 2 // Copyright (c) 2008 Charlie Poole 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining 5 // a copy of this software and associated documentation files (the 6 // "Software"), to deal in the Software without restriction, including 7 // without limitation the rights to use, copy, modify, merge, publish, 8 // distribute, sublicense, and/or sell copies of the Software, and to 9 // permit persons to whom the Software is furnished to do so, subject to 10 // the following conditions: 11 // 12 // The above copyright notice and this permission notice shall be 13 // included in all copies or substantial portions of the Software. 14 // 15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 // *********************************************************************** 23 24 using System; 25 using NUnit.Framework; 26 27 namespace NUnit.TestData.TestCaseAttributeFixture 28 { 29 [TestFixture] 30 public class TestCaseAttributeFixture 31 { 32 [TestCase("12-Octobar-1942")] MethodHasInvalidDateFormat(DateTime dt)33 public void MethodHasInvalidDateFormat(DateTime dt) 34 {} 35 36 [TestCase(2,3,4,Description="My Description")] MethodHasDescriptionSpecified(int x, int y, int z)37 public void MethodHasDescriptionSpecified(int x, int y, int z) 38 {} 39 40 [TestCase(2,3,4,TestName="XYZ")] MethodHasTestNameSpecified(int x, int y, int z)41 public void MethodHasTestNameSpecified(int x, int y, int z) 42 {} 43 44 [TestCase(2, 3, 4, Category = "XYZ")] MethodHasSingleCategory(int x, int y, int z)45 public void MethodHasSingleCategory(int x, int y, int z) 46 { } 47 48 [TestCase(2, 3, 4, Category = "X,Y,Z")] MethodHasMultipleCategories(int x, int y, int z)49 public void MethodHasMultipleCategories(int x, int y, int z) 50 { } 51 52 [TestCase(2, 2000000, ExpectedResult=4)] MethodCausesConversionOverflow(short x, short y)53 public int MethodCausesConversionOverflow(short x, short y) 54 { 55 return x + y; 56 } 57 58 [TestCase(2, 3, 4, ExpectedException = typeof(ArgumentNullException))] MethodThrowsExpectedException(int x, int y, int z)59 public void MethodThrowsExpectedException(int x, int y, int z) 60 { 61 throw new ArgumentNullException(); 62 } 63 64 [TestCase(2, 3, 4, ExpectedException = typeof(ArgumentNullException))] MethodThrowsWrongException(int x, int y, int z)65 public void MethodThrowsWrongException(int x, int y, int z) 66 { 67 throw new ArgumentException(); 68 } 69 70 [TestCase(2, 3, 4, ExpectedException = typeof(ArgumentNullException))] MethodThrowsNoException(int x, int y, int z)71 public void MethodThrowsNoException(int x, int y, int z) 72 { 73 } 74 75 [TestCase(2, 3, 4, ExpectedException = typeof(Exception), 76 ExpectedMessage="Test Exception")] MethodThrowsExpectedExceptionWithWrongMessage(int x, int y, int z)77 public void MethodThrowsExpectedExceptionWithWrongMessage(int x, int y, int z) 78 { 79 throw new Exception("Wrong Test Exception"); 80 } 81 82 [TestCase(2, 3, 4, ExpectedException = typeof(ArgumentNullException))] MethodCallsIgnore(int x, int y, int z)83 public void MethodCallsIgnore(int x, int y, int z) 84 { 85 Assert.Ignore("Ignore this"); 86 } 87 88 [TestCase(1)] 89 [TestCase(2, Ignore = true)] 90 [TestCase(3, IgnoreReason = "Don't Run Me!")] MethodWithIgnoredTestCases(int num)91 public void MethodWithIgnoredTestCases(int num) 92 { 93 } 94 95 [TestCase(1)] 96 [TestCase(2, Explicit = true)] 97 [TestCase(3, Explicit = true, Reason = "Connection failing")] MethodWithExplicitTestCases(int num)98 public void MethodWithExplicitTestCases(int num) 99 { 100 } 101 } 102 } 103