Ejemplo n.º 1
0
 [SetUp] public void SetUp()
 {
     processor = new CellProcessorBase();
     processor.AddOperator(new TestParseInterpreter());
     execute = new ExecuteStoryTest(processor, (t, c) => {});
     tables  = new CellTree(new CellTree(new CellTree("myfixture")));
 }
Ejemplo n.º 2
0
        [Test] public void WaitUntilRepeatsExpectedValueCheck()
        {
            var row = new CellTree("wait until", "next count", "2");

            Invoke(row);
            Assert.AreEqual(fitSharp.Fit.Model.TestStatus.Right, row.Last().Value.GetAttribute(CellAttribute.Status));
        }
Ejemplo n.º 3
0
 public void DisplaysResultInTable()
 {
     processor.Memory.GetItem<Symbols>().Save("mysymbol", "myvalue");
     var table = new CellTree(new CellTree("configure", "symbols", "getvalue", "mysymbol"));
     fixture.Interpret(processor, table);
     Assert.AreEqual("myvalue", table.ValueAt(0, 2).GetAttribute(CellAttribute.Folded));
 }
Ejemplo n.º 4
0
        [Test] public void NameKeywordAssignsASymbol()
        {
            var row = new CellTree("name", "symbol", "stuff");

            Invoke(row);
            Assert.AreEqual("some stuff", processor.Get <Symbols>().GetValue("symbol"));
        }
Ejemplo n.º 5
0
        [Test] public void ShowAsKeywordComposesWithAttributes()
        {
            var row = new CellTree("show as", "raw", "stuff");

            Invoke(row);
            Assert.IsTrue(row.Last().Value.HasAttribute(CellAttribute.Raw));
        }
Ejemplo n.º 6
0
        [Test] public void ChecksExpectedValue()
        {
            var row = new CellTree("check", "stuff", "some stuff");

            Invoke(row);
            Assert.AreEqual(fitSharp.Fit.Model.TestStatus.Right, row.Last().Value.GetAttribute(CellAttribute.Status));
        }
        public void ExecutesFlowKeyword()
        {
            var row = new CellTree("akeyword");

            Evaluate(row, null);
            Assert.AreEqual("somevalue", TestInvokeSpecialAction.Field);
        }
Ejemplo n.º 8
0
 public void ExecutesFlowKeyword()
 {
     var row = new CellTree("akeyword");
     Evaluate(row, null);
     Assert.AreEqual("somevalue", TestInvokeSpecialAction.Field);
     Assert.AreEqual(CellAttributeValue.SyntaxKeyword, row.ValueAt(0).Attributes[CellAttribute.Syntax].Value);
 }
Ejemplo n.º 9
0
        private static void AssertQuery(string columnName, string headerCellName)
        {
            var dataTable = new DataTable();

            dataTable.Columns.Add("somekey", typeof(string));
            dataTable.Columns.Add(columnName, typeof(string));
            var newRow = dataTable.NewRow();

            newRow["somekey"]  = "key";
            newRow[columnName] = "value";
            dataTable.Rows.Add(newRow);
            var fixture = new Query(dataTable, false)
            {
                Processor = new Service()
            };

            var testTable = new CellTree(
                new CellTree("query"),
                new CellTree("somekey", headerCellName),
                new CellTree("key", "value")
                );
            Parse parseTable = Parse.CopyFrom(testTable);

            fixture.DoTable(parseTable);
            Assert.AreEqual(TestStatus.Right, parseTable.At(0, 2, 0).GetAttribute(CellAttribute.Status));
            Assert.AreEqual(TestStatus.Right, parseTable.At(0, 2, 1).GetAttribute(CellAttribute.Status));
        }
Ejemplo n.º 10
0
        public bool Compare(TypedValue actual, Tree <Cell> expected)
        {
            string expectedText = expected.Value.Text.Substring("fail[".Length, expected.Value.Text.Length - ("fail[".Length + 1));
            var    rest         = new CellTree(new CellSubstring(expected.Value, expectedText));

            return(!Processor.Compare(actual, rest));
        }
