Exemple #1
0
    public static IReflectionAttributeInfo CollectionBehaviorAttribute(
        CollectionBehavior?collectionBehavior = null,
        bool disableTestParallelization       = false,
        int maxParallelThreads = 0)
    {
        CollectionBehaviorAttribute attribute;
        var result = Substitute.For <IReflectionAttributeInfo, InterfaceProxy <IReflectionAttributeInfo> >();

        if (collectionBehavior.HasValue)
        {
            attribute = new CollectionBehaviorAttribute(collectionBehavior.GetValueOrDefault());
            result.GetConstructorArguments().Returns(new object[] { collectionBehavior });
        }
        else
        {
            attribute = new CollectionBehaviorAttribute();
            result.GetConstructorArguments().Returns(new object[0]);
        }

        attribute.DisableTestParallelization = disableTestParallelization;
        attribute.MaxParallelThreads         = maxParallelThreads;

        result.Attribute.Returns(attribute);
        result.GetNamedArgument <bool>("DisableTestParallelization").Returns(disableTestParallelization);
        result.GetNamedArgument <int>("MaxParallelThreads").Returns(maxParallelThreads);
        return(result);
    }
Exemple #2
0
    public static IReflectionAttributeInfo CollectionBehaviorAttribute(string factoryTypeName, string factoryAssemblyName, bool disableTestParallelization = false, int maxParallelThreads = 0)
    {
        var attribute = new CollectionBehaviorAttribute(factoryTypeName, factoryAssemblyName)
        {
            DisableTestParallelization = disableTestParallelization,
            MaxParallelThreads         = maxParallelThreads
        };
        var result = Substitute.For <IReflectionAttributeInfo, InterfaceProxy <IReflectionAttributeInfo> >();

        result.Attribute.Returns(attribute);
        result.GetNamedArgument <bool>("DisableTestParallelization").Returns(disableTestParallelization);
        result.GetNamedArgument <int>("MaxParallelThreads").Returns(maxParallelThreads);
        result.GetConstructorArguments().Returns(new object[] { factoryTypeName, factoryAssemblyName });
        return(result);
    }