Пример #1
0
        public void Execute(GenerationState state)
        {
            var index = state.TestCaseCollection.Scope.Variables.ToList().FindIndex(v => v == OldVariableName);

            state.TestCaseCollection.Scope.Variables[index] = NewVariableName;
            state.TestCaseCollection.Scope.Content.Columns[index].ColumnName = NewVariableName;
        }
Пример #2
0
 public void Execute(GenerationState state)
 {
     state.Suite.DefineSettings(state.Settings.GetSettingsXml());
     state.Suite.DefineVariables(state.Variables);
     state.Suite.DefineTests(state.List.GetTests());
     state.Suite.SaveAs(Filename);
 }
Пример #3
0
        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);
        }
Пример #4
0
        public void Execute_Filename_StateUpdated()
        {
            var state = new GenerationState();

            using (var memory = new MemoryStream())
            {
                var sw = new StreamWriter(memory, new UnicodeEncoding());
                sw.Write(@"<?xml version=""1.0"" encoding=""utf-8""?>
                            <variables>
                              <variable name=""var1"">
                                <script language=""c-sharp"">DateTime.Now</script>
                              </variable>
                              <variable name=""var2"">
                                <script language=""c-sharp"">DateTime.Now.Year+1</script>
                              </variable>
                            </variables> ");
                sw.Flush();
                memory.Seek(0, SeekOrigin.Begin);

                var action = new IncludeVariableActionTestable(memory);
                action.Execute(state);
            }

            Assert.That(state.Variables, Has.Count.EqualTo(2));
            Assert.That(state.Variables.ContainsKey("var1"), Is.True);
            Assert.That(state.Variables.ContainsKey("var2"), Is.True);
            Assert.That(state.Variables.All(x => (x.Value as GlobalVariableXml).Script.Language == LanguageType.CSharp), Is.True);
            Assert.That(state.Variables.All(x => (x.Value as GlobalVariableXml).Script.Code.StartsWith("DateTime")), Is.True);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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"));
        }
Пример #7
0
        public void Execute(GenerationState state)
        {
            var dataTable = state.TestCaseCollection.Scope.Content;

            foreach (var columnName in Columns)
            {
                if (!state.TestCaseCollection.Scope.Variables.Contains(columnName))
                    throw new ArgumentOutOfRangeException(String.Format("No column named '{0}' has been found.", columnName));

                dataTable.Columns.Add("_" + columnName, typeof(List<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);
                    var list = new List<string>();
                    list.AddRange(array);
                    dataTable.Rows[i][columnListId] = list;
                }

                dataTable.Columns["_" + columnName].SetOrdinal(columnId);
                dataTable.Columns.Remove(columnName);
                dataTable.Columns["_" + columnName].ColumnName = columnName;
            }

            dataTable.AcceptChanges();
        }
Пример #8
0
 public void Execute(GenerationState state)
 {
     if (Values==null || Values.Count()==0)
         state.TestCaseCollection.Scope.Replace(Column, NewValue);
     else
         state.TestCaseCollection.Scope.Replace(Column, NewValue, Operator, Negation, Values);
 }
Пример #9
0
        public void Execute_VectorAndCellsWithArray_NoSpecificIssue()
        {
            var state = new GenerationState();

            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();

            firstRow[0] = "firstCell1.1/firstCell1.2";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();

            secondRow[0] = "firstCell2.1/firstCell2.2";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);

            var splitAction = new SplitCaseAction(new[] { "firstColumn" }, "/");

            splitAction.Execute(state);

            var action = new CrossVectorCaseAction(state.TestCaseCollection.CurrentScopeName, "helloColumn", new[] { "Hello" });

            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(2));
            Assert.That(state.TestCaseCollection.Scope.Variables[1], Is.EqualTo("helloColumn"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(2));
        }
Пример #10
0
        private GenerationState BuildOriginalState()
        {
            var state  = new GenerationState();
            var master = state.TestCaseCollection.Item("master");

            master.Content.Columns.Add("keyColumn1");
            master.Content.Columns.Add("keyColumn2");
            master.Content.Columns.Add("thirdColumn");
            master.Variables.Add("keyColumn1");
            master.Variables.Add("keyColumn2");
            master.Variables.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);

            return(state);
        }
