public void Dispose_NullPointerWorks() { //Act var target = new SafeBStrHandle(); target.Dispose(); //Assert - No real way to confirm the memory was released target.Pointer.Should().BeZero(); target.IsInvalid.Should().BeTrue(); }
public void Dispose_ValidPointerWorks() { var ptr = AllocateMemory(10); //Act var target = new SafeBStrHandle(ptr); target.Dispose(); //Assert - No real way to confirm the memory was released target.Pointer.Should().BeZero(); target.IsInvalid.Should().BeTrue(); }
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); }; }