-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
ThreadPoolBoundHandle_DisposeTests.cs
42 lines (32 loc) · 1.36 KB
/
ThreadPoolBoundHandle_DisposeTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Threading;
using Xunit;
public partial class ThreadPoolBoundHandleTests
{
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void Dispose_CalledMultipleTimes_DoesNotThrow()
{
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();
boundHandle.Dispose();
boundHandle.Dispose();
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public void Dispose_DoesNotDisposeHandle()
{
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();
Assert.False(boundHandle.Handle.IsClosed);
boundHandle.Dispose();
Assert.False(boundHandle.Handle.IsClosed);
}
[Fact]
[PlatformSpecific(TestPlatforms.Windows)] // ThreadPoolBoundHandle.BindHandle is not supported on Unix
public unsafe void Dispose_WithoutFreeingNativeOverlapped_DoesNotThrow()
{
ThreadPoolBoundHandle boundHandle = CreateThreadPoolBoundHandle();
NativeOverlapped* overlapped = boundHandle.AllocateNativeOverlapped((_, __, ___) => { }, new object(), new byte[1024]);
boundHandle.Dispose();
}
}