コード例 #1
0
        public static ITestDataProvider FromFieldInfo(FieldInfo field)
        {
            if (field == null)
            {
                throw new ArgumentNullException(nameof(field));
            }
            var accessor = MemberAccessors.Field(field);

            return(FromMemberAccessor(accessor));
        }
コード例 #2
0
        IEnumerable <TestData> ITestDataProvider.GetData(TestContext context)
        {
            TestUnit unit          = context.TestUnit;
            var      declaringType = ((TestTheory)unit).TestMethod.DeclaringType;
            var      all           = new List <IMemberAccessor>();

            foreach (var f in _fields)
            {
                var fld = declaringType.GetField(f, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                if (fld == null)
                {
                    throw SpecFailure.CannotFindDataField(f);
                }
                all.Add(MemberAccessors.Field(fld));
            }
            return(this.WithNames(TestDataProvider.FromMemberAccessors(all).GetData(context), _tags.TestTags));
        }