Ejemplo n.º 11
0
 private static void TestDefine(Tree<Cell> defineRow) {
     var processor = Builder.CellProcessor();
     var define = new Define();
     var input = new CellTree(defineRow, new CellTree("stuff"));
     define.Interpret(processor, input);
     Assert.AreEqual(input, processor.Get<Procedures>().GetValue("myprocedure"));
 }
Ejemplo n.º 12
0
 public void CheckFieldsForWrapsResultInList()
 {
     var row = new CellTree("check fields for", "stuff");
     var result = Invoke(row).GetValue<List<object>>();
     Assert.AreEqual(1, result.Count);
     Assert.AreEqual("some stuff", result[0]);
 }
Ejemplo n.º 13
0
        [Test] public void InvokesMethodInEachRow()
        {
            var table = new CellTree(new CellTree("configure", "processor"), new CellTree("teststatus"));

            fixture.Interpret(processor, table);
            Assert.AreEqual("fitSharp.Fit.Model.TestStatus", table.ValueAt(1, 0).GetAttribute(CellAttribute.Folded));
        }
Ejemplo n.º 14
0
        [Test] public void InvokesMethodInEachRow()
        {
            var table = new CellTree(new CellTree("configure", "processor"), new CellTree("tostring"));

            fixture.Interpret(processor, table);
            Assert.AreEqual("fitSharp.Fit.Service.CellProcessorBase", table.ValueAt(1, 0).GetAttribute(CellAttribute.Folded));
        }
Ejemplo n.º 15
0
        public override void DoRow(Parse theRow)
        {
            try {
                CheckRowSize(theRow.Parts);

                for (int j = 0; j < expectedCount; j++) {
                    var memberCells = new CellTree();
                    memberCells.AddBranch(headerCells.At(j));
                    foreach (var suffixCell in methodSuffixCells.Cells) {
                        memberCells.AddBranch(suffixCell);
                    }

                    Parse expectedCell = theRow.Parts.At(myParameterCount + j + 1);

                    try {
                        Processor.Check(GetTargetObject(), memberCells,
                                            myValues.GetCells(theRow.Branches.Take(myParameterCount)),
                                            expectedCell);
                    }
                    catch (MemberMissingException e) {
                        TestStatus.MarkException(headerCells.At(j), e);
                        TestStatus.MarkIgnore(expectedCell);
                    }
                    catch (IgnoredException) {
                        TestStatus.MarkIgnore(expectedCell);
                    }
                    catch (Exception e) {
                        TestStatus.MarkException(expectedCell, e);
                    }
                }
            }
            catch (Exception e) {
                TestStatus.MarkException(theRow.Parts, e);
            }
        }
Ejemplo n.º 16
0
        [Test] public void CheckFieldsForWrapsResultInList()
        {
            var row    = new CellTree("check fields for", "stuff");
            var result = Invoke(row).GetValue <List <object> >();

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("some stuff", result[0]);
        }
Ejemplo n.º 17
0
        [Test] public void DisplaysResultInTable()
        {
            processor.Memory.GetItem <Symbols>().Save("mysymbol", "myvalue");
            var table = new CellTree(new CellTree("configure", "symbols", "getvalue", "mysymbol"));

            fixture.Interpret(processor, table);
            Assert.AreEqual("myvalue", table.ValueAt(0, 2).GetAttribute(CellAttribute.Folded));
        }
Ejemplo n.º 18
0
        public void ExecutesFlowKeyword()
        {
            var row = new CellTree("akeyword");

            Evaluate(row, null);
            Assert.AreEqual("somevalue", TestInvokeSpecialAction.Field);
            Assert.AreEqual(CellAttributeValue.SyntaxKeyword, row.ValueAt(0).Attributes[CellAttribute.Syntax].Value);
        }
