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); }
[Test] public void ExecuteDefaultReturnsException() { var executeDefault = new ExecuteDefault(); var input = new TreeList <string>().AddBranchValue("step").AddBranchValue("garbage"); ExecuteOperation(executeDefault, input, 2); CheckForException("message<<MALFORMED_INSTRUCTION step,garbage>>"); }
[Test] public void ExecuteDefaultReturnsException() { var executeDefault = new ExecuteDefault { Processor = processor }; var input = new SlimTree().AddBranchValue("step").AddBranchValue("garbage"); ExecuteOperation(executeDefault, input, 2); CheckForException("message:<<MALFORMED_INSTRUCTION step,garbage>>"); }