public UnitExpressionParserTests() { var unitRegistry = new UnitRegistry(); this.lexicalAnalyzer = A.Fake <ILexicalAnalyzer>(); this.testee = new UnitExpressionParser(unitRegistry, this.lexicalAnalyzer); }
/// <summary> /// Creates the parser. /// </summary> /// <param name="unitRegistry">The unit registry.</param> /// <returns> /// A new <see cref="IExpressionParser" />. /// </returns> public IExpressionParser CreateParser(IUnitRegistry unitRegistry) { var tokenMatcherBuilder = new TokenMatcherBuilder(); var prefixTokenMatchers = tokenMatcherBuilder.Build(unitRegistry.GetPrefixNotations(), true); var unitTokenMatchers = tokenMatcherBuilder.Build(unitRegistry.GetUnitNotations(), false); var unitExpressionParser = new UnitExpressionParser( unitRegistry, new LexicalAnalyzer(new[] { prefixTokenMatchers, unitTokenMatchers })); return(new ExpressionParser(unitExpressionParser)); }