Esempio n. 1
0
        public IEnumerable <Action <IFixture> > GetSetupActions(Type type, string fixtureAction)
        {
            var method = type.GetMethod(
                fixtureAction,
                BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);

            if (method == null ||
                (method.ReturnType != typeof(Action <IFixture>) &&
                 method.ReturnType != typeof(IEnumerable <Action <IFixture> >)))
            {
                return(Enumerable.Empty <Action <IFixture> >());
            }

            var obj = method.Invoke(null, new object[] { });

            try
            {
                return(SetupActionsServices.ParseFixtureActionValue(obj));
            }
            catch (ArgumentNullException)
            {
                throw new ArgumentOutOfRangeException(
                          string.Format(
                              "Method {0} on {1} did not return IEnumerableAction<IFixture>> or Action<IFixture>",
                              fixtureAction,
                              type.FullName));
            }
        }
Esempio n. 2
0
        public IEnumerable <Action <IFixture> > GetSetupActions(Type type, string fixtureAction)
        {
            var property = type.GetProperty(
                fixtureAction,
                BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);

            if (property == null)
            {
                return(Enumerable.Empty <Action <IFixture> >());
            }

            var obj = property.GetValue(null);

            try
            {
                return(SetupActionsServices.ParseFixtureActionValue(obj));
            }
            catch (ArgumentNullException)
            {
                throw new ArgumentOutOfRangeException(
                          string.Format(
                              "Property {0} on {1} did not return IEnumerableAction<IFixture>> or Action<IFixture>",
                              fixtureAction,
                              type.FullName));
            }
        }