public void Detach_NullPointerWorks()
        {
            //Act
            using (var target = new SafeHGlobalHandle())
            {
                var actual = target.Detach();

                //Assert
                actual.Should().BeZero();
                target.Pointer.Should().BeZero();
                target.IsInvalid.Should().BeTrue();
            };
        }
        public void Dispose_DetachedPointerWorks()
        {
            var ptr = AllocateMemory(10);

            try
            {
                //Act
                var target = new SafeHGlobalHandle(ptr);
                var actual = target.Detach();
                target.Dispose();

                //Assert - doesn't really confirm the memory was released
                target.Pointer.Should().BeZero();
                target.IsInvalid.Should().BeTrue();
            } finally
            {
                FreeMemory(ptr);
            };
        }
        public void Detach_ValidPointerWorks()
        {
            var ptr = AllocateMemory(50);

            try
            {
                //Act
                using (var target = new SafeHGlobalHandle(ptr))
                {
                    var actual = target.Detach();

                    //Assert
                    actual.Should().Be(ptr);
                    target.Pointer.Should().BeZero();
                    target.IsInvalid.Should().BeTrue();
                };
            } finally
            {
                FreeMemory(ptr);
            };
        }