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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
// 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 Xunit;
namespace System.Reflection.Tests
{
public class FieldInfoIsFamily
{
private BindingFlags _allFlags = BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static;
#pragma warning disable 169
#pragma warning disable 649
static private int s_field1;
static public string Field2;
static protected int Field3;
static internal string Field4;
static protected internal int Field5;
private int _field6;
public string Field7;
protected int Field8;
internal string Field9;
protected internal int Field10;
public string Field11;
#pragma warning restore 169
#pragma warning restore 649
[Fact]
public void PosTest1()
{
PosTest(typeof(FieldInfoIsFamily).GetField("s_field1", _allFlags), false, "00A");
}
[Fact]
public void PosTest2()
{
PosTest(typeof(FieldInfoIsFamily).GetField("Field2", _allFlags), false, "00B");
}
[Fact]
public void PosTest3()
{
PosTest(typeof(FieldInfoIsFamily).GetField("Field3", _allFlags), true, "00C");
}
[Fact]
public void PosTest4()
{
PosTest(typeof(FieldInfoIsFamily).GetField("Field4", _allFlags), false, "00D");
}
[Fact]
public void PosTest5()
{
PosTest(typeof(FieldInfoIsFamily).GetField("Field5", _allFlags), false, "00E");
}
[Fact]
public void PosTest6()
{
PosTest(typeof(FieldInfoIsFamily).GetField("_field6", _allFlags), false, "00F");
}
[Fact]
public void PosTest7()
{
PosTest(typeof(FieldInfoIsFamily).GetField("Field7", _allFlags), false, "00G");
}
[Fact]
public void PosTest8()
{
PosTest(typeof(FieldInfoIsFamily).GetField("Field8", _allFlags), true, "00H");
}
[Fact]
public void PosTest9()
{
PosTest(typeof(FieldInfoIsFamily).GetField("Field9", _allFlags), false, "00I");
}
[Fact]
public void PosTest10()
{
PosTest(typeof(FieldInfoIsFamily).GetField("Field10", _allFlags), false, "00J");
}
[Fact]
public void PosTest11()
{
PosTest(typeof(FieldInfoIsFamily).GetField("Field11", _allFlags), false, "00K");
}
private void PosTest(FieldInfo fi, bool expected, string id)
{
bool actual = fi.IsFamily;
Assert.Equal(expected, actual);
}
}
}
|