public FixtureInstanceTestHost(ReflectionTestFixtureBuilder builder)
     : base(TestPathType.Instance, null, TestPath.GetFriendlyName(builder.Type.AsType()),
            builder.Type.AsType(), builder.Type.AsType(),
            TestFlags.ContinueOnError | TestFlags.Hidden | TestFlags.PathHidden)
 {
     Builder = builder;
 }
 public ReflectionPropertyHost(ReflectionTestFixtureBuilder fixture,
                               PropertyInfo prop, ParameterizedTestHost host)
     : base(prop.Name, prop.PropertyType.GetTypeInfo(), host.Serializer, host.Flags)
 {
     Fixture  = fixture;
     Property = prop;
     Host     = host;
 }
 public ReflectionTestCaseBuilder(ReflectionTestFixtureBuilder fixture, AsyncTestAttribute attr, MethodInfo method)
     : base(TestSerializer.TestCaseIdentifier, method.Name, GetParameter(method))
 {
     Fixture   = fixture;
     Attribute = attr;
     Method    = method;
     filter    = ReflectionHelper.CreateTestFilter(fixture.Filter, ReflectionHelper.GetMethodInfo(method));
 }
示例#4
0
        internal static TestHost ResolveParameter(ReflectionTestFixtureBuilder builder, PropertyInfo member)
        {
            var host = ResolveParameter(builder, new _PropertyInfo(member));

            if (host != null)
            {
                return(host);
            }

            throw new InternalErrorException();
        }
示例#5
0
        static TestHost ResolveParameter(
            ReflectionTestFixtureBuilder fixture, IMemberInfo member)
        {
            if (typeof(ITestInstance).GetTypeInfo().IsAssignableFrom(member.Type))
            {
                var hostAttr = member.GetCustomAttribute <TestHostAttribute> ();
                if (hostAttr == null)
                {
                    hostAttr = member.Type.GetCustomAttribute <TestHostAttribute> ();
                }
                if (hostAttr == null)
                {
                    throw new InternalErrorException();
                }

                return(CreateCustomHost(fixture.Type, member, hostAttr));
            }

            var paramAttrs = member.GetCustomAttributes <TestParameterAttribute> ().ToArray();

            if (paramAttrs.Length == 1)
            {
                return(CreateParameterAttributeHost(fixture.Type, member, paramAttrs[0]));
            }
            else if (paramAttrs.Length > 1)
            {
                throw new InternalErrorException();
            }

            var typeAttr = GetCustomAttributeForType <TestParameterAttribute> (member.Type);

            if (typeAttr != null)
            {
                return(CreateParameterAttributeHost(fixture.Type, member, typeAttr));
            }

            if (member.Type.AsType().Equals(typeof(bool)))
            {
                return(CreateBoolean(member));
            }

            if (member.Type.IsEnum)
            {
                return(CreateEnum(member));
            }

            throw new InternalErrorException();
        }
示例#6
0
 internal static TestHost ResolveParameter(
     ReflectionTestFixtureBuilder builder, PropertyInfo member)
 {
     return(ResolveParameter(builder, new _PropertyInfo(member)));
 }
示例#7
0
 public FixtureInstanceTestHost(ReflectionTestFixtureBuilder builder)
     : base(TestSerializer.FixtureInstanceIdentifier, null, builder.Type.AsType(), builder.Type.AsType(),
            TestFlags.ContinueOnError | TestFlags.PathHidden | TestFlags.Hidden)
 {
     Builder = builder;
 }