From e045fc2dce38d18059a67fa389148417f792134f Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sun, 24 Jul 2022 23:13:41 +0200 Subject: [PATCH] Add unit test for InteropServices APIs with disposed device --- .../DeviceDisposalTests.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs index c2ec6e2c..113429b1 100644 --- a/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs +++ b/tests/ComputeSharp.Tests.DeviceLost/DeviceDisposalTests.cs @@ -1,4 +1,5 @@ -using ComputeSharp.Interop; +using System; +using ComputeSharp.Interop; using ComputeSharp.Tests.Attributes; using ComputeSharp.Tests.Extensions; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -58,6 +59,20 @@ public class DeviceDisposalTests Assert.AreEqual(refCount, 1u); } + [CombinatorialTestMethod] + [AllDevices] + [ExpectedException(typeof(ObjectDisposedException))] + public unsafe void DeviceDisposal_InteropServicesThrowsObjectDisposedException(Device device) + { + using ComPtr d3D12Device = default; + + GraphicsDevice graphicsDevice = device.Get(); + + graphicsDevice.Dispose(); + + InteropServices.GetID3D12Device(graphicsDevice, Windows.__uuidof(), (void**)d3D12Device.GetAddressOf()); + } + [CombinatorialTestMethod] [AllDevices] public unsafe void DeviceDisposal_DisposedResources_ReferenceCounting(Device device)