-
Notifications
You must be signed in to change notification settings - Fork 4.6k
/
CustomPropertyInfoTests.cs
34 lines (30 loc) · 1.38 KB
/
CustomPropertyInfoTests.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
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.Collections.Generic;
using System.Linq;
using Xunit;
namespace System.Reflection.Context.Tests
{
public class CustomPropertyInfoTests
{
// Points to a PropertyInfo instance created by reflection. This doesn't work in a reflection-only context.
private readonly PropertyInfo _customProperty;
public CustomPropertyInfoTests()
{
var customReflectionContext = new TestCustomReflectionContext();
TypeInfo typeInfo = typeof(TestObject).GetTypeInfo();
TypeInfo customTypeInfo = customReflectionContext.MapType(typeInfo);
IEnumerable<PropertyInfo> customProperties = customTypeInfo.DeclaredProperties;
_customProperty = customProperties.First();
}
[Fact]
public void GetCustomAttributesDataTest()
{
// CustomAttributesData operates on custom attributes themselves defined in code
// that is loaded in the reflection-only context.
IList<CustomAttributeData> customAttributesData = _customProperty.GetCustomAttributesData();
Assert.All(customAttributesData,
cad => Assert.Equal(ProjectionConstants.ProjectingCustomAttributeData, cad.GetType().FullName));
}
}
}