blob: f3fbc06f462653377bd18c1ae780b1976b3b1421 (
plain)
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
43
44
45
46
47
48
49
50
51
52
|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Runtime.InteropServices;
using Xunit;
public partial class CriticalHandle_4000_Tests
{
private class MyCriticalHandle : CriticalHandle
{
public MyCriticalHandle()
: base(IntPtr.Zero)
{
}
public MyCriticalHandle(IntPtr handle)
: this()
{
SetHandle(handle);
}
public override bool IsInvalid
{
get { return this.handle == IntPtr.Zero; }
}
public bool IsReleased { get; private set; }
protected override bool ReleaseHandle()
{
return this.IsReleased = true;
}
}
[Fact]
public static void CriticalHandle_invalid()
{
MyCriticalHandle mch = new MyCriticalHandle();
Assert.Equal(false, mch.IsClosed);
Assert.Equal(true, mch.IsInvalid);
}
[Fact]
public static void CriticalHandle_valid()
{
MyCriticalHandle mch = new MyCriticalHandle(new IntPtr(1));
Assert.Equal(false, mch.IsClosed);
Assert.Equal(false, mch.IsInvalid);
}
}
|