Пример #11
0
        private void ga_OnGenerationComplete(object sender, GaEventArgs e)
        {
            // Basic log debugging stuff. Not really needed
            Console.WriteLine("Generation {0} | Max Fitness {1}", e.Generation, e.Population.MaximumFitness);

            // Do WoC stuff
            Chromosome wocChrom = CalculateWoC(e.Population);

            // Add this generation's data to our log
            log.Write(Log.GenerationData.GenDataFromPopulation(e.Generation, e.Population, wocChrom));

            // Report the current state of execution back to the main UI thread
            GenerationState gs = new GenerationState()
            {
                genNum = e.Generation, maxFit = e.Population.MaximumFitness
            };

            b.ReportProgress(-1, gs);

            // Maintain lastFiveGens queue
            // Put this generations fitness onto the queue
            lastFiveGens.Enqueue(e.Population.MaximumFitness);
            // Pull 6th last generation from queue, if it exists
            if (lastFiveGens.Count > 5)
            {
                lastFiveGens.Dequeue();
            }
        }
Пример #12
0
        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);
        }
Пример #13
0
        public void ResumeGeneration()
        {
            enabled = true;
            _state  = GenerationState.Generation;

            StartNextPhase();
        }
Пример #14
0
        public void Execute_ReplaceSecondColumnWithCondition_ColumnReplaced()
        {
            var state = new GenerationState();

            state.CaseCollection.CurrentScope.Content.Columns.Add("firstColumn");
            state.CaseCollection.CurrentScope.Content.Columns.Add("secondColumn");
            state.CaseCollection.CurrentScope.Content.Columns.Add("thirdColumn");
            var firstRow = state.CaseCollection.CurrentScope.Content.NewRow();

            firstRow[0] = "firstCell1";
            firstRow[1] = "secondCell1";
            firstRow[2] = "thirdCell1";
            state.CaseCollection.CurrentScope.Content.Rows.Add(firstRow);
            var secondRow = state.CaseCollection.CurrentScope.Content.NewRow();

            secondRow[0] = "firstCell2";
            secondRow[1] = "secondCell2";
            secondRow[2] = "thirdCell2";
            state.CaseCollection.CurrentScope.Content.Rows.Add(secondRow);


            var action = new ReplaceCaseAction("secondColumn", "new cell", OperatorType.Like, new[] { "%1" }, false);

            action.Execute(state);
            Assert.That(state.CaseCollection.CurrentScope.Content.Columns, Has.Count.EqualTo(3));
            Assert.That(state.CaseCollection.CurrentScope.Content.Rows, Has.Count.EqualTo(2));
            Assert.That(state.CaseCollection.CurrentScope.Content.Rows[0][1], Is.EqualTo("new cell"));
            Assert.That(state.CaseCollection.CurrentScope.Content.Rows[1][1], Is.EqualTo("secondCell2"));
        }
Пример #15
0
        private void toPreparation()
        {
            Vector3 pointerPosition = worldmapController.pointer.localPosition;

            GenerationState.get().localGenConfig.location = new IntVector2((int)pointerPosition.x, (int)pointerPosition.y);
            switchTo(preparationStage);
        }
Пример #16
0
        public void Execute_TwoRowsDuplicatedContainingAnArrayWithDifference_TwoRowsRemain()
        {
            var state = new GenerationState();

            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn", typeof(object));
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn", typeof(object));
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();

            firstRow[0] = "firstCell1";
            firstRow[1] = "foo/bar";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();

            secondRow[0] = "firstCell1";
            secondRow[1] = "foo/bar/x";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);

            var splitAction = new SplitCaseAction(new[] { "secondColumn" }, "/");

            splitAction.Execute(state);

            var action = new FilterDistinctCaseAction();

            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("firstCell1"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0].ItemArray[1], Has.Member("foo"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0].ItemArray[1], Has.Member("bar"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[1].ItemArray[1], Has.Member("x"));
        }
