示例#1
0
        public void Calculate_CorrectOperation_ShouldCallParserAndCalculatorEngine()
        {
            Operation         operation  = new Operation("test", new [] { 1d, 2d });
            IParser           parser     = new ParserStub(operation);
            ICalculatorEngine calculator = new CalculatorEngineStub(new Dictionary <Operation, double>
            {
                { operation, 42d }
            });

            var evaluator = new Evaluator(calculator, parser);

            Assert.That(evaluator.Calculate("any"), Is.EqualTo("42"));
        }
示例#2
0
        public void SimpleUrlPattern()
        {
            ParserSelecter selecter = new ParserSelecter(new ResourceFactoryStub(), new StatementFactoryStub());

            ParserStub             expectedParser = new ParserStub();
            ParserFactoryResponder factory        = new ParserFactoryResponder(expectedParser);

            selecter.RegisterUrlPattern("http://example.com/", factory);

            Parser selectedParser = selecter.GetParserForUrl("http://example.com/");

            Assert.AreSame(expectedParser, selectedParser, "Got expected parser");
        }