mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-27 20:08:06 +00:00
Merge pull request #288 from mfcollins3/csharp-byte-buffer
Add Get Bytes Method Generator for C#
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user