Пример #17
0
        public void Execute_TwoScopesWithIdenticalColumns_CurrentScopeHasMoreRows()
        {
            var state = new GenerationState();

            state.CaseCollection.Add("firstScope", new CaseSet());
            state.CaseCollection["firstScope"].Content.Columns.Add("firstColumn");
            state.CaseCollection.CurrentScopeName = "firstScope";
            var newRow = state.CaseCollection.CurrentScope.Content.NewRow();

            newRow[0] = "firstCell-firstScope";
            state.CaseCollection.CurrentScope.Content.Rows.Add(newRow);

            state.CaseCollection.Add("secondScope", new CaseSet());
            state.CaseCollection["secondScope"].Content.Columns.Add("firstColumn");
            var newRowBis = state.CaseCollection["secondScope"].Content.NewRow();

            newRowBis[0] = "firstCell-secondScope";
            state.CaseCollection["secondScope"].Content.Rows.Add(newRowBis);

            var action = new MergeCaseAction("secondScope");

            action.Execute(state);
            Assert.That(state.CaseCollection.CurrentScope.Content.Columns, Has.Count.EqualTo(1));
            Assert.That(state.CaseCollection.CurrentScope.Content.Rows, Has.Count.EqualTo(2));
        }
Пример #18
0
        protected GenerationState BuildInitialState()
        {
            var state = new GenerationState();

            state.CaseCollection.CurrentScope.Content.Columns.Add("firstColumn");
            state.CaseCollection.CurrentScope.Content.Columns.Add("secondColumn");
            state.CaseCollection.CurrentScope.Content.Columns.Add("thirdColumn");
            var firstRow = state.CaseCollection.CurrentScope.Content.NewRow();

            firstRow[0] = "firstCell1";
            firstRow[1] = "secondCell1";
            firstRow[2] = "thirdCell1";
            state.CaseCollection.CurrentScope.Content.Rows.Add(firstRow);
            var secondRow = state.CaseCollection.CurrentScope.Content.NewRow();

            secondRow[0] = "firstCell2";
            secondRow[1] = "";
            secondRow[2] = "thirdCell2";
            state.CaseCollection.CurrentScope.Content.Rows.Add(secondRow);
            var thirdRow = state.CaseCollection.CurrentScope.Content.NewRow();

            thirdRow[0] = "firstCell3";
            thirdRow[1] = "(none)";
            thirdRow[2] = "thirdCell3";
            state.CaseCollection.CurrentScope.Content.Rows.Add(thirdRow);

            return(state);
        }
Пример #19
0
        public void Execute_SecondColumnMoveLast_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", int.MaxValue);

            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("fourthColumn"));
            Assert.That(state.TestCaseCollection.Scope.Variables[3], Is.EqualTo("secondColumn"));
        }
Пример #20
0
        internal void ArchivesPacked()
        {
            gen_state = GenerationState.ImageGeneration;
            var progress = Externals.PS2ImageMaker.PS2ImageMaker.StartPacking(tbTwinsanityPath.Text, tbOutputPath.Text + "\\" + tbImageName.Text + ".iso");

            tspbGenerationProgress.Value = (int)(progress.ProgressPercentage * 100);
        }
Пример #21
0
 public override void generate()
 {
     Debug.Log("placing ramps");
     localMap = GenerationState.get().localGenContainer.localMap;
     fillRamps();
     fillFloors();
 }
