public void CommentThenEof(string fileName) { var fileAsStream = DirStructure.IonTestFileAsStream(fileName); var reader = new UserTextReader(fileAsStream); Assert.AreEqual(IonType.Symbol, reader.MoveNext()); Assert.AreEqual("abc", reader.SymbolValue().Text); Assert.AreEqual(IonType.None, reader.MoveNext()); }
public void EolComment(string fileName) { var fileAsStream = DirStructure.IonTestFileAsStream(fileName); var reader = new UserTextReader(fileAsStream); Assert.AreEqual(IonType.List, reader.MoveNext()); reader.StepIn(); Assert.AreEqual(IonType.None, reader.MoveNext()); reader.StepOut(); Assert.AreEqual(IonType.None, reader.MoveNext()); }
public void TestBasicBool() { byte[] values = DirStructure.IonTestFileAsBytes("good/booleans.ion"); string str = Encoding.UTF8.GetString(values); var reader = new UserTextReader(str); reader.MoveNext(); Assert.AreEqual(true, reader.BoolValue()); var a = reader.MoveNext(); Assert.AreEqual(false, reader.BoolValue()); }
/// <summary> /// Deserialize a text format to object type T /// </summary> /// <param name="text">Text input</param> /// <param name="scalarConverter"></param> /// <typeparam name="T">Type of object to deserialize to</typeparam> /// <returns>Deserialized object</returns> public T Deserialize <T>(string text, IScalarConverter scalarConverter = null) { var reader = new UserTextReader(text); reader.MoveNext(); return((T)IonSerializationPrivate.Deserialize(reader, typeof(T), scalarConverter)); }
/// <summary> /// Deserialize a text format to object type T /// </summary> /// <param name="text">Text input</param> /// <typeparam name="T">Type of object to deserialize to</typeparam> /// <returns>Deserialized object</returns> public T Deserialize <T>(string text) { var reader = new UserTextReader(text); reader.MoveNext(); return((T)IonSerializationPrivate.Deserialize(reader, typeof(T))); }
public void EmptyBlob() { const string text = "{{}}"; var reader = new UserTextReader(text); Assert.AreEqual(IonType.Blob, reader.MoveNext()); }
public void Float_Underscore(string f, double val) { var reader = new UserTextReader(f); Assert.AreEqual(IonType.Float, reader.MoveNext()); Assert.AreEqual(val, reader.DoubleValue()); }
public void CurrentType() { var bin = Encoding.UTF8.GetBytes("true"); var reader = new UserTextReader(new MemoryStream(bin)); Assert.AreEqual(IonType.None, reader.CurrentType); reader.MoveNext(); Assert.AreEqual(IonType.Bool, reader.CurrentType); }