Ejemplo n.º 19
0
 [SetUp] public void SetUp()
 {
     processor = Builder.CellProcessor();
     processor.AddOperator(new TestParseInterpreter());
     processor.AddOperator(new TestInvokeSpecialAction(), 2);
     runTest = new RunTestDefault();
     tables  = new CellTree(new CellTree(new CellTree("myfixture")));
 }
Ejemplo n.º 20
0
 [Test] public void RepeatKeywordWithNoPreviousValue() {
     var rows = new CellTree(new CellTree("xxx", "yy"), new CellTree("aaa", "bb", "ditto"));
     var results = ProcessRows(rows.Branches);
     Assert.AreEqual(3, results.Count,  "count");
     Assert.AreEqual("aaa", results[0], "first");
     Assert.AreEqual("bb", results[1], "second");
     Assert.AreEqual("ditto", results[2], "third");
 }
Ejemplo n.º 21
0
 [Test] public void MultipleRowsReturnsEachCell() {
     var rows = new CellTree(new CellTree("xxx"), new CellTree("aaa", "bb", "c"));
     var results = ProcessRows(rows.Branches);
     Assert.AreEqual(3, results.Count,  "count");
     Assert.AreEqual("aaa", results[0], "first");
     Assert.AreEqual("bb", results[1], "second");
     Assert.AreEqual("c", results[2], "third");
 }
Ejemplo n.º 22
0
        private static void TestDefine(Tree <Cell> defineRow)
        {
            var processor = Builder.CellProcessor();
            var define    = new Define();
            var input     = new CellTree(defineRow, new CellTree("stuff"));

            define.Interpret(processor, input);
            Assert.AreEqual(input, processor.Get <Procedures>().GetValue("myprocedure"));
        }
Ejemplo n.º 23
0
        protected override void Transformation()
        {
            foreach (Cell c in Cells)
            {
                c.Value = NewValue;
            }

            Cells = null;
        }
Ejemplo n.º 24
0
        [Test] public void WaitUntilRepeatsUpToLimit()
        {
            processor.Get <Symbols>().Save("WaitFor.Count", 10);
            processor.Get <Symbols>().Save("WaitFor.Time", 1);
            var row = new CellTree("wait until", "next count", "101");

            Invoke(row);
            Assert.AreEqual(fitSharp.Fit.Model.TestStatus.Wrong, row.Last().Value.GetAttribute(CellAttribute.Status));
        }
        [Test] public void MultipleRowsReturnsEachCell()
        {
            var rows    = new CellTree(new CellTree("xxx"), new CellTree("aaa", "bb", "c"));
            var results = ProcessRows(rows.Branches);

            Assert.AreEqual(3, results.Count, "count");
            Assert.AreEqual("aaa", results[0], "first");
            Assert.AreEqual("bb", results[1], "second");
            Assert.AreEqual("c", results[2], "third");
        }
Ejemplo n.º 26
0
        public virtual Tree <Cell> MakeCell(string text, string tag, IEnumerable <Tree <Cell> > branches)
        {
            var result = new CellTree(new CellBase(text));

            foreach (var branch in branches)
            {
                result.AddBranch(branch);
            }
            return(result);
        }
        [Test] public void RepeatKeywordWithNoPreviousValue()
        {
            var rows    = new CellTree(new CellTree("xxx", "yy"), new CellTree("aaa", "bb", "ditto"));
            var results = ProcessRows(rows.Branches);

            Assert.AreEqual(3, results.Count, "count");
            Assert.AreEqual("aaa", results[0], "first");
            Assert.AreEqual("bb", results[1], "second");
            Assert.AreEqual("ditto", results[2], "third");
        }
