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 System.Collections; 26 using System.Reflection; 27 using NUnit.Framework.Internal; 28 using NUnit.Framework.Extensibility; 29 using NUnit.Framework.Api; 30 31 namespace NUnit.Framework.Builders 32 { 33 /// <summary> 34 /// CombiningStrategy is the abstract base for classes that 35 /// know how to combine values provided for individual test 36 /// parameters to create a set of test cases. 37 /// </summary> 38 public abstract class CombiningStrategy 39 { 40 private IEnumerable[] sources; 41 private IEnumerator[] enumerators; 42 43 /// <summary> 44 /// Initializes a new instance of the <see cref="CombiningStrategy"/> 45 /// class using a set of parameter sources. 46 /// </summary> 47 /// <param name="sources">The sources.</param> CombiningStrategy(IEnumerable[] sources)48 public CombiningStrategy(IEnumerable[] sources) 49 { 50 this.sources = sources; 51 } 52 53 /// <summary> 54 /// Gets the sources used by this strategy. 55 /// </summary> 56 /// <value>The sources.</value> 57 public IEnumerable[] Sources 58 { 59 get { return sources; } 60 } 61 62 /// <summary> 63 /// Gets the enumerators for the sources. 64 /// </summary> 65 /// <value>The enumerators.</value> 66 public IEnumerator[] Enumerators 67 { 68 get 69 { 70 if (enumerators == null) 71 { 72 enumerators = new IEnumerator[Sources.Length]; 73 for (int i = 0; i < Sources.Length; i++) 74 enumerators[i] = Sources[i].GetEnumerator(); 75 } 76 77 return enumerators; 78 } 79 } 80 81 /// <summary> 82 /// Gets the test cases generated by the CombiningStrategy. 83 /// </summary> 84 /// <returns>The test cases.</returns> 85 #if CLR_2_0 || CLR_4_0 GetTestCases()86 public abstract System.Collections.Generic.IEnumerable<ITestCaseData> GetTestCases(); 87 #else GetTestCases()88 public abstract System.Collections.IEnumerable GetTestCases(); 89 #endif 90 } 91 } 92