コード例 #1
0
ファイル: ExecutionDebugInfo.cs プロジェクト: Ancestry/Daisy
 public ExecutionDebugInfo(DaisyAst ast, DaisyMode mode)
 {
     _mode = mode;
     Ast = ast;
     _performanceCounter = mode == DaisyMode.Debug
         ? new PerformanceCounter()
         : NoopPerformanceCounter.Instance;
     measurements = new Lazy<PerformanceMeasurments>(() => PerformanceCounter.Measurments);
 }
コード例 #2
0
ファイル: DaisyProgramTests.cs プロジェクト: Ancestry/Daisy
 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();
 }
コード例 #3
0
ファイル: DaisyLinkerTest.cs プロジェクト: Ancestry/Daisy
 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());
 }
コード例 #4
0
ファイル: DaisyLinkerTest.cs プロジェクト: Ancestry/Daisy
        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());
        }
コード例 #5
0
ファイル: DaisyLinkerTest.cs プロジェクト: Ancestry/Daisy
        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());
        }
コード例 #6
0
ファイル: DaisyProgramTests.cs プロジェクト: Ancestry/Daisy
 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();
 }
コード例 #7
0
ファイル: DaisyExecution.cs プロジェクト: Ancestry/Daisy
 public DaisyExecution(DaisyAst ast, DaisyMode mode)
 {
     Attachments = new ContextBundle();
     DebugInfo = new ExecutionDebugInfo(ast,mode);
 }
コード例 #8
0
ファイル: DaisyLinkerTest.cs プロジェクト: Ancestry/Daisy
        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());
        }