Ejemplo n.º 28
0
        [Test] public void ParsesAndExecutesIncludedText()
        {
            processor.AddOperator(new MockRunTestOperator());
            processor.AddOperator(new MockComposeStoryTestString());
            var includeTable = new CellTree(new CellTree("include", "string", input));

            new Include().Interpret(processor, includeTable);
            Assert.IsTrue(includeTable.ValueAt(0, 0).HasAttribute(CellAttribute.Folded));
            Assert.AreEqual(result, includeTable.ValueAt(0, 0).GetAttribute(CellAttribute.Folded));
            Assert.AreEqual(1, processor.TestStatus.Counts.GetCount(TestStatus.Right));
        }
Ejemplo n.º 29
0
 private static void TestDefine(Func<Tree<Cell>, bool> isName, Tree<Cell> defineRow)
 {
     var processor = new Mock<CellProcessor>();
     processor
         .Setup(p => p.Parse(typeof (MemberName), TypedValue.Void, It.Is<Tree<Cell>>(c => isName(c))))
         .Returns(new TypedValue(new MemberName("myprocedure")));
     var define = new Define {Processor = processor.Object};
     var input = new CellTree(defineRow, new CellTree("stuff"));
     define.Interpret(input);
     processor.Verify(p => p.Store(It.Is<Procedure>(v => v.Id == "myprocedure" && v.Instance == input)));
 }
        protected override void Transformation()
        {
            foreach (Cell c in Group.ExclusiveCells)
            {
                c.RepeatGroups.Remove(Group);
            }

            Cells.Min.Cell.GroupActions.Remove((true, Group));
            Cells.Max.Cell.GroupActions.Remove((false, Group));

            Group = null;
            Cells = null;
        }
Ejemplo n.º 31
0
        private static void TestDefine(Func <Tree <Cell>, bool> isName, Tree <Cell> defineRow)
        {
            var processor = new Mock <CellProcessor>();

            processor
            .Setup(p => p.Parse(typeof(MemberName), TypedValue.Void, It.Is <Tree <Cell> >(c => isName(c))))
            .Returns(new TypedValue(new MemberName("myprocedure")));
            var define = new Define {
                Processor = processor.Object
            };
            var input = new CellTree(defineRow, new CellTree("stuff"));

            define.Interpret(input);
            processor.Verify(p => p.Store(It.Is <Procedure>(v => v.Id == "myprocedure" && v.Instance == input)));
        }
Ejemplo n.º 32
0
        protected override void Transformation()
        {
            foreach (Cell c in Group.ExclusiveCells)
            {
                c.MultGroups.Remove(Group);
            }

            Row.MultGroups.Remove(Group);

            Group.ExclusiveCells.First.Value.GroupActions.Remove((true, Group));
            Group.ExclusiveCells.Last.Value.GroupActions.Remove((false, Group));

            ChangesViewWidth = true;

            Group = null;
            Cells = null;
        }
Ejemplo n.º 33
0
        private TypedValue Invoke(Parse procedure, TypedValue target, Tree <Cell> parameterValues)
        {
            var doFixture = new CellTree("fitlibrary.DoFixture");
            var fixture   = Processor.Parse(typeof(Interpreter), target, doFixture);

            var parameters = new Parameters(procedure.Parts, parameterValues);
            var body       = procedure.Parts.More.Parts.Parts != null
                ? new CellTree(procedure.Parts.More.Parts.Parts.DeepCopy(parameters.Substitute, s => s.More, s => s.Parts).SiblingTrees)
                : new CellTree((Tree <Cell>)procedure.DeepCopy(
                                   parameters.Substitute,
                                   s => s == procedure ? null : s.More,
                                   s => s == procedure ? s.Parts.More : s.Parts));

            Processor.TestStatus.PushReturn(TypedValue.Void);
            Processor.Execute(fixture, body);
            Processor.TestStatus.LastAction = Processor.ParseTree(typeof(StoryTestString), body).ValueString;
            return(Processor.TestStatus.PopReturn());
        }
