Exemplo n.º 1
0
        public void Detach_NullPointerWorks()
        {
            //Act
            using (var target = new SafeBStrHandle())
            {
                var actual = target.Detach();

                //Assert
                target.Pointer.Should().BeZero();
                target.IsInvalid.Should().BeTrue();
                actual.Should().BeZero();
            };
        }
Exemplo n.º 2
0
        public void Detach_ValidPointerWorks()
        {
            var expected = AllocateMemory(10);

            //Act
            using (var target = new SafeBStrHandle(expected))
            {
                var actual = target.Detach();

                //Assert
                target.Pointer.Should().BeZero();
                target.IsInvalid.Should().BeTrue();
                actual.Should().Be(expected);
            };
        }
Exemplo n.º 3
0
        public void Dispose_DetachedPointerWorks()
        {
            var ptr = AllocateMemory(10);

            try
            {
                //Act
                var target = new SafeBStrHandle(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);
            };
        }