public void ParseValue(string text, object expected) { var value = ValueParser.ParseValue(text); Assert.AreEqual( expected: expected, actual: value); }
public static Specification <TFact, TProjection> Match <TProjection>(Expression <Func <TFact, TProjection> > spec) { var parameter = spec.Parameters[0]; var initialFactName = parameter.Name; var initialFactType = parameter.Type.FactTypeName(); object proxy = SpecificationParser.InstanceOfFact(typeof(TFact)); var label = new Label(initialFactName, initialFactType); var context = SpecificationContext.Empty.With(label, proxy, parameter.Type); var startingSet = new SetDefinitionInitial(label, parameter.Type); var symbolTable = SymbolTable.Empty.With(initialFactName, new SymbolValueSetDefinition(startingSet)); var symbolValue = ValueParser.ParseValue(symbolTable, context, spec.Body).symbolValue; var result = SpecificationParser.ParseValue(symbolValue); var specification = SpecificationGenerator.CreateSpecification(context, result); return(new Specification <TFact, TProjection>(specification.Pipeline, specification.Projection)); }