Пример #22
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(string[]));
            state.TestCaseCollection.Scope.Content.Columns.Add("thirdColumn", typeof(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 [] { "secondCell1", "secondCell1", "secondCell2" };
            firstRow[2] = new [] { "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 <string[]>());
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["thirdColumn"], Has.Member("thirdCell1"));
            Assert.That((state.TestCaseCollection.Scope.Content.Rows[0]["thirdColumn"] as Array).Length, Is.EqualTo(1));

            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["secondColumn"], Is.TypeOf <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"] as Array).Length, Is.EqualTo(2));
        }
Пример #23
0
 public void Execute(GenerationState state)
 {
     if (IsMatchingColumn)
         state.TestCaseCollection.Cross(FirstSet, SecondSet, MatchingColumn);
     else
         state.TestCaseCollection.Cross(FirstSet, SecondSet);
 }
Пример #24
0
        public void StartGeneration()
        {
            _state  = GenerationState.Start;
            enabled = true;

            GenerationStarted.Invoke();
        }
Пример #25
0
        public void Execute(GenerationState state)
        {
            var dataTable = state.TestCaseCollection.Scope.Content;

            foreach (var columnName in Columns)
            {
                if (!state.TestCaseCollection.Scope.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();
        }
Пример #26
0
        public void Execute_ReplaceSecondColumn_ColumnReplaced()
        {
            var state = new GenerationState();

            state.CaseCollection.CurrentScope.Content.Columns.Add("firstColumn");
            state.CaseCollection.CurrentScope.Content.Columns.Add("secondColumn");
            state.CaseCollection.CurrentScope.Content.Columns.Add("thirdColumn");
            var firstRow = state.CaseCollection.CurrentScope.Content.NewRow();

            firstRow[0] = "firstCell1";
            firstRow[1] = "secondCell1";
            firstRow[2] = "thirdCell1";
            state.CaseCollection.CurrentScope.Content.Rows.Add(firstRow);
            var secondRow = state.CaseCollection.CurrentScope.Content.NewRow();

            secondRow[0] = "firstCell2";
            secondRow[1] = "secondCell2";
            secondRow[2] = "thirdCell2";
            state.CaseCollection.CurrentScope.Content.Rows.Add(secondRow);


            var action = new ReplaceCaseAction("secondColumn", "new cell");

            action.Execute(state);
            Assert.That(state.CaseCollection.CurrentScope.Content.Columns, Has.Count.EqualTo(3));
            Assert.That(state.CaseCollection.CurrentScope.Content.Rows, Has.Count.EqualTo(2));
            foreach (DataRow row in state.CaseCollection.CurrentScope.Content.Rows)
            {
                Assert.That(row[1], Is.EqualTo("new cell"));
            }
        }
Пример #27
0
        public void Execute_OneRowDuplicated_OnlyOneRemains()
        {
            var state = new GenerationState();

            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");
            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");
            var firstRow = state.TestCaseCollection.Scope.Content.NewRow();

            firstRow[0] = "firstCell1";
            firstRow[1] = "secondCell1";
            state.TestCaseCollection.Scope.Content.Rows.Add(firstRow);
            var secondRow = state.TestCaseCollection.Scope.Content.NewRow();

            secondRow[0] = "firstCell1";
            secondRow[1] = "secondCell1";
            state.TestCaseCollection.Scope.Content.Rows.Add(secondRow);

            var action = new FilterDistinctCaseAction();

            action.Execute(state);

            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(2));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(1));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0].ItemArray[0], Is.EqualTo("firstCell1"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0].ItemArray[1], Is.EqualTo("secondCell1"));
        }
Пример #28
0
        private void ga_OnGenerationComplete(object sender, GaEventArgs e)
        {
            // Generate the WoC individual for this generation
            var wocSolution = GenerateWoCSolution(e.Population);

            // Add this generation's data to our log
            log.Write(Log.GenerationData.GenDataFromPopulation(e.Generation, stopwatch.Elapsed.TotalSeconds, e.Population, wocSolution));

            // Report the current state of execution back to the main UI thread
            GenerationState gs = new GenerationState()
            {
                genNum = e.Generation, maxFit = e.Population.MaximumFitness
            };

            b.ReportProgress(-1, gs);

            // Maintain lastFiveGens queue
            // Put this generations fitness onto the queue
            plateauDetectorQueue.Enqueue(e.Population.MaximumFitness);
            // Pull 6th last generation from queue, if it exists
            if (plateauDetectorQueue.Count > plateauDetectorSize)
            {
                plateauDetectorQueue.Dequeue();
            }
        }
Пример #29
0
 public void Execute(GenerationState state)
 {
     foreach (var action in actions)
     {
         action.Execute(state);
     }
 }
