public void Serialize_WithTestTableWithTable_CanBeReadByOracle() { const int intProp = 42; const byte byteProp = 22; const short shortProp = 62; var serializer = new FlatBuffersSerializer(); var testTable = new TestTable1() { IntProp = intProp, ShortProp = shortProp, ByteProp = byteProp }; var obj = new TestTableWithTable() { TableProp = testTable, IntProp = 1024 }; var buffer = new byte[256]; serializer.Serialize(obj, buffer, 0, buffer.Length); var oracle = new SerializationTestOracle(); var oracleResult = oracle.ReadTestTableWithTable(buffer); Assert.AreEqual(obj.IntProp, oracleResult.IntProp); Assert.AreEqual(obj.TableProp.IntProp, oracleResult.TableProp.IntProp); Assert.AreEqual(obj.TableProp.ByteProp, oracleResult.TableProp.ByteProp); Assert.AreEqual(obj.TableProp.ShortProp, oracleResult.TableProp.ShortProp); }
public void Oracle_WithTestTableWithTable_CanReadGeneratedData() { const int intProp = 42; const byte byteProp = 22; const short shortProp = 62; var testTable = new TestTable1() { IntProp = intProp, ShortProp = shortProp, ByteProp = byteProp }; var obj = new TestTableWithTable() { TableProp = testTable, IntProp = 1024 }; var oracle = new SerializationTestOracle(); var buffer = oracle.GenerateTestTableWithTable(testTable, 1024); var oracleResult = oracle.ReadTestTableWithTable(buffer); Assert.AreEqual(obj.IntProp, oracleResult.IntProp); Assert.AreEqual(obj.TableProp.IntProp, oracleResult.TableProp.IntProp); Assert.AreEqual(obj.TableProp.ByteProp, oracleResult.TableProp.ByteProp); Assert.AreEqual(obj.TableProp.ShortProp, oracleResult.TableProp.ShortProp); }
public TestTableWithTable ReadTestTableWithTable(byte[] buffer) { var test = SerializationTests.TestTableWithTable.GetRootAsTestTableWithTable(new ByteBuffer(buffer)); var result = new TestTableWithTable() { IntProp = test.IntProp, }; if (test.TableProp != null) { result.TableProp = new TestTable1() { IntProp = test.TableProp.IntProp, ByteProp = test.TableProp.ByteProp, ShortProp = test.TableProp.ShortProp, }; } return(result); }