public void Execute_ReplaceSecondColumnWithCondition_ColumnReplaced()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            firstRow[0] = "firstCell1";
            firstRow[1] = "secondCell1";
            firstRow[2] = "thirdCell1";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();
            secondRow[0] = "firstCell2";
            secondRow[1] = "secondCell2";
            secondRow[2] = "thirdCell2";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);

            var action = new ReplaceCaseAction("secondColumn", "new cell", NBi.Service.Operator.Like, new[] {"%1"}, false);
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(3));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(2));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0][1], Is.EqualTo("new cell"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[1][1], Is.EqualTo("secondCell2"));
        }
Beispiel #2
0
        public void Execute_ContentWithTwoGroupedRowsForTwoColumns_ContentReduced()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn", typeof(List<string>));
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn", typeof(List<string>));
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");

            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            firstRow[0] = "firstCell1";
            firstRow[1] = new List<string>() { "secondCell1", "secondCell1", "secondCell2" };
            firstRow[2] = new List<string>() { "thirdCell1", "thirdCell1", "thirdCell1" };
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);

            var action = new ReduceCaseAction(new[] { "thirdColumn", "secondColumn" });
            action.Execute(state);

            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(1));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["thirdColumn"], Is.TypeOf<List<string>>());
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["thirdColumn"], Has.Member("thirdCell1"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["thirdColumn"], Has.Count.EqualTo(1));

            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["secondColumn"], Is.TypeOf<List<string>>());
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["secondColumn"], Has.Member("secondCell1"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["secondColumn"], Has.Member("secondCell2"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["secondColumn"], Has.Count.EqualTo(2));
        }
        public void Execute_OneColumnToSplit_Correct()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("initialColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("otherColumn");
            state.TestCaseCollection.Scope.Variables.Add("initialColumn");
            state.TestCaseCollection.Scope.Variables.Add("otherColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            firstRow[0] = "a-b-c";
            firstRow[1] = "other";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();
            secondRow[0] = "a-b";
            secondRow[1] = "other";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);
            var thirdRow = state.TestCaseCollection.Scope.Content.NewRow();
            thirdRow[0] = "a-b-c-d";
            thirdRow[1] = "(none)";
            state.TestCaseCollection.Scope.Content.Rows.Add(thirdRow);

            var columns = new string[] { "initialColumn" };

            var action = new SplitCaseAction(columns, "-");
            action.Execute(state);
            var dataTable = state.TestCaseCollection.Scope.Content;
            Assert.That(dataTable.Columns, Has.Count.EqualTo(2));
            Assert.That(dataTable.Rows, Has.Count.EqualTo(3));

            Assert.That(dataTable.Rows[0]["otherColumn"], Is.TypeOf<string>());
            Assert.That(dataTable.Rows[0]["initialColumn"], Is.TypeOf<List<string>>());

            Assert.That(dataTable.Rows[0]["initialColumn"] as List<string>, Has.Count.EqualTo(3));
            Assert.That(dataTable.Rows[1]["initialColumn"] as List<string>, Has.Count.EqualTo(2));
            Assert.That(dataTable.Rows[2]["initialColumn"] as List<string>, Has.Count.EqualTo(4));
        }
        public void Execute_VectorWithTwoValues_OriginalSetDoubled()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            firstRow[0] = "firstCell1";
            firstRow[1] = "secondCell1";
            firstRow[2] = "thirdCell1";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();
            secondRow[0] = "firstCell2";
            secondRow[1] = "secondCell2";
            secondRow[2] = "thirdCell2";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);

            var action = new CrossVectorCaseAction(state.TestCaseCollection.CurrentScopeName, "fourthColumn", new [] {"Hello", "World"});
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(4));
            Assert.That(state.TestCaseCollection.Scope.Variables[3], Is.EqualTo("fourthColumn"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(4));
        }
        protected GenerationState BuildInitialState()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            firstRow[0] = "Cell";
            firstRow[1] = "secondCell1";
            firstRow[2] = "Text";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();
            secondRow[0] = "Cell";
            secondRow[1] = "secondCell2";
            secondRow[2] = "";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);
            var thirdRow = state.TestCaseCollection.Scope.Content.NewRow();
            thirdRow[0] = "XXX";
            thirdRow[1] = "secondCell3";
            thirdRow[2] = "YYY";
            state.TestCaseCollection.Scope.Content.Rows.Add(thirdRow);

            return state;
        }
Beispiel #6
0
        protected GenerationState Apply(IEnumerable<IAction> actions)
        {
            var state = new GenerationState();
            foreach (var action in actions)
            {
                OnActionInfoEvent(new ActionInfoEventArgs(action.Display));
                action.Execute(state);
            }

            return state;
        }
