コード例 #1
0
        public void IsNonBlocking_InitializedStream_ReturnsTrue()
        {
            byte[]            data   = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            NativeInputStream stream = NativeInputStream.Create(data);

            Assert.AreEqual(true, stream.IsNonBlocking());
        }
コード例 #2
0
        public void Available_InitializedStream_ReturnsNumberOfAvailableBytes()
        {
            byte[]            data   = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            NativeInputStream stream = NativeInputStream.Create(data);

            Assert.AreEqual(11, stream.Available());
        }
コード例 #3
0
        public void Read_InitializedStream_ShouldReturnCorrectResults()
        {
            byte[]            data   = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            NativeInputStream stream = NativeInputStream.Create(data);
            IntPtr            aBuf   = Marshal.AllocCoTaskMem(1);

            // Read first byte
            stream.Read(aBuf, 1);
            byte result = Marshal.ReadByte(aBuf);

            Assert.AreEqual(0, result);

            // Read second byte.
            stream.Read(aBuf, 1);
            result = Marshal.ReadByte(aBuf);
            Assert.AreEqual(1, result);

            Marshal.FreeCoTaskMem(aBuf);
        }