PageRenderTime 48ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/src/NUnit/core/Builders/CombinatorialStrategy.cs

#
C# | 60 lines | 43 code | 12 blank | 5 comment | 7 complexity | b0ecfbd06d3691519ffa341bb2112d4c MD5 | raw file
Possible License(s): GPL-2.0
  1. // ****************************************************************
  2. // Copyright 2008, Charlie Poole
  3. // This is free software licensed under the NUnit license. You may
  4. // obtain a copy of the license at http://nunit.org.
  5. // ****************************************************************
  6. using System;
  7. using System.Collections;
  8. using System.Reflection;
  9. using NUnit.Core.Extensibility;
  10. #if NET_2_0
  11. using System.Collections.Generic;
  12. #endif
  13. namespace NUnit.Core.Builders
  14. {
  15. public class CombinatorialStrategy : CombiningStrategy
  16. {
  17. public CombinatorialStrategy(IEnumerable[] sources) : base(sources) { }
  18. public override IEnumerable GetTestCases()
  19. {
  20. IEnumerator[] enumerators = new IEnumerator[Sources.Length];
  21. int index = -1;
  22. #if NET_2_0
  23. List<ParameterSet> testCases = new List<ParameterSet>();
  24. #else
  25. ArrayList testCases = new ArrayList();
  26. #endif
  27. for (; ; )
  28. {
  29. while (++index < Sources.Length)
  30. {
  31. enumerators[index] = Sources[index].GetEnumerator();
  32. if (!enumerators[index].MoveNext())
  33. return testCases;
  34. }
  35. object[] testdata = new object[Sources.Length];
  36. for (int i = 0; i < Sources.Length; i++)
  37. testdata[i] = enumerators[i].Current;
  38. ParameterSet testCase = new ParameterSet();
  39. testCase.Arguments = testdata;
  40. testCases.Add(testCase);
  41. index = Sources.Length;
  42. while (--index >= 0 && !enumerators[index].MoveNext()) ;
  43. if (index < 0) break;
  44. }
  45. return testCases;
  46. }
  47. }
  48. }