public void It_should_marshal_native_memory_to_JS()
        {
            var ptr = Marshal.AllocHGlobal(4);

            Marshal.WriteByte(ptr, 0, 1);
            Marshal.WriteByte(ptr, 1, 2);
            Marshal.WriteByte(ptr, 2, 3);
            Marshal.WriteByte(ptr, 3, 4);
            using var memory = NativeMemory.Create(ptr, 4, (pointer, _) => Marshal.FreeHGlobal(pointer));
            Global.testObject.assertByteArray(memory);
        }
        public void It_should_directly_access_array_buffer_created_from_dotnet_memory()
        {
            var ptr = Marshal.AllocHGlobal(4);

            Marshal.WriteByte(ptr, 0, 1);
            Marshal.WriteByte(ptr, 1, 2);
            Marshal.WriteByte(ptr, 2, 3);
            Marshal.WriteByte(ptr, 3, 4);
            using var memory = NativeMemory.Create(ptr, 4, (pointer, _) => Marshal.FreeHGlobal(pointer));
            var jsArray = Global.Uint8Array.CreateNewInstance(memory);

            using var arrayBuffer = (ArrayBuffer)jsArray.buffer;

            Global.testObject.assertByteArray(jsArray);
            arrayBuffer.ByteLength.Should().Be(4);
            Marshal.ReadByte(arrayBuffer.Address, 0).Should().Be(1);
            Marshal.ReadByte(arrayBuffer.Address, 3).Should().Be(4);

            // TODO: Why is this not true?
            //Marshal.WriteByte(ptr, 0, 5);
            //Marshal.ReadByte(arrayBuffer.Address, 0).Should().Be(5);
            //arrayBuffer.Address.Should().Be(ptr);
        }