Example #1
0
 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;
 }
Example #2
0
        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();
        }
Example #3
0
        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));
        }
Example #4
0
 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;
 }