Exemple #1
0
        public void TestSerializeSingletonStruct()
        {
            var byteStruct = new ByteStruct {
                a = 7
            };

            Expect.AreArraysEqual(new byte[] { 7 },
                                  SerializableUtil.Serialize(byteStruct));
        }
Exemple #2
0
        public void TestSerializeMultiStruct()
        {
            var byteStruct = new BytesStruct {
                a = 7, b = 3
            };

            Expect.AreArraysEqual(new byte[] { 7, 0, 3 },
                                  SerializableUtil.Serialize(byteStruct));
        }
Exemple #3
0
        public void TestSerializeClass()
        {
            var obj = new ByteType {
                a = 7
            };
            var bytes = SerializableUtil.Serialize(obj);

            Expect.AreArraysEqual(new byte[] { 7 }, bytes);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        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);
        }
Exemple #6
0
 public void TestGet1ParameterNameFromFunc()
 {
     Expect.AreArraysEqual(new[] { "test" },
                           CallbackUtil.GetParameterNames((byte test) => true));
 }
Exemple #7
0
 public void TestGet2ParameterNamesFromFunc()
 {
     Expect.AreArraysEqual(new[] { "foo", "bar" },
                           CallbackUtil.GetParameterNames(
                               (int foo, float bar) => true));
 }