public void Execute(CaseSet testCases) { if (!testCases.Variables.Contains(ColumnName)) { throw new ArgumentOutOfRangeException(String.Format("No column named '{0}' has been found.", ColumnName)); } var index = testCases.Variables.ToList().FindIndex(v => v == ColumnName); foreach (DataRow row in testCases.Content.Rows) { if ((string)row[ColumnName] != "(none)") { foreach (var valuable in Valuables) { if (valuable.GetValue(row) != "(none)") { row[ColumnName] = (string)row[ColumnName] + valuable.GetValue(row); } else { row[ColumnName] = "(none)"; } } } } }
public void Execute(CaseSet testCases) { var columnNames = ColumnNames; if (columnNames == null || columnNames.Count() == 0) { columnNames = testCases.Variables; } foreach (var columnName in columnNames) { 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 (DataRow row in testCases.Content.Rows) { if ((string)row[columnName] != "(none)") { row[columnName] = Trim((string)row[columnName]); } } } }
public void Execute(CaseSet testCases) { foreach (var variableName in VariableNames) { testCases.Content.Columns.Remove(variableName); } }
public virtual void Execute(CaseSet testCases) { var csvReader = new CsvReader(); testCases.Content = csvReader.ToDataTable(Filename, true); testCases.Content.AcceptChanges(); }
public void Execute(CaseSet testCases) { var dataTable = testCases.Content; foreach (var columnName in Columns) { if (!testCases.Variables.Contains(columnName)) { throw new ArgumentOutOfRangeException(String.Format("No column named '{0}' has been found.", columnName)); } dataTable.Columns.Add("_" + columnName, typeof(string[])); var columnListId = dataTable.Columns["_" + columnName].Ordinal; var columnId = dataTable.Columns[columnName].Ordinal; for (int i = 0; i < dataTable.Rows.Count; i++) { if (dataTable.Rows[i][columnId] is IEnumerable <string> ) { throw new ArgumentOutOfRangeException(String.Format("The column named '{0}' was already an array.", columnName)); } var array = dataTable.Rows[i][columnId].ToString().Split(new[] { Separator }, StringSplitOptions.None); dataTable.Rows[i][columnListId] = array; } dataTable.Columns["_" + columnName].SetOrdinal(columnId); dataTable.Columns.Remove(columnName); dataTable.Columns["_" + columnName].ColumnName = columnName; } dataTable.AcceptChanges(); }
public override void Execute(CaseSet testCases) { if (!testCases.Variables.Contains(Column)) { throw new ArgumentOutOfRangeException(nameof(Column)); } var compare = AssignCompare(Operator); var index = testCases.Variables.ToList().IndexOf(Column); DataTableReader dataReader = null; var filteredRows = testCases.Content.AsEnumerable().Where(row => compare(row[index].ToString(), Values) != Negation); if (filteredRows.Count() > 0) { var filteredTable = filteredRows.CopyToDataTable(); dataReader = filteredTable.CreateDataReader(); } testCases.Content.Clear(); if (dataReader != null) { testCases.Content.Load(dataReader, LoadOption.PreserveChanges); } testCases.Content.AcceptChanges(); }
protected void Cross(DataTable first, DataTable second, CaseSet destination, Func <DataRow, DataRow, bool> matchingRow) { var table = BuildStructure(first, second); foreach (DataRow firstRow in first.Rows) { foreach (DataRow secondRow in second.Rows) { if (matchingRow(firstRow, secondRow)) { var newRow = table.NewRow(); foreach (DataColumn column in firstRow.Table.Columns) { newRow[column.ColumnName] = firstRow[column.ColumnName]; } foreach (DataColumn column in secondRow.Table.Columns) { newRow[column.ColumnName] = secondRow[column.ColumnName]; } table.Rows.Add(newRow); } } } var dataReader = table.CreateDataReader(); destination.Content.Clear(); destination.Content.Load(dataReader, LoadOption.PreserveChanges); destination.Content.AcceptChanges(); }
public virtual void Execute(CaseSet testCases) { var queryEngineFactory = new ExecutionEngineFactory(); var queryEngine = queryEngineFactory.Instantiate(new Query(Query, ConnectionString)); var ds = queryEngine.Execute(); testCases.Content = ds.Tables[0]; }
public void Execute(CaseSet testCases) { var variablesDeleted = testCases.Variables.Except(VariableNames).ToList(); foreach (var variable in variablesDeleted) { testCases.Content.Columns.Remove(variable); } }
public ProjectStatusCalculator(CaseSet caseSet, List<Person> persons, bool isLoadedByAdmin, FbSchedule schedule) { _caseSet = caseSet; _persons = persons; _isScheduleLoadedByAdmin = isLoadedByAdmin; _fbSchedule = schedule; }
public override void Execute(CaseSet testCases) { if (Values == null || Values.Count() == 0) { Replace(testCases, Column, NewValue); } else { Replace(testCases, Column, NewValue, Operator, Negation, Values); } }
public void Execute_ThreeTimesTwo_SixRowsFiveColumns() { var state = new GenerationState(); var alphaCase = new CaseSet(); alphaCase.Content.Columns.Add("firstColumn"); alphaCase.Content.Columns.Add("secondColumn"); alphaCase.Content.Columns.Add("thirdColumn"); var firstAlphaRow = alphaCase.Content.NewRow(); firstAlphaRow[0] = "firstAlphaCell1"; firstAlphaRow[1] = "secondAlphaCell1"; firstAlphaRow[2] = "thirdAlphaCell1"; alphaCase.Content.Rows.Add(firstAlphaRow); var secondAlphaRow = alphaCase.Content.NewRow(); secondAlphaRow[0] = "firstAlphaCell2"; secondAlphaRow[1] = "secondAlphaCell2"; secondAlphaRow[2] = "thirdAlphaCell2"; alphaCase.Content.Rows.Add(secondAlphaRow); state.CaseCollection.Add("alpha", alphaCase); var betaCase = new CaseSet(); betaCase.Content.Columns.Add("fourthColumn"); betaCase.Content.Columns.Add("fifthColumn"); var firstBetaRow = betaCase.Content.NewRow(); firstBetaRow[0] = "firstBetaCell1"; firstBetaRow[1] = "secondBetaCell1"; betaCase.Content.Rows.Add(firstBetaRow); var secondBetaRow = betaCase.Content.NewRow(); secondBetaRow[0] = "firstBetaCell2"; secondBetaRow[1] = "secondBetaCell2"; betaCase.Content.Rows.Add(secondBetaRow); var thirdBetaRow = betaCase.Content.NewRow(); thirdBetaRow[0] = "firstBetaCell3"; thirdBetaRow[1] = "secondBetaCell3"; betaCase.Content.Rows.Add(thirdBetaRow); state.CaseCollection.Add("beta", betaCase); state.CaseCollection.CurrentScopeName = "alpha"; var action = new CrossFullCaseAction("alpha", "beta"); action.Execute(state); Assert.That(alphaCase.Content.Rows, Has.Count.EqualTo(6)); Assert.That(alphaCase.Content.Columns, Has.Count.EqualTo(5)); }
public void Execute(CaseSet testCases) { foreach (DataRow row in testCases.Content.Rows) { foreach (var columnName in ColumnNames) { if (row[columnName] is IEnumerable <string> list) { row[columnName] = list.Distinct().ToArray(); } } } }
public void Cross_ThreeTimesTwoWithTwoCommonColumnNames_ThreeRowsThreeColumns() { var state = new GenerationState(); var alphaCase = new CaseSet(); alphaCase.Content.Columns.Add("keyColumn1"); alphaCase.Content.Columns.Add("keyColumn2"); alphaCase.Content.Columns.Add("thirdColumn"); var firstAlphaRow = alphaCase.Content.NewRow(); firstAlphaRow[0] = "key1"; firstAlphaRow[1] = "keyA"; firstAlphaRow[2] = "thirdAlphaCell1"; alphaCase.Content.Rows.Add(firstAlphaRow); var secondAlphaRow = alphaCase.Content.NewRow(); secondAlphaRow[0] = "key2"; secondAlphaRow[1] = "keyB"; secondAlphaRow[2] = "thirdAlphaCell2"; alphaCase.Content.Rows.Add(secondAlphaRow); state.CaseCollection.Add("alpha", alphaCase); var betaCase = new CaseSet(); betaCase.Content.Columns.Add("keyColumn1"); betaCase.Content.Columns.Add("keyColumn2"); var firstBetaRow = betaCase.Content.NewRow(); firstBetaRow[0] = "key1"; firstBetaRow[1] = "keyA"; betaCase.Content.Rows.Add(firstBetaRow); var secondBetaRow = betaCase.Content.NewRow(); secondBetaRow[0] = "key1"; secondBetaRow[1] = "keyA"; betaCase.Content.Rows.Add(secondBetaRow); var thirdBetaRow = betaCase.Content.NewRow(); thirdBetaRow[0] = "key2"; thirdBetaRow[1] = "keyB"; betaCase.Content.Rows.Add(thirdBetaRow); state.CaseCollection.Add("beta", betaCase); state.CaseCollection.CurrentScopeName = "alpha"; var action = new CrossJoinCaseAction("alpha", "beta", new[] { "keyColumn1", "keyColumn2" }); action.Execute(state); Assert.That(alphaCase.Content.Rows, Has.Count.EqualTo(3)); Assert.That(alphaCase.Content.Columns, Has.Count.EqualTo(3)); }
public void Execute(CaseSet testCases) { if (testCases.Variables.Contains(VariableName)) { throw new ArgumentException($"Variable '{VariableName}' already existing."); } var newColumn = new DataColumn(VariableName) { DefaultValue = DefaultValue }; testCases.Content.Columns.Add(newColumn); }
public void Replace(CaseSet testCases, string columnName, string newValue) { if (!testCases.Variables.Contains(columnName)) { throw new ArgumentException($"No column named '{columnName}' has been found."); } var index = testCases.Variables.ToList().IndexOf(columnName); foreach (DataRow row in testCases.Content.Rows) { row[index] = newValue; } testCases.Content.AcceptChanges(); }
public void Setup() { var milestoneBuilder = new MilestoneBuilder(); var today = DateTime.Now; _milestone = milestoneBuilder.BuildMileStone(today.Date.AddDays(-5), today.Date.AddDays(+10), 1); var personBuilder = new PersonBuilder(); _persons = new List<Person>(4); _persons.Add(personBuilder.BuildPerson("Ivan", 1)); _persons.Add(personBuilder.BuildPerson("John", 2)); _persons.Add(personBuilder.BuildPerson("Igor", 3)); _persons.Add(personBuilder.BuildPerson("Sasha", 4)); var cases = new List<Case>(); var caseBuilder = new CaseBuilder(); var person = _persons[0]; cases.Add(caseBuilder.BuildCase(person, 10, 2, today.AddDays(-4), 1)); cases.Add(caseBuilder.BuildCase(person, 10, 0, null, 2)); cases.Add(caseBuilder.BuildCase(person, 10, 8, today.AddDays(-3), 3)); person = _persons[1]; cases.Add(caseBuilder.BuildCase(person, 5, 0, null, 4)); cases.Add(caseBuilder.BuildCase(person, 5, 5, today.AddDays(-1), 5)); cases.Add(caseBuilder.BuildCase(person, 5, 3, today, 6)); person = _persons[2]; cases.Add(caseBuilder.BuildCase(person, 15, 8, today.AddDays(-4), 7)); cases.Add(caseBuilder.BuildCase(person, 15, 10, today.AddDays(-3), 8)); cases.Add(caseBuilder.BuildCase(person, 150, 9, today.AddDays(-2), 9)); person = _persons[3]; cases.Add(caseBuilder.BuildCase(person, 5, 0, null, 10)); cases.Add(caseBuilder.BuildCase(person, 5, 0, null, 11)); cases.Add(caseBuilder.BuildCase(person, 5, 0, null, 12)); _caseSet = new CaseSet() {Cases = cases, Milestone = _milestone}; _isScheduleLoadedByAdmin = false; _schedule = new FbSchedule(); }
public void Execute(CaseSet testCases) { var currentPosition = testCases.Variables.ToList().IndexOf(VariableName); //Calculate new position var newPosition = (Ordinal != int.MinValue && Ordinal != int.MaxValue) ? currentPosition + Ordinal : (Ordinal == int.MinValue) ? 0 : testCases.Variables.Count() - 1; if (!testCases.Variables.Contains(VariableName)) { throw new ArgumentOutOfRangeException("variableName"); } testCases.Content.Columns[currentPosition].SetOrdinal(newPosition); testCases.Content.AcceptChanges(); }
public void Execute(CaseSet testCases) { foreach (var newColumn in NewColumns) { var dataTable = testCases.Content; dataTable.Columns.Add(new DataColumn(newColumn, typeof(object)) { AllowDBNull = true, DefaultValue = DBNull.Value }); foreach (DataRow row in dataTable.Rows) { if (!row.IsNull(OriginalColumn)) { row[newColumn] = row[OriginalColumn]; } } } }
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++; } } } }
public void Execute(CaseSet testCases) { DataTableReader dataReader = null; var content = testCases.Content; var distinctRows = content.AsEnumerable().Distinct(DataRowComparer.Default); if (distinctRows.Count() > 0) { var distinctTable = distinctRows.CopyToDataTable(); dataReader = distinctTable.CreateDataReader(); } content.Clear(); if (dataReader != null) { content.Load(dataReader, LoadOption.PreserveChanges); } content.AcceptChanges(); }
public void Replace(CaseSet testCases, string columnName, string newValue, OperatorType @operator, bool negation, IEnumerable <string> values) { if (!testCases.Variables.Contains(columnName)) { throw new ArgumentException($"No column named '{columnName}' has been found."); } var compare = AssignCompare(@operator); var index = testCases.Variables.ToList().IndexOf(columnName); foreach (DataRow row in testCases.Content.Rows) { if (compare(row[index].ToString(), values) != negation) { row[index] = newValue; } } testCases.Content.AcceptChanges(); }
private GenerationState BuildOriginalState() { var state = new GenerationState(); var master = new CaseSet(); master.Content.Columns.Add("keyColumn1"); master.Content.Columns.Add("keyColumn2"); master.Content.Columns.Add("thirdColumn"); var firstAlphaRow = master.Content.NewRow(); firstAlphaRow[0] = "key1"; firstAlphaRow[1] = "keyA"; firstAlphaRow[2] = "thirdAlphaCell1"; master.Content.Rows.Add(firstAlphaRow); var secondAlphaRow = master.Content.NewRow(); secondAlphaRow[0] = "key2"; secondAlphaRow[1] = "keyB"; secondAlphaRow[2] = "thirdAlphaCell2"; master.Content.Rows.Add(secondAlphaRow); state.CaseCollection.Add("master", master); return(state); }
public static CaseSet GetCaseSet(int projectId, int milestoneId, int? subProjectParentCaseId = null) { object existingCaseSet = null; string cacheKey = MsCacheKey.GenCaseSetKey(projectId, milestoneId, subProjectParentCaseId); if (MsCache.TryGet(cacheKey, ref existingCaseSet)) return (CaseSet)existingCaseSet; var caseSet = new CaseSet(); caseSet.Project = GetProject(projectId); caseSet.Milestone = GetMilestone(milestoneId); if (subProjectParentCaseId.HasValue) caseSet.SubProjectParentCase = GetSubProjectParentCase(subProjectParentCaseId.Value); var cases = GetCases(projectId, milestoneId, subProjectParentCaseId); //For analytics always use cases with no children caseSet.Cases = cases.Where(CaseUtils.HasNoChildren).ToList(); //expire in 1 hour MsCache.Set(cacheKey, caseSet, new TimeSpan(1, 0, 0)); return caseSet; }
public void Execute(CaseSet testCases) { var index = testCases.Variables.ToList().FindIndex(v => v == OldVariableName); testCases.Content.Columns[index].ColumnName = NewVariableName; }
public override void Execute(CaseSet testCases) { Query = System.IO.File.ReadAllText(Filename); base.Execute(testCases); }
public string BeginGettingProjectStatuses(List<ProjectListItem> combinations) { var fbClient = FogBugzGateway.GetClientForParallel(); var persons = fbClient.GetPersons().ToList(); var milestones = GetOnlyStartedMilstones(combinations); var isLoadedByAdmin = FogBugzGateway.GetIsScheduleLoadedByAdmin(); var fbSchedule = FogBugzGateway.GetFbSchedule(); Func<object, int> action = (object obj) => { ProjectStatusListItem combo = obj as ProjectStatusListItem; Core.MsCache.Set(ListProgressStatusKey + "_" + _cacheKey, new ProgressStatusInfo { Value = 66, Label = String.Format("Calculating status for \"{0} {1}\" for tasks {2} of {3}", combo.Project.Name, combo.Milestone.Name, milestones.IndexOf(combo) + 1, milestones.Count) }); var cases = FogBugzGateway.GetCases(combo.ProjectId, combo.MileStoneId, combo.SubProjectParentCaseId, null, fbClient); var caseSet = new CaseSet(); caseSet.Cases = cases; caseSet.Milestone = new Milestone(combo.Milestone); caseSet.Project = new Project(combo.Project); var projectStatusCalculator = new ProjectStatusCalculator(caseSet, persons, isLoadedByAdmin, fbSchedule); var status = projectStatusCalculator.GetProjectStatus(); var eventArgs = new ProjectStatusListEventArgs(combo, status, _cacheKey); SaveStatus(eventArgs); return 0; }; var factory = new TaskFactory(); var tasks = new Task<int>[milestones.Count()]; for (int i = 0; i < milestones.Count(); i++) { tasks[i] = factory.StartNew(action, milestones[i]); } return GenKeysString(milestones); }
public void Execute(CaseSet testCases) { var dataTable = testCases.Content; dataTable.AcceptChanges(); foreach (var columnName in ColumnNames) { dataTable.Columns.Add($"_{columnName}", typeof(List <string>)); } int i = 0; var firstRow = 0; while (i < dataTable.Rows.Count) { var isIdentical = true; for (int j = 0; j < dataTable.Columns.Count - ColumnNames.Count; j++) { if (!ColumnNames.Contains(dataTable.Columns[j].ColumnName) && !(dataTable.Rows[i][j] is IEnumerable <string>)) { isIdentical &= dataTable.Rows[i][j].ToString() == dataTable.Rows[firstRow][j].ToString(); } } if (!isIdentical) { firstRow = i; } foreach (var columnName in ColumnNames) { var columnListId = dataTable.Columns[$"_{columnName}"].Ordinal; var columnId = dataTable.Columns[columnName].Ordinal; if (dataTable.Rows[firstRow][columnListId] == DBNull.Value) { dataTable.Rows[firstRow][columnListId] = new List <string>(); } var list = dataTable.Rows[firstRow][columnListId] as List <string>; if (dataTable.Rows[i][columnId] is IEnumerable <string> ) { list.AddRange(dataTable.Rows[i][columnId] as IEnumerable <string>); } else { list.Add(dataTable.Rows[i][columnId].ToString()); } } if (isIdentical && i != 0) { dataTable.Rows[i].Delete(); } i++; } foreach (var columnName in ColumnNames) { dataTable.Columns.Add($"_{columnName}_", typeof(string[])); } foreach (DataRow row in dataTable.Rows.Cast <DataRow>().Where(x => x.RowState != DataRowState.Deleted)) { foreach (var columnName in ColumnNames) { row[$"_{columnName}_"] = (row[$"_{columnName}"] as List <string>).ToArray(); } } foreach (var columnName in ColumnNames) { var columnId = dataTable.Columns[columnName].Ordinal; dataTable.Columns[$"_{columnName}_"].SetOrdinal(columnId); dataTable.Columns.Remove(columnName); dataTable.Columns.Remove($"_{columnName}"); dataTable.Columns[$"_{columnName}_"].ColumnName = columnName; } dataTable.AcceptChanges(); }
public void Execute(CaseSet testCases) { var csvWriter = new CsvWriter(true); csvWriter.Write(testCases.Content, Filename); }
public void Execute(CaseSet testCases) { testCases.Content = DataTable.Copy(); testCases.Content.AcceptChanges(); }
public abstract void Execute(CaseSet testCases);