Пример #30
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 (DataRow row in state.TestCaseCollection.Scope.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)";
                        }
                    }
                }
            }
        }
Пример #31
0
        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));
        }
Пример #32
0
        public void Execute(GenerationState state)
        {
            var columnNames = ColumnNames;

            if (columnNames == null || columnNames.Count() == 0)
            {
                columnNames = state.TestCaseCollection.Scope.Variables;
            }

            foreach (var columnName in columnNames)
            {
                if (!state.TestCaseCollection.Scope.Variables.Contains(columnName))
                {
                    throw new ArgumentOutOfRangeException($"No column named '{columnName}' has been found.");
                }

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

                foreach (DataRow row in state.TestCaseCollection.Scope.Content.Rows)
                {
                    if ((string)row[columnName] != "(none)")
                    {
                        row[columnName] = Trim((string)row[columnName]);
                    }
                }
            }
        }
Пример #33
0
        public void Execute_ContentWithFiveIdenticalRows_ContentReduced()
        {
            var state = new GenerationState();

            state.TestCaseCollection.Scope.Content.Columns.Add("firstColumn");
            state.TestCaseCollection.Scope.Content.Columns.Add("secondColumn");

            state.TestCaseCollection.Scope.Variables.Add("firstColumn");
            state.TestCaseCollection.Scope.Variables.Add("secondColumn");

            Random rnd = new Random();

            for (int i = 0; i < 5; i++)
            {
                var row = state.TestCaseCollection.Scope.Content.NewRow();
                row[0] = rnd.Next(1, 100000);
                row[1] = "secondCell1";
                state.TestCaseCollection.Scope.Content.Rows.Add(row);
            }
            state.TestCaseCollection.Scope.Content.AcceptChanges();

            var action = new GroupCaseAction(new[] { "firstColumn" });

            action.Execute(state);
            Assert.That(state.TestCaseCollection.Scope.Content.Columns, Has.Count.EqualTo(2));

            Assert.That(state.TestCaseCollection.Scope.Content.Rows, Has.Count.EqualTo(1));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["secondColumn"], Is.EqualTo("secondCell1"));
            Assert.That(state.TestCaseCollection.Scope.Content.Rows[0]["firstColumn"], Is.TypeOf <string[]>());
            var list = (state.TestCaseCollection.Scope.Content.Rows[0]["firstColumn"] as string[]).ToList();

            Assert.That(list, Has.Count.EqualTo(5));
        }
Пример #34
0
 public void Execute(GenerationState state)
 {
     foreach (var variableName in variableNames)
     {
         state.TestCaseCollection.Scope.Variables.Remove(variableName);
         state.TestCaseCollection.Scope.Content.Columns.Remove(variableName);
     }
 }
Пример #35
0
        public void Execute(GenerationState state)
        {
            if (!state.TestCaseCollection.ItemExists(MergedScope))
                throw new ArgumentException(String.Format("Scope '{0}' doesn't exist.", MergedScope));

            var dr = state.TestCaseCollection.Item(MergedScope).Content.CreateDataReader();
            state.TestCaseCollection.Scope.Content.Load(dr, LoadOption.PreserveChanges);
            state.TestCaseCollection.Scope.Content.AcceptChanges();
        }
Пример #36
0
        public void Execute(GenerationState state)
        {
            if (state.TestCaseCollection.Scope.Variables.Contains(VariableName))
                throw new ArgumentException(String.Format("Variable '{0}' already existing.", VariableName));

            state.TestCaseCollection.Scope.Variables.Add(VariableName);
            var newColumn = new DataColumn(VariableName);
            newColumn.DefaultValue = DefaultValue;
            state.TestCaseCollection.Scope.Content.Columns.Add(newColumn);
        }
Пример #37
0
        public void Execute(GenerationState state)
        {
            var variablesDeleted = state.TestCaseCollection.Scope.Variables.Except(variableNames).ToList();

            foreach (var variable in variablesDeleted)
            {
                state.TestCaseCollection.Scope.Variables.Remove(variable);
                state.TestCaseCollection.Scope.Content.Columns.Remove(variable);
            }
        }
