public CustomTestHost(string name, Type type, Type hostType, TestFlags flags, TestHostAttribute attr, bool useFixtureInstance) : base(name, name, type, hostType, flags) { HostType = hostType; Attribute = attr; UseFixtureInstance = useFixtureInstance; }
static Type GetCustomHostType( TypeInfo fixtureType, IMemberInfo member, TestHostAttribute attr, out bool useFixtureInstance) { var hostType = typeof(ITestHost <>).GetTypeInfo(); var genericInstance = hostType.MakeGenericType(member.Type.AsType()).GetTypeInfo(); if (attr.HostType != null) { if (!genericInstance.IsAssignableFrom(attr.HostType.GetTypeInfo())) { throw new InternalErrorException(); } useFixtureInstance = genericInstance.IsAssignableFrom(fixtureType); return(attr.HostType); } if (genericInstance.IsAssignableFrom(fixtureType)) { useFixtureInstance = true; return(null); } throw new InternalErrorException(); }
static TestHost CreateCustomHost(TypeInfo fixture, IMemberInfo member, TestHostAttribute attr) { bool useFixtureInstance; var hostType = GetCustomHostType(fixture, member, attr, out useFixtureInstance); return(new CustomTestHost(attr.Identifier ?? member.Name, member.Type.AsType(), hostType, attr.TestFlags, attr, useFixtureInstance)); }
public CustomTestHost(string name, Type type, Type hostType, TestFlags flags, TestHostAttribute attr, ITestHost <ITestInstance> staticHost, bool useFixtureInstance) : base(TestPathType.Parameter, name, name, type, hostType, flags) { HostType = hostType; Attribute = attr; StaticHost = staticHost; UseFixtureInstance = useFixtureInstance; }