public void TestSerializeSingletonStruct() { var byteStruct = new ByteStruct { a = 7 }; Expect.AreArraysEqual(new byte[] { 7 }, SerializableUtil.Serialize(byteStruct)); }
public void TestSerializeMultiStruct() { var byteStruct = new BytesStruct { a = 7, b = 3 }; Expect.AreArraysEqual(new byte[] { 7, 0, 3 }, SerializableUtil.Serialize(byteStruct)); }
public void TestSerializeClass() { var obj = new ByteType { a = 7 }; var bytes = SerializableUtil.Serialize(obj); Expect.AreArraysEqual(new byte[] { 7 }, bytes); }
public void TestRead() { var bytes = new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; var stream = new BytesViewStream(); stream.SetImpl(bytes, 1, 9); var readBytes = new byte[10]; var readCount = stream.Read(readBytes, 1, 9); Expect.AreEqual(7, readCount); Expect.AreArraysEqual(new byte[] { 2, 3, 4, 5, 6, 7, 8, 0, 0, 0 }, readBytes); }
public async Task TestToArray() { var collector = new AsyncCollector <string>(); var delay = new TaskCompletionSource(); collector.Add("foo"); collector.Add("bar"); collector.Add(delay.Task.ContinueWith(_ => "awaited")); var toArray = collector.ToArray(); collector.Clear(); delay.SetResult(); Expect.AreArraysEqual(new[] { "foo", "bar", "awaited" }, await toArray); }
public void TestGet1ParameterNameFromFunc() { Expect.AreArraysEqual(new[] { "test" }, CallbackUtil.GetParameterNames((byte test) => true)); }
public void TestGet2ParameterNamesFromFunc() { Expect.AreArraysEqual(new[] { "foo", "bar" }, CallbackUtil.GetParameterNames( (int foo, float bar) => true)); }