void SetUpSUT(string memberName) { this.memberName = memberName; testStatus = new TestStatus(); processor = new Mock <CellProcessor>(); execute = new ExecuteDefault { Processor = processor.Object }; check = new CheckDefault { Processor = processor.Object }; memory = new TypeDictionary(); target = new TypedValue("target"); result = new TypedValue("result"); targetCell = new CellTreeLeaf("stuff"); processor .Setup(p => p.Parse(typeof(MemberName), It.IsAny <TypedValue>(), It.Is <CellTreeLeaf>(c => c.Text == memberName))) .Returns(new TypedValue(new MemberName(memberName))); processor .Setup(p => p.Invoke(target, It.Is <MemberName>(m => m.Name == "member"), It.Is <Tree <Cell> >(c => c.Branches.Count == 0))) .Returns(result); processor .Setup(p => p.Invoke(It.Is <TypedValue>(v => v.ValueString == "target"), It.Is <MemberName>(m => m.Name == "procedure"), It.IsAny <Tree <Cell> >())) .Returns((TypedValue t, MemberName m, Tree <Cell> c) => { testStatus.Counts.AddCount(TestStatus.Right); testStatus.LastAction = "blah blah"; return(result); }); processor.Setup(p => p.Compare(It.IsAny <TypedValue>(), It.IsAny <Tree <Cell> >())).Returns(true); processor.Setup(p => p.TestStatus).Returns(testStatus); processor.Setup(p => p.Memory).Returns(memory); }
public Tree <Cell> Compose(TypedValue instance) { var cell = new CellTreeLeaf("stuff"); cell.Value.SetAttribute(CellAttribute.Add, string.Empty); return(cell); }
public void AddsSymbolValueToCellAttributes() { var cell = new CellTreeLeaf("<<symbol"); var processor = new CellProcessorBase(); processor.Store(new Symbol("symbol", "value")); new ParseSymbol{Processor = processor}.Parse(typeof (string), TypedValue.Void, cell); Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix)); }
private static void ParseCell(string cellContent, string symbolName) { var cell = new CellTreeLeaf(cellContent); var processor = Builder.CellProcessor(); processor.Get<Symbols>().Save(symbolName, "value"); new ParseSymbol{Processor = processor}.Parse(typeof (string), TypedValue.Void, cell); Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix)); }
public void CopiesAttributes() { var source = new CellTreeLeaf("leaf"); source.Value.SetAttribute(CellAttribute.Label, "mylabel"); var result = copy.Make(source); source.Value.SetAttribute(CellAttribute.Label, "other"); Assert.AreEqual("leaf,Label:mylabel[]", Write(result)); }
[Test] public void ParseAddsInformationSuffix() { Parser.Processor.Get <Symbols>().Save("symbol", "value"); var cell = new CellTreeLeaf("<<symbol"); Parser.Parse(typeof(string), TypedValue.Void, cell); Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix)); }
public void CopiesBranches() { var source = new CellTreeLeaf("root"); source.AddBranchValue(new CellTreeLeaf("leafa")); source.AddBranchValue(new CellTreeLeaf("leafb")); var result = copy.Make(source); source.Branches[0].Add(new CellTreeLeaf("extra")); Assert.AreEqual("root[leafa[];leafb[]]", Write(result)); }
public void DoesNotSubstituteWithinSubstitutes() { var source = new CellTreeLeaf("root"); source.AddBranchValue(new CellTreeLeaf("leafa")); source.AddBranchValue(new CellTreeLeaf("leafb")); var result = copy.Make(source, original => original.Value != null && original.Value.Text == "leafa" ? new CellTree("new", "leafa") : null); source.Branches[0].Add(new CellTreeLeaf("extra")); Assert.AreEqual("root[null[new[];leafa[]];leafb[]]", Write(result)); }
private static void ParseCell(string cellContent, string symbolName) { var cell = new CellTreeLeaf(cellContent); var processor = Builder.CellProcessor(); processor.Get <Symbols>().Save(symbolName, "value"); new ParseSymbol { Processor = processor }.Parse(typeof(string), TypedValue.Void, cell); Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix)); }
[Test] public void CachesParsedValue() { var cell = new CellTreeLeaf("<<symbol"); var processor = Builder.CellProcessor(); processor.Get<Symbols>().Save("symbol", "value"); TypedValue result = processor.Parse(typeof (string), TypedValue.Void, cell); Assert.AreEqual("value", result.GetValue<string>()); Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix)); processor.Parse(typeof (string), TypedValue.Void, cell); Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix)); Assert.AreEqual("value", result.GetValue<string>()); }
[Test] public void CachesParsedValue() { var cell = new CellTreeLeaf("<<symbol"); var processor = new CellProcessorBase(); processor.Store(new Symbol("symbol", "value")); TypedValue result = processor.Parse(typeof(string), TypedValue.Void, cell); Assert.AreEqual("value", result.GetValue <string>()); Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix)); processor.Parse(typeof(string), TypedValue.Void, cell); Assert.AreEqual(" value", cell.Value.GetAttribute(CellAttribute.InformationSuffix)); Assert.AreEqual("value", result.GetValue <string>()); }
void SetUpSUT(string memberName) { this.memberName = memberName; testStatus = new TestStatus(); processor = new Mock<CellProcessor>(); invoke = new InvokeOperationDefault {Processor = processor.Object}; check = new CheckOperationDefault {Processor = processor.Object}; target = new TypedValue("target"); result = new TypedValue("result"); targetCell = new CellTreeLeaf("stuff"); processor .Setup(p => p.Parse(typeof (MemberName), It.IsAny<TypedValue>(), It.Is<CellTreeLeaf>(c => c.Text == memberName))) .Returns(new TypedValue(new MemberName(memberName))); processor .Setup(p => p.Invoke(target, "member", It.Is<Tree<Cell>>(c => c.Branches.Count == 0))) .Returns(result); processor .Setup(p => p.Invoke(It.Is<TypedValue>(v => v.ValueString == "target"), "procedure", It.IsAny<Tree<Cell>>())) .Returns((TypedValue t, string s, Tree<Cell> c) => { testStatus.Counts.AddCount(TestStatus.Right); testStatus.LastAction = "blah blah"; return result; }); processor.Setup(p => p.Compare(It.IsAny<TypedValue>(), It.IsAny<Tree<Cell>>())).Returns(true); processor.Setup(p => p.TestStatus).Returns(testStatus); }