Ejemplo n.º 34
0
    /// <summary>
    ///     Creates the cell hierarchy.
    /// </summary>
    private void CreateCellHierarchy()
    {
        if (!IsCellCountAllowed())
        {
            if (UnityEngine.Debug.isDebugBuild)
            {
                UnityEngine.Debug.LogError("There are too many cells created by your subdivision options. Maximum allowed number of cells is " + (MAX_NUMBER_OF_ALLOWED_CELLS - FIRST_GROUP_ID) + ". Current number of cells is " + CellCount + ".");
                return;
            }
            else
            {
                Application.Quit();
            }
        }

        CellTreeNode rootNode = new CellTreeNode(idCounter++, CellTreeNode.ENodeType.Root, null);

        if (YIsUpAxis)
        {
            Center = new Vector2(transform.position.x, transform.position.y);
            Size   = new Vector2(transform.localScale.x, transform.localScale.y);

            rootNode.Center      = new Vector3(Center.x, Center.y, 0.0f);
            rootNode.Size        = new Vector3(Size.x, Size.y, 0.0f);
            rootNode.TopLeft     = new Vector3((Center.x - (Size.x / 2.0f)), (Center.y - (Size.y / 2.0f)), 0.0f);
            rootNode.BottomRight = new Vector3((Center.x + (Size.x / 2.0f)), (Center.y + (Size.y / 2.0f)), 0.0f);
        }
        else
        {
            Center = new Vector2(transform.position.x, transform.position.z);
            Size   = new Vector2(transform.localScale.x, transform.localScale.z);

            rootNode.Center      = new Vector3(Center.x, 0.0f, Center.y);
            rootNode.Size        = new Vector3(Size.x, 0.0f, Size.y);
            rootNode.TopLeft     = new Vector3((Center.x - (Size.x / 2.0f)), 0.0f, (Center.y - (Size.y / 2.0f)));
            rootNode.BottomRight = new Vector3((Center.x + (Size.x / 2.0f)), 0.0f, (Center.y + (Size.y / 2.0f)));
        }

        CreateChildCells(rootNode, 1);

        CellTree = new CellTree(rootNode);

        RecreateCellHierarchy = false;
    }
Ejemplo n.º 35
0
        private static void AssertQuery(string columnName, string headerCellName)
        {
            var dataTable = new DataTable();
            dataTable.Columns.Add("somekey", typeof (string));
            dataTable.Columns.Add(columnName, typeof (string));
            var newRow = dataTable.NewRow();
            newRow["somekey"] = "key";
            newRow[columnName] = "value";
            dataTable.Rows.Add(newRow);
            var fixture = new Query(dataTable, false) {Processor = new Service()};

            var testTable = new CellTree(
                new CellTree("query"),
                new CellTree("somekey", headerCellName),
                new CellTree("key", "value")
                );
            Parse parseTable = Parse.CopyFrom(testTable);
            fixture.DoTable(parseTable);
            Assert.AreEqual(TestStatus.Right, parseTable.At(0, 2, 0).GetAttribute(CellAttribute.Status));
            Assert.AreEqual(TestStatus.Right, parseTable.At(0, 2, 1).GetAttribute(CellAttribute.Status));
        }
Ejemplo n.º 36
0
        public override void DoRow(Parse theRow)
        {
            try {
                CheckRowSize(theRow.Parts);

                for (int j = 0; j < expectedCount; j++)
                {
                    var memberCells = new CellTree();
                    memberCells.AddBranch(headerCells.At(j));
                    foreach (var suffixCell in methodSuffixCells.Cells)
                    {
                        memberCells.AddBranch(suffixCell);
                    }

                    Parse expectedCell = theRow.Parts.At(myParameterCount + j + 1);

                    try {
                        Processor.Check(GetTargetObject(), memberCells,
                                        myValues.GetCells(theRow.Branches.Take(myParameterCount)),
                                        expectedCell);
                    }
                    catch (MemberMissingException e) {
                        TestStatus.MarkException(headerCells.At(j), e);
                        TestStatus.MarkIgnore(expectedCell);
                    }
                    catch (IgnoredException) {
                        TestStatus.MarkIgnore(expectedCell);
                    }
                    catch (Exception e) {
                        TestStatus.MarkException(expectedCell, e);
                    }
                }
            }
            catch (Exception e) {
                TestStatus.MarkException(theRow.Parts, e);
            }
        }
