public ExecutionDebugInfo(DaisyAst ast, DaisyMode mode) { _mode = mode; Ast = ast; _performanceCounter = mode == DaisyMode.Debug ? new PerformanceCounter() : NoopPerformanceCounter.Instance; measurements = new Lazy<PerformanceMeasurments>(() => PerformanceCounter.Measurments); }
public void AddLink(DaisyAst ast, string rawStatement, Func<int,bool> predicate) { var statement = new FakeStatement(rawStatement, predicate).Link(rawStatement); new AstCollector(ast) .OfType<StatementNode>() .Where(x => x.Text == rawStatement) .Select(x => { x.LinkedStatement = statement; return x; }) //Sigh, I wish I had a for each .ToList(); }
public void ItDiesOnFailureToLink() { var statementSet = new StatementSet(); var ast = new DaisyAst(new StatementNode("Hello gov'nor")); var load = new DaisyLinker(ast,statementSet,typeof(int)); var ex = Assert.Catch<FailedLinkException>(() => load.Link()); Assert.AreEqual(1, ex.Errors.Count); Assert.IsInstanceOf<NoLinksFoundError>(ex.Errors.First()); }
public void ItDiesOnLinkingGroupToNonGroup() { var linkedStatement1 = new Mock<ILinkedStatement>(); var statement = new Mock<IStatementDefinition>(); linkedStatement1.SetupGet(x => x.Definition).Returns(statement.Object); statement.Setup(x => x.Link(It.IsAny<string>())).Returns(linkedStatement1.Object); statement.SetupGet(x => x.Name).Returns("David"); statement.SetupGet(x => x.ScopeType).Returns(typeof(int)); statement.SetupGet(x => x.TransformsScopeTo).Returns((Type)null); var statementSet = new StatementSet().Add(statement.Object); var ast = new DaisyAst(new GroupOperatorNode("Hello gov'nor",new StatementNode("Blah"))); var load = new DaisyLinker(ast,statementSet,typeof(int)); var ex = Assert.Catch<FailedLinkException>(() => load.Link()); Assert.AreEqual(1, ex.Errors.Count); Assert.IsInstanceOf<NoLinksPermittedError>(ex.Errors.First()); }
public void ItDiesOnMultipleLinksFound() { var linkedStatement1 = new Mock<ILinkedStatement>(); var statement = new Mock<IStatementDefinition>(); linkedStatement1.SetupGet(x => x.Definition).Returns(statement.Object); statement.Setup(x => x.Link(It.IsAny<string>())).Returns(linkedStatement1.Object); statement.SetupGet(x => x.Name).Returns("David"); statement.SetupGet(x => x.ScopeType).Returns(typeof(int)); var linkedStatement2 = new Mock<ILinkedStatement>(); var statement2 = new Mock<IStatementDefinition>(); linkedStatement2.SetupGet(x => x.Definition).Returns(statement2.Object); statement2.Setup(x => x.Link(It.IsAny<string>())).Returns(linkedStatement2.Object); statement2.SetupGet(x => x.Name).Returns("Tennant"); statement2.SetupGet(x => x.ScopeType).Returns(typeof(int)); var statementSet = new StatementSet().Add(statement.Object).Add(statement2.Object); var ast = new DaisyAst(new StatementNode("Hello gov'nor")); var load = new DaisyLinker(ast,statementSet,typeof(int)); var ex = Assert.Catch<FailedLinkException>(() => load.Link()); Assert.AreEqual(1, ex.Errors.Count); Assert.IsInstanceOf<MultipleLinksFoundError>(ex.Errors.First()); }
private void AddAggregateLink(DaisyAst ast, string rawStatement) { var statement = new FakeAggregate<int,int>(rawStatement).Link(rawStatement); new AstCollector(ast) .OfType<StatementNode>() .Where(x => x.Text == rawStatement) .Select(x => { x.LinkedStatement = statement; return x; }) //Sigh, I wish I had a for each .ToList(); }
public DaisyExecution(DaisyAst ast, DaisyMode mode) { Attachments = new ContextBundle(); DebugInfo = new ExecutionDebugInfo(ast,mode); }
public void ItLinksStatements() { var linkedStatement = new Mock<ILinkedStatement>(); var statement = new Mock<IStatementDefinition>(); statement.Setup(x => x.Link(It.IsAny<string>())).Returns(linkedStatement.Object); statement.SetupGet(x => x.Name).Returns("Tennant"); statement.SetupGet(x => x.ScopeType).Returns(typeof(Int32)); var statementSet = new StatementSet().Add(statement.Object); var ast = new DaisyAst(new StatementNode("Hello gov'nor")); var load = new DaisyLinker(ast,statementSet,typeof(int)); load.Link(); statement.Verify(x => x.Link(It.IsAny<string>()), Times.Once()); }