Beispiel #7
0
        protected GenerationState Apply(IEnumerable <IAction> actions)
        {
            var state = new GenerationState();

            foreach (var action in actions)
            {
                OnActionInfoEvent(new ActionInfoEventArgs(action.Display));
                action.Execute(state);
            }

            return(state);
        }
        public void Execute_SecondColumn_ColumnAddedWithDefaultValue()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            var newRow = state.TestCaseCollection.Scope.Content.NewRow();
            newRow[0] = "firstCell";
            state.TestCaseCollection.Scope.Content.Rows.Add(newRow);

            var action = new AddCaseAction("myColumn");
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0].ItemArray[1], Is.EqualTo("(none)"));
        }
        public void Execute_SecondColumn_ColumnAdded()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            var newRow = state.TestCaseCollection.Scope.Content.NewRow();
            newRow[0] = "firstCell";
            state.TestCaseCollection.Scope.Content.Rows.Add(newRow);

            var action = new AddCaseAction("myColumn");
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(2));
        }
        public void Display_FirstAndThirdColumns_ColumnsRemoved()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");

            var action = new RemoveCaseAction(new List<string>() { "firstColumn", "thirdColumn" });
            Assert.That(action.Display, Is.EqualTo("Removing columns 'firstColumn', 'thirdColumn'"));
        }
 protected GenerationState BuildInitialState(object obj)
 {
     var state = new GenerationState();
     state.TestCaseCollection.Scope.Content.Columns.Add("one");
     state.TestCaseCollection.Scope.Content.Columns.Add("two", typeof(object));
     state.TestCaseCollection.Scope.Variables.Add("one");
     state.TestCaseCollection.Scope.Variables.Add("two");
     var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
     firstRow[0] = "a";
     firstRow[1] = obj;
     state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
     state.Template.Code = "<test name='$one$ + $two$'/>";
     return state;
 }
        public void Execute_FirstColumn_ColumnRemoved()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");

            var action = new RemoveCaseAction("firstColumn");
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(2));
        }
        public void Execute_TwoScopesWithIdenticalColumns_CurrentScopeHasMoreRows()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Item("firstScope").Content.Columns.Add("firstColumn");
            var newRow = state.TestCaseCollection.Scope.Content.NewRow();
            newRow[0] = "firstCell-firstScope";
            state.TestCaseCollection.Scope.Content.Rows.Add(newRow);

            state.TestCaseCollection.Item("secondScope").Content.Columns.Add("firstColumn");
            var newRowBis = state.TestCaseCollection.Item("secondScope").Content.NewRow();
            newRowBis[0] = "firstCell-secondScope";
            state.TestCaseCollection.Item("secondScope").Content.Rows.Add(newRowBis);

            var action = new MergeCaseAction("secondScope");
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(1));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(2));
        }
        public void Execute_SecondColumn_ColumnHeld()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            firstRow[0] = "firstCell";
            firstRow[1] = "secondCell";
            firstRow[2] = "thirdCell";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");

            var action = new HoldCaseAction("secondColumn");
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(1));
            Assert.That(state.TestCaseCollection.Scope.Variables[0], Is.EqualTo("secondColumn"));
        }
        public void Execute_SecondAndThirdColumns_ColumnsHeld()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            firstRow[0] = "firstCell";
            firstRow[1] = "secondCell";
            firstRow[2] = "thirdCell";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");

            var action = new HoldCaseAction(new List<string>() {"secondColumn", "firstColumn"});
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(2));
            Assert.That(state.TestCaseCollection.Scope.Variables, Has.Member("secondColumn"));
            Assert.That(state.TestCaseCollection.Scope.Variables, Has.Member("firstColumn"));
        }
        protected GenerationState BuildInitialState()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("initialColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("otherColumn");
            state.TestCaseCollection.Scope.Variables.Add("initialColumn");
            state.TestCaseCollection.Scope.Variables.Add("otherColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            firstRow[0] = "a-b-c";
            firstRow[1] = "other";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();
            secondRow[0] = "a-b";
            secondRow[1] = "other";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);
            var thirdRow = state.TestCaseCollection.Scope.Content.NewRow();
            thirdRow[0] = "a-b-c-d";
            thirdRow[1] = "(none)";
            state.TestCaseCollection.Scope.Content.Rows.Add(thirdRow);

            return state;
        }
        public void Execute_SecondColumnMoveRight_ColumnMoved()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("fourthColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");
            state.TestCaseCollection.Scope.Variables.Add("fourthColumn");

            var action = new MoveCaseAction("secondColumn", 1);
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(4));
            Assert.That(state.TestCaseCollection.Scope.Variables[0], Is.EqualTo("firstColumn"));
            Assert.That(state.TestCaseCollection.Scope.Variables[1], Is.EqualTo("thirdColumn"));
            Assert.That(state.TestCaseCollection.Scope.Variables[2], Is.EqualTo("secondColumn"));
            Assert.That(state.TestCaseCollection.Scope.Variables[3], Is.EqualTo("fourthColumn"));
        }
        public void Execute_TwoScopesWithDifferentColumns_CurrentScopeHasMoreRowsAndNewColumn()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Item("firstScope").Content.Columns.Add("firstColumn");
            var newRow = state.TestCaseCollection.Scope.Content.NewRow();
            newRow[0] = "firstCell-firstScope";
            state.TestCaseCollection.Scope.Content.Rows.Add(newRow);

            state.TestCaseCollection.Item("secondScope").Content.Columns.Add("secondColumn");
            var newRowBis = state.TestCaseCollection.Item("secondScope").Content.NewRow();
            newRowBis[0] = "firstCell-secondScope";
            state.TestCaseCollection.Item("secondScope").Content.Rows.Add(newRowBis);

            var action = new MergeCaseAction("secondScope");
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(2));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(2));

            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0].ItemArray[0], Is.EqualTo("firstCell-firstScope"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0].IsNull(1), Is.True);
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[1].ItemArray[1], Is.EqualTo("firstCell-secondScope"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[1].IsNull(0), Is.True);
        }
        protected GenerationState BuildState()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");

            return state;
        }
        public void Execute_ReplaceSecondColumn_ColumnReplaced()
        {
            var state = new GenerationState();
            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn");
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("thirdColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();
            firstRow[0] = "firstCell1";
            firstRow[1] = "secondCell1";
            firstRow[2] = "thirdCell1";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();
            secondRow[0] = "firstCell2";
            secondRow[1] = "secondCell2";
            secondRow[2] = "thirdCell2";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);

            var action = new ReplaceCaseAction("secondColumn", "new cell");
            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(3));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(2));
            foreach (DataRow row in state.TestCaseCollection.Scope.Content.Rows)
                Assert.That(row[1], Is.EqualTo("new cell"));
        }