[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"))); }
[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)); }
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)); }
[Test] public void NameKeywordAssignsASymbol() { var row = new CellTree("name", "symbol", "stuff"); Invoke(row); Assert.AreEqual("some stuff", processor.Get <Symbols>().GetValue("symbol")); }
[Test] public void ShowAsKeywordComposesWithAttributes() { var row = new CellTree("show as", "raw", "stuff"); Invoke(row); Assert.IsTrue(row.Last().Value.HasAttribute(CellAttribute.Raw)); }
[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); }
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); }
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)); }
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)); }
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")); }
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]); }
[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)); }
[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)); }
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); } }
[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]); }
[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)); }
[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"))); }
[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"); }
[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"); }
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")); }
protected override void Transformation() { foreach (Cell c in Cells) { c.Value = NewValue; } Cells = null; }
[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)); }
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 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)); }
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; }
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.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; }
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()); }
/// <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; }
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)); }
public AddRepeatGroup(Repeat repeat, CellTree cells) : base(repeat, cells, "Add Repeat Group") { }
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)); }
TypedValue Invoke(CellTree row) { var keyword = row.Branches[0].Value.Text; return keywords.InvokeSpecial(interpreter, new MemberName(keyword), row); }
public void ShowAsKeywordComposesWithAttributes() { var row = new CellTree("show as", "raw", "stuff"); Invoke(row); Assert.IsTrue(row.Last().Value.HasAttribute(CellAttribute.Raw)); }
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)); }
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 NameKeywordAssignsASymbol() { var row = new CellTree("name", "symbol", "stuff"); Invoke(row); Assert.AreEqual("some stuff", processor.Get<Symbols>().GetValue("symbol")); }
[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; }
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)); }
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)); }