Пример #38
0
        public void Execute(GenerationState state)
        {
            if (Variable.ToLower() != "ConnectionString".ToLower())
                throw new ArgumentException("Currently you must define the variable as ConnectionString. Other options are not supported!");

            if (state.Settings.Exists(Name))
                state.Settings.SetValue(Name, Value);
            else
                state.Settings.Add(Name, Value);
        }
Пример #39
0
 public void Execute(GenerationState state)
 {
     foreach (DataRow row in state.TestCaseCollection.Scope.Content.Rows)
     {
         foreach (var columnName in columnNames)
         {
             var list = row[columnName] as IList<string>;
             row[columnName] = list.Distinct().ToList();
         }
     }
 }
Пример #40
0
        public void Execute(GenerationState state)
        {
            var currentPosition = state.TestCaseCollection.Scope.Variables.IndexOf(VariableName);

            if (Position != int.MinValue && Position != int.MaxValue)
                state.TestCaseCollection.Scope.MoveVariable(VariableName, currentPosition + Position);

            if (Position == int.MinValue)
                state.TestCaseCollection.Scope.MoveVariable(VariableName, 0);

            if (Position == int.MaxValue)
                state.TestCaseCollection.Scope.MoveVariable(VariableName, state.TestCaseCollection.Scope.Variables.Count-1);
        }
Пример #41
0
        public void Execute(GenerationState state)
        {
            foreach (var columnName in columnNames)
                state.TestCaseCollection.Scope.Content.Columns.Add("_" + columnName, typeof(List<string>));

            var dataTable = state.TestCaseCollection.Scope.Content;

            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 IList<string>;
                    list.Add(dataTable.Rows[i][columnId].ToString());
                }

                if (isIdentical && i!=0)
                    dataTable.Rows[i].Delete();
                else
                    i++;
            }

            foreach (var columnName in columnNames)
            {
                var columnId = dataTable.Columns[columnName].Ordinal;

                dataTable.Columns["_" + columnName].SetOrdinal(columnId);
                dataTable.Columns.Remove(columnName);
                dataTable.Columns["_" + columnName].ColumnName = columnName;
            }

            dataTable.AcceptChanges();
        }
Пример #42
0
 public void Execute(GenerationState state)
 {
     Action<GenerationState> function = null;
     switch (LoadType)
     {
         case LoadType.File:
             function = LoadExternal;
             break;
         case LoadType.Predefined:
             function = LoadPredefined;
             break;
         default:
             break;
     }
     function.Invoke(state);
 }
Пример #43
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 (DataRow row in state.TestCaseCollection.Scope.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)";
            }
        }
