Beispiel #1
0
        public void Execute(GenerationState state)
        {
            if (!state.TestCaseCollection.Scope.Variables.Contains(ColumnName))
            {
                throw new ArgumentOutOfRangeException(String.Format("No column named '{0}' has been found.", ColumnName));
            }

            var index = state.TestCaseCollection.Scope.Variables.ToList().FindIndex(v => v == ColumnName);

            foreach (var newColumnName in NewColumns)
            {
                if (state.TestCaseCollection.Scope.Variables.Contains(newColumnName))
                {
                    throw new ArgumentException(String.Format("Column '{0}' already existing.", newColumnName));
                }

                state.TestCaseCollection.Scope.Variables.Add(newColumnName);
                var newColumn = new DataColumn(newColumnName);
                state.TestCaseCollection.Scope.Content.Columns.Add(newColumn);
            }

            foreach (DataRow row in state.TestCaseCollection.Scope.Content.Rows)
            {
                if ((string)row[ColumnName] != "(none)")
                {
                    var value = (string)row[ColumnName];
                    var array = value.Split(new string[] { Separator }, NewColumns.Count(), StringSplitOptions.None);

                    var i = 0;
                    foreach (var newColumnName in NewColumns)
                    {
                        if (i >= array.Length || string.IsNullOrEmpty(array[i]))
                        {
                            row[newColumnName] = "(none)";
                        }
                        else
                        {
                            row[newColumnName] = array[i];
                        }
                        i++;
                    }
                }
            }
        }
Beispiel #2
0
        public void Execute(CaseSet testCases)
        {
            if (!testCases.Variables.Contains(ColumnName))
            {
                throw new ArgumentOutOfRangeException($"No column named '{ColumnName}' has been found.");
            }

            var index = testCases.Variables.ToList().FindIndex(v => v == ColumnName);

            foreach (var newColumnName in NewColumns)
            {
                if (testCases.Variables.Contains(newColumnName))
                {
                    throw new ArgumentException($"Column '{newColumnName}' already existing.");
                }

                var newColumn = new DataColumn(newColumnName);
                testCases.Content.Columns.Add(newColumn);
            }

            foreach (DataRow row in testCases.Content.Rows)
            {
                if ((string)row[ColumnName] != "(none)")
                {
                    var value = (string)row[ColumnName];
                    var array = value.Split(new string[] { Separator }, NewColumns.Count(), StringSplitOptions.None);

                    var i = 0;
                    foreach (var newColumnName in NewColumns)
                    {
                        if (i >= array.Length || string.IsNullOrEmpty(array[i]))
                        {
                            row[newColumnName] = "(none)";
                        }
                        else
                        {
                            row[newColumnName] = array[i];
                        }
                        i++;
                    }
                }
            }
        }