Merge pull request #288 from mfcollins3/csharp-byte-buffer

Add Get Bytes Method Generator for C#
This commit is contained in:
Wouter van Oortmerssen
2015-12-07 17:35:57 -08:00
9 changed files with 70 additions and 12 deletions

View File

@@ -107,6 +107,14 @@ namespace FlatBuffers.Test
}
}
public static void IsFalse(bool value)
{
if (value)
{
throw new AssertFailedException(false, value);
}
}
public static void Throws<T>(Action action) where T : Exception
{
var caught = false;

View File

@@ -15,6 +15,7 @@
*/
using System.IO;
using System.Text;
using MyGame.Example;
namespace FlatBuffers.Test
@@ -184,6 +185,18 @@ namespace FlatBuffers.Test
Assert.AreEqual("test2", monster.GetTestarrayofstring(1));
Assert.AreEqual(false, monster.Testbool);
var nameBytes = monster.GetNameBytes().Value;
Assert.AreEqual("MyMonster", Encoding.UTF8.GetString(nameBytes.Array, nameBytes.Offset, nameBytes.Count));
if (0 == monster.TestarrayofboolsLength)
{
Assert.IsFalse(monster.GetTestarrayofboolsBytes().HasValue);
}
else
{
Assert.IsTrue(monster.GetTestarrayofboolsBytes().HasValue);
}
}
[FlatBuffersTestMethod]