public void SelfReferencingSKEMA() { string skema = @"define A: #A, A: #A,"; Assert.Throws <CouldNotSolveReferencesException>(() => ParseWithMetadata(skema)); skema = @"define A: { optional A: #A, }, A: #A,"; SKEMAObject obj = ParseWithMetadata(skema); string res = SKEMA.Write(obj); Console.WriteLine(res); SKEMAObject resObj = SKEMA.Parse(res); Assert.IsTrue(resObj == obj); skema = @"define A: { optional A: #A, optional B: #B, }, define B: #A, A: #A, "; obj = ParseWithMetadata(skema); res = SKEMA.Write(obj); Console.WriteLine(res); resObj = SKEMA.Parse(res); Assert.IsTrue(resObj == obj); }
public void WriteSKEMA() { string skema = @"define Color: { Red: Integer, Green: Integer, Blue: Integer, }, Colors: [ #Color ],"; SKEMAObject skemaObj = ParseWithMetadata(skema); string res = SKEMA.Write(skemaObj); SKEMAObject newSkemaObj = SKEMA.Parse(res); Assert.AreEqual(skemaObj, newSkemaObj); Console.WriteLine(res); skema = @"define Node: { Value: Any, optional Nodes: [ #Node ], }, Tree: #Node,"; skemaObj = ParseWithMetadata(skema); res = SKEMA.Write(skemaObj); newSkemaObj = SKEMA.Parse(res); //Assert.AreEqual(skemaObj, newSkemaObj); Console.WriteLine(res); }
private static SKEMAObject ParseWithMetadata(string skema) { return(SKEMA.Parse(metadataString + skema)); }