Ejemplo n.º 1
0
        public static PropertyInitializationResult Initialize(
            Type testClassType,
            MethodInfo testMethodInfo,
            object[] constructorArguments,
            IPropertyFactory propertyFactory)
        {
            var testClassInstance = Activator.CreateInstance(testClassType, constructorArguments);
            var propertyAttribute = testMethodInfo.GetCustomAttributes <PropertyAttribute>(inherit: true).Single();

            var genFactory = TryResolveGenFactory(testClassType, testMethodInfo);
            var customGens = ResolveCustomGens(testClassInstance, testMethodInfo);
            var property   = propertyFactory.CreateProperty(testMethodInfo, testClassInstance, genFactory, customGens);
            var replay     = testMethodInfo.GetCustomAttributes <ReplayAttribute>().SingleOrDefault()?.Replay;

            var propertyRunParameters = new PropertyRunParameters(
                Property: property,
                Iterations: propertyAttribute.Iterations,
                ShrinkLimit: propertyAttribute.ShrinkLimit,
                Replay: replay,
                Seed: replay == null ? propertyAttribute.NullableSeed : null,
                Size: replay == null ? propertyAttribute.NullableSize : null);

            return(new PropertyInitializationResult(
                       propertyAttribute.Runner,
                       propertyRunParameters,
                       propertyAttribute.Skip?.Length > 0 ? propertyAttribute.Skip : null));
        }
Ejemplo n.º 2
0
 public void Run(PropertyRunParameters parameters, ITestOutputHelper testOutputHelper)
 {
     parameters.Property.Select(test => test.Cast <object>()).Assert(
         replay: parameters.Replay,
         seed: parameters.Seed,
         size: parameters.Size,
         iterations: parameters.Iterations,
         shrinkLimit: parameters.ShrinkLimit,
         formatReproduction: (newReplay) => $"{Environment.NewLine}    [Replay(\"{newReplay}\")]",
         formatMessage: (x) => Environment.NewLine + Environment.NewLine + x);
 }
Ejemplo n.º 3
0
        public void Run(PropertyRunParameters parameters, ITestOutputHelper testOutputHelper)
        {
            var log = new List <string>();

            parameters.Property.Advanced.Print(
                stdout: log.Add,
                seed: parameters.Seed,
                size: parameters.Size,
                iterations: parameters.Iterations);

            throw new SampleException(string.Join(Environment.NewLine, log));
        }