private TestTrace <TParserToCheck> TestParse <TTopParser, TParserToCheck>(string parseString) { var rtn = new TestTrace <TParserToCheck>(); var result = Lexico.Parse <TTopParser>(parseString, rtn); return(rtn); }
public void CanRetrieveUserObjectValueType() { var myUserObject = 3.14f; var obj = Lexico.Parse <ClassWithUserObject>("5", userObject: myUserObject); Assert.Equal(myUserObject, obj.UserObject); }
public void CanUseConcreteTypeForUserObject() { var myUserObject = 3.14f; var obj = Lexico.Parse <ClassWithConcreteUserObject>("5", userObject: myUserObject); Assert.Equal(myUserObject, obj.UserObject); }
public void CanRetrieveUserObject() { var myUserObject = new object(); var obj = Lexico.Parse <ClassWithUserObject>("5", userObject: myUserObject); Assert.Equal(myUserObject, obj.UserObject); }
public void LexicoJsonWithNoOpTrace() { var result = Lexico.Parse <JsonDocument>(JsonString, new NoTrace()); if (result.value == null) { throw new Exception("Parsing failed"); } }
public void WriteProtectedField() => Assert.Equal(5, Lexico.Parse <ProtectedField>("5").Val);
public void CannotWriteReadonlyField() => Assert.NotEqual(5, Lexico.Parse <ReadonlyField>("5").Value);
public void WritePrivateSetProperty() => Assert.Equal(5, Lexico.Parse <GetOnlyPropWithPrivateSet>("5").Value);
public void CannotWriteGetOnlyProperty() => Assert.NotEqual(5, Lexico.Parse <GetOnlyProp>("5").Value);
public void WrongUserObjectTypeThrowsCastException() { var myUserObject = 3; Assert.Throws <InvalidCastException>(() => Lexico.Parse <ClassWithConcreteUserObject>("5", userObject: myUserObject)); }
public void BadExplicitAlternativeType() { Assert.Throws <ArgumentException>(() => Lexico.Parse <TruthyWithInvalidAlternative>("true", new ConsoleDeveloperTrace())); }
regexPattern, config, flags); // TODO: Don't pass in regexPattern, retrieve it by unparsing public static IParser Parse(string pattern, IConfig config, ParserFlags flags) => Lexico.Parse <Regex>(pattern).Create(pattern, config, flags);
public void OrderOfGenericSequenceCorrect() => Lexico.Parse <GenericWrapper>(" 5 ", new ConsoleDeveloperTrace());
public void SeperatorWithinRepeatedRecursive() => Lexico.Parse <List <RecBase> >("foobar,bar") .Should() .ContainEquivalentOf(new Recursive { RecBase = { new LiteralCase(), new LiteralCase() } });
public void OptionalRepeatOfNothingReturnsNull() => Assert.Null(Lexico.Parse <OptionalRepeat>("[]").List);
public void GenericRepeatParser() => Assert.Equal(Lexico.Parse <GenericRepeat <int> >("(1, 1, 3, 5, 7)").Values, new [] { 1, 1, 3, 5, 7 });