summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Loader/TestMember.cs
blob: 95eb0ec9356c0aebd682a2594476be2c7e162003 (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
using System.Collections.Generic;
using System.Reflection;
using NUnit.Framework;
using Xamarin.Forms.CustomAttributes;

namespace Xamarin.Forms.Loader
{
	internal sealed class TestMember : ILoaderElement
	{
		readonly IEnumerable<CategoryAttribute> categoryAttributes;

		readonly IEnumerable<UiTestAttribute> uiTestAttributes;

		public TestMember(TestType uiTestType, MemberInfo memberInfo)
		{
			DeclaringType = uiTestType;
			MemberInfo = memberInfo;

			// handle public overrides that inherit attributes
			uiTestAttributes = memberInfo.GetCustomAttributes<UiTestAttribute>();
			categoryAttributes = memberInfo.GetCustomAttributes<CategoryAttribute>();
		}

		internal FormsLoader FormsLoader
		{
			get { return DeclaringType.FormsLoader; }
		}

		public TestType DeclaringType { get; }

		public MemberInfo MemberInfo { get; }

		public IEnumerable<UiTestAttribute> UiTestAttributes()
		{
			return uiTestAttributes;
		}

		public IEnumerable<CategoryAttribute> CategoryAttributes()
		{
			return categoryAttributes;
		}
	}
}