Ejemplo n.º 37
0
 public AddRepeatGroup(Repeat repeat, CellTree cells) : base(repeat, cells, "Add Repeat Group")
 {
 }
Ejemplo n.º 38
0
 public void WaitUntilRepeatsUpToLimit()
 {
     processor.Get<Symbols>().Save("WaitFor.Count", 10);
     processor.Get<Symbols>().Save("WaitFor.Time", 1);
     var row = new CellTree("wait until", "next count", "101");
     Invoke(row);
     Assert.AreEqual(fitSharp.Fit.Model.TestStatus.Wrong, row.Last().Value.GetAttribute(CellAttribute.Status));
 }
Ejemplo n.º 39
0
 TypedValue Invoke(CellTree row)
 {
     var keyword = row.Branches[0].Value.Text;
     return keywords.InvokeSpecial(interpreter, new MemberName(keyword), row);
 }
Ejemplo n.º 40
0
 public void ShowAsKeywordComposesWithAttributes()
 {
     var row = new CellTree("show as", "raw", "stuff");
     Invoke(row);
     Assert.IsTrue(row.Last().Value.HasAttribute(CellAttribute.Raw));
 }
Ejemplo n.º 41
0
 public void WaitUntilRepeatsExpectedValueCheck()
 {
     var row = new CellTree("wait until", "next count", "2");
     Invoke(row);
     Assert.AreEqual(fitSharp.Fit.Model.TestStatus.Right, row.Last().Value.GetAttribute(CellAttribute.Status));
 }
Ejemplo n.º 42
0
 public void ChecksExpectedValue()
 {
     var row = new CellTree("check", "stuff", "some stuff");
     Invoke(row);
     Assert.AreEqual(fitSharp.Fit.Model.TestStatus.Right, row.Last().Value.GetAttribute(CellAttribute.Status));
 }
Ejemplo n.º 43
0
 public void NameKeywordAssignsASymbol()
 {
     var row = new CellTree("name", "symbol", "stuff");
     Invoke(row);
     Assert.AreEqual("some stuff", processor.Get<Symbols>().GetValue("symbol"));
 }
Ejemplo n.º 44
0
 public void ExecutesFlowKeyword()
 {
     var row = new CellTree("akeyword");
     Evaluate(row, null);
     Assert.AreEqual("somevalue", TestInvokeSpecialAction.Field);
 }
Ejemplo n.º 45
0
 [SetUp] public void SetUp()
 {
     processor     = Builder.CellProcessor();
     includeAction = new IncludeAction(processor);
     parsedInput   = new CellTree(new CellBase(result), "something");
 }
 public RemoveRepeatGroup(CellTree cells) : base(cells.Root.Cell.Row, "Remove Repeat Group")
 {
     Cells = cells;
 }
Ejemplo n.º 47
0
 public void InvokesMethodInEachRow()
 {
     var table = new CellTree(new CellTree("configure", "processor"), new CellTree("teststatus"));
     fixture.Interpret(processor, table);
     Assert.AreEqual("fitSharp.Fit.Model.TestStatus", table.ValueAt(1, 0).GetAttribute(CellAttribute.Folded));
 }
Ejemplo n.º 48
0
 public void InvokesMethodInEachRow()
 {
     var table = new CellTree(new CellTree("configure", "processor"), new CellTree("tostring"));
     fixture.Interpret(processor, table);
     Assert.AreEqual("fitSharp.Fit.Service.CellProcessorBase", table.ValueAt(1, 0).GetAttribute(CellAttribute.Folded));
 }