PageRenderTime 25ms CodeModel.GetById 19ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/src/NUnit/core/Builders/SequentialStrategy.cs

#
C# | 55 lines | 41 code | 9 blank | 5 comment | 4 complexity | 50be939b3ad07ce7cfc25ab38cd167d7 MD5 | raw file
 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
 7using System;
 8using System.Collections;
 9#if NET_2_0
10using System.Collections.Generic;
11#endif
12using System.Reflection;
13using NUnit.Core.Extensibility;
14
15namespace NUnit.Core.Builders
16{
17    public class SequentialStrategy : CombiningStrategy
18    {
19        public SequentialStrategy(IEnumerable[] sources) : base(sources) { }
20
21        public override IEnumerable GetTestCases()
22        {
23#if NET_2_0
24            List<ParameterSet> testCases = new List<ParameterSet>();
25#else
26            ArrayList testCases = new ArrayList();
27#endif
28
29            for (; ; )
30            {
31                bool gotData = false;
32                object[] testdata = new object[Sources.Length];
33
34                for (int i = 0; i < Sources.Length; i++)
35                    if (Enumerators[i].MoveNext())
36                    {
37                        testdata[i] = Enumerators[i].Current;
38                        gotData = true;
39                    }
40                    else
41                        testdata[i] = null;
42
43                if (!gotData)
44                    break;
45
46                ParameterSet testcase = new ParameterSet();
47                testcase.Arguments = testdata;
48
49                testCases.Add(testcase);
50            }
51
52            return testCases;
53        }
54    }
55}