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 26 namespace NUnit.Framework.Attributes 27 { 28 public class TestFixtureAttributeTests 29 { 30 static object[] fixtureArgs = new object[] { 10, 20, "Charlie" }; 31 #if CLR_2_0 || CLR_4_0 32 static Type[] typeArgs = new Type[] { typeof(int), typeof(string) }; 33 static object[] combinedArgs = new object[] { typeof(int), typeof(string), 10, 20, "Charlie" }; 34 #endif 35 36 [Test] ConstructWithoutArguments()37 public void ConstructWithoutArguments() 38 { 39 TestFixtureAttribute attr = new TestFixtureAttribute(); 40 Assert.That(attr.Arguments.Length == 0); 41 #if CLR_2_0 || CLR_4_0 42 Assert.That(attr.TypeArgs.Length == 0); 43 #endif 44 } 45 46 [Test] ConstructWithFixtureArgs()47 public void ConstructWithFixtureArgs() 48 { 49 TestFixtureAttribute attr = new TestFixtureAttribute(fixtureArgs); 50 Assert.That(attr.Arguments, Is.EqualTo( fixtureArgs ) ); 51 #if CLR_2_0 || CLR_4_0 52 Assert.That(attr.TypeArgs.Length == 0 ); 53 #endif 54 } 55 56 #if CLR_2_0 || CLR_4_0 57 [Test] ConstructWithJustTypeArgs()58 public void ConstructWithJustTypeArgs() 59 { 60 TestFixtureAttribute attr = new TestFixtureAttribute(typeArgs); 61 Assert.That(attr.Arguments.Length == 0); 62 Assert.That(attr.TypeArgs, Is.EqualTo(typeArgs)); 63 } 64 65 [Test] ConstructWithNoArgumentsAndSetTypeArgs()66 public void ConstructWithNoArgumentsAndSetTypeArgs() 67 { 68 TestFixtureAttribute attr = new TestFixtureAttribute(); 69 attr.TypeArgs = typeArgs; 70 Assert.That(attr.Arguments.Length == 0); 71 Assert.That(attr.TypeArgs, Is.EqualTo(typeArgs)); 72 } 73 74 [Test] ConstructWithFixtureArgsAndSetTypeArgs()75 public void ConstructWithFixtureArgsAndSetTypeArgs() 76 { 77 TestFixtureAttribute attr = new TestFixtureAttribute(fixtureArgs); 78 attr.TypeArgs = typeArgs; 79 Assert.That(attr.Arguments, Is.EqualTo(fixtureArgs)); 80 Assert.That(attr.TypeArgs, Is.EqualTo(typeArgs)); 81 } 82 83 [Test] ConstructWithCombinedArgs()84 public void ConstructWithCombinedArgs() 85 { 86 TestFixtureAttribute attr = new TestFixtureAttribute(combinedArgs); 87 Assert.That(attr.Arguments, Is.EqualTo(fixtureArgs)); 88 Assert.That(attr.TypeArgs, Is.EqualTo(typeArgs)); 89 } 90 #endif 91 } 92 } 93