public void ReadString() { Init("A\0SFString\0ATest"); Connect.Field field = connection.Read(); Assert.AreEqual("A", field.Name); Assert.IsInstanceOfType(typeof(Connect.StringField), field); Assert.AreEqual("ATest", ((Connect.StringField)field).Value); }
public void ReadInteger() { Init("A\0SFInt\042\n"); Connect.Field field = connection.Read(); Assert.AreEqual("A", field.Name); Assert.IsInstanceOfType(typeof(Connect.IntField), field); Assert.AreEqual(42, ((Connect.IntField)field).Value); }
public void ReadDouble() { Init("A\0SFDouble\01.2\n"); Connect.Field field = connection.Read(); Assert.AreEqual("A", field.Name); Assert.IsInstanceOfType(typeof(Connect.DoubleField), field); Assert.AreEqual(1.2, ((Connect.DoubleField)field).Value, 0.00001); }
public void ReadBool() { Init("A\0SFBool\01\n"); Connect.Field field = connection.Read(); Assert.AreEqual("A", field.Name); Assert.IsInstanceOfType(typeof(Connect.BoolField), field); Assert.AreEqual(true, ((Connect.BoolField)field).Value); }
public void ReadMultiString() { Init("A\0MFString\0ATest\0Another Test\n"); Connect.Field field = connection.Read(); Assert.AreEqual("A", field.Name); Assert.IsInstanceOfType(typeof(Connect.MultiStringField), field); string[] value_ = { "ATest", "Another Test" }; Assert.AreEqual(value_, ((Connect.MultiStringField)field).Value); }
public void ReadMultiVec3() { Init("A\0MFVec3\01.1\01.2\01.3\02.1\02.2\02.3\n"); Connect.Field field = connection.Read(); Assert.AreEqual("A", field.Name); Assert.IsInstanceOfType(typeof(Connect.MultiVec3Field), field); double[,] value_ = { { 1.1, 1.2, 1.3 }, { 2.1, 2.2, 2.3 } }; AssertVectorsAreEqual(value_, ((Connect.MultiVec3Field)field).Value); }
public void ReadFieldsFromFile() { StreamReader reader = new StreamReader(Environment.GetEnvironmentVariable("TEST_DATA_PATH") + "/fielddata", new ASCIIEncoding()); Connect.Connection connection = new Connect.Connection(reader, writer); Connect.Field field = connection.Read(); Assert.AreEqual("A", field.Name); Assert.IsInstanceOfType(typeof(Connect.IntField), field); Assert.AreEqual(42, ((Connect.IntField)field).Value); field = connection.Read(); Assert.AreEqual("B", field.Name); Assert.IsInstanceOfType(typeof(Connect.StringField), field); Assert.AreEqual("Another one.", ((Connect.StringField)field).Value); field = connection.Read(); Assert.AreEqual("C", field.Name); Assert.IsInstanceOfType(typeof(Connect.MultiStringField), field); string[] value_ = { "Another one.", "Two" }; Assert.AreEqual(value_, ((Connect.MultiStringField)field).Value); }
public void Write(Field field) { WriteHeader(field); WriteBody(field); Flush(); }
void WriteBody(Field field) { field.Write(writer); }
void WriteHeader(Field field) { writer.Write(field.Name); writer.Write("\0"); }