Пример #44
0
        public void Execute(GenerationState state)
        {
            if (Variable.ToLower() != "ConnectionString".ToLower())
                throw new ArgumentException("Currently you must define the variable as ConnectionString. Other options are not supported!");

            var name = string.Empty;
            switch (DefaultType)
            {
                case DefaultType.SystemUnderTest: name = "Default - System-under-test";
                    break;
                case DefaultType.Assert: name= "Default - Assert";
                    break;
                default:
                    break;
            }

            state.Settings.SetValue(name, Value);
        }
        public bool CheckExitStrategy(GenerationState generationState)
        {
            this.previousGenerationsScores.Add(generationState.GenerationNumber, generationState.TopDecileAverageScore);
            if (this.previousGenerationsScores.Count <= PreviousGenerationsToKeep)
            {
                // Don't exit until we have enough generations.
                return false;
            }

            // Remove oldest generation.
            var minimumGeneration = this.previousGenerationsScores.Keys.Min();
            this.previousGenerationsScores.Remove(minimumGeneration);

            // Exit if score hasn't changed siginificantly in previous generations.
            return
                this.previousGenerationsScores.OrderBy(x => x.Key)
                    .Skip(1)
                    .All(generation => !(Math.Abs(this.previousGenerationsScores[generation.Key - 1] - generation.Value) > SignificantThreshold));
        }
      async void _dispatcher_Tick(object sender, object e)
      {
         if (_state == GenerationState.None)
         {
            StartStopButton.Content = "Generate";
            _dispatcher.Stop();
            return;
         }

         var multiplier = _random.NextDouble() * 100;
         var vectorX = multiplier * (_gyroReading.AngularVelocityX + 1) * (_forceReading.AccelerationX + 1);
         var vectorY = multiplier * (_gyroReading.AngularVelocityY + 1) * (_forceReading.AccelerationY + 1);
         var vectorZ = multiplier * (_gyroReading.AngularVelocityZ + 1) * (_forceReading.AccelerationZ + 1);

         var value = Math.Sqrt(Math.Pow(vectorX, 2) + Math.Pow(vectorY, 2) + Math.Pow(vectorZ, 2));

         while (value > Characters.Length)
            value *= _random.NextDouble();

         _generatedSecrets.Add(Characters[(int)value]);
         ProgressBar.Value = _generatedSecrets.Count;
         _newSecretCode = string.Join(" ", _generatedSecrets);
         SecretDisplay.Text = _newSecretCode;
         if (_generatedSecrets.Count == 15)
         {
            _state = GenerationState.None;
            StartStopButton.Content = "Generate";
            _dispatcher.Stop();
            ApplyButton.IsEnabled = true;
            _newSecretCodeWithChecksum = _newSecretCode + SecretChecksum.Compute(_newSecretCode);
            SecretDisplay.Text = _newSecretCodeWithChecksum;
            return;
         }

         await Task.Delay(TimeSpan.FromSeconds(_random.NextDouble() * 2.5 + 0.5));
      }
Пример #47
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++;
                    }
                }
            }
        }
Пример #48
0
 public virtual void Execute(GenerationState state)
 {
     state.TestCaseCollection.Scope.ReadFromCsv(Filename);
 }
Пример #49
0
 public void Execute(GenerationState state)
 {
     state.TestCaseCollection.Copy(From, To);
 }
 public void Execute(GenerationState state)
 {
     state.Settings.SetParallelizeQueries(Value);
 }
Пример #51
0
 public virtual void Execute(GenerationState state)
 {
     state.TestCases.ReadFromQuery(Query, ConnectionString);
 }
 public bool CheckExitStrategy(GenerationState generationState)
 {
     return false;
 }
Пример #53
0
 private void LoadPredefined(GenerationState state)
 {
     state.Template.GetEmbeddedTemplate(Filename);
 }
Пример #54
0
 private void LoadExternal(GenerationState state)
 {
     state.Template.GetExternalTemplate(Filename);
 }
 public virtual void Execute(GenerationState state)
 {
     state.TestCaseCollection.Scope.ReadFromQueryFile(Filename, ConnectionString);
 }
 public void Execute(GenerationState state)
 {
     state.TestCaseCollection.Scope.FilterDistinct();
 }
      private void GenerateClicked(object sender, RoutedEventArgs e)
      {
         if (_state == GenerationState.None)
         {
            StartStopButton.Content = "Cancel";
            ApplyButton.IsEnabled = false;
            ProgressBar.Value = 0;
            _generatedSecrets.Clear();
            _state = GenerationState.Gathering;
            _dispatcher.Start();
            return;
         }

         _state = GenerationState.None;
         StartStopButton.Content = "Generate";
         _dispatcher.Stop();
      }
Пример #58
0
 public void Execute(GenerationState state)
 {
     state.Suite.DefineSettings(state.Settings.GetSettings());
     state.Suite.DefineTests(state.List.GetTests());
     state.Suite.SaveAs(Filename);
 }
Пример #59
0
        public void Execute(GenerationState state)
        {
            var currentPosition = state.TestCases.Variables.IndexOf(VariableName);

            state.TestCases.MoveVariable(VariableName, currentPosition + RelativePosition);
        }
Пример #60
0
 public void Execute(GenerationState state)
 {
     var index = state.TestCaseCollection.Scope.Variables.ToList().FindIndex(v => v == OldVariableName);
     state.TestCaseCollection.Scope.Variables[index] = NewVariableName;
     state.TestCaseCollection.Scope.Content.Columns[index].ColumnName = NewVariableName;
 }