Пример #1
0
        public void Create_from_property_should_yield_items_from_lists(string property)
        {
            var prop = Property(property);
            var ctxt = SelfTestUtility.NewTestContext(new FakeTheory(fakeTestMethod), new FakeRunner());

            Assert.Equal(2, TestData.Create(ctxt, MemberAccessors.Property(prop)).Count());
        }
Пример #2
0
        public void Create_from_property_should_yield_singleton_return_type(string property)
        {
            var prop   = Property(property);
            var ctxt   = SelfTestUtility.NewTestContext(new FakeTheory(fakeTestMethod), new FakeRunner());
            var actual = TestData.Create(ctxt, MemberAccessors.Property(prop));

            Assert.Equal(1, actual.Count());
            Assert.Equal("420", actual.First()[0]);
        }
Пример #3
0
        public static ITestDataProvider FromPropertyInfo(PropertyInfo property)
        {
            if (property == null)
            {
                throw new ArgumentNullException(nameof(property));
            }
            var accessor = MemberAccessors.Property(property);

            return(FromMemberAccessor(accessor));
        }
Пример #4
0
        IEnumerable <TestData> ITestDataProvider.GetData(TestContext context)
        {
            TestUnit unit          = context.TestUnit;
            var      declaringType = ((TestTheory)unit).TestMethod.DeclaringType;
            var      all           = new List <IMemberAccessor>();

            foreach (var p in _properties)
            {
                var prop = declaringType.GetProperty(p, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
                if (prop == null)
                {
                    throw SpecFailure.CannotFindDataProperty(p);
                }

                if (prop.GetMethod == null)
                {
                    throw SpecFailure.DataPropertyIncorrectGetter();
                }
                all.Add(MemberAccessors.Property(prop));
            }
            return(this.WithNames(TestDataProvider.FromMemberAccessors(all).GetData(context), _tags.TestTags));
        }