public static void ExecuteStep(MethodInfo specificationStep, Fixture context) { var isAsync = specificationStep.IsAsync(); object invocationResult; try { invocationResult = specificationStep.Invoke(context.Instance, null); } catch (TargetInvocationException exception) { throw new PreservedException(exception.InnerException); } if (isAsync) { var task = (Task)invocationResult; try { task.Wait(); } catch (AggregateException exception) { throw new PreservedException(exception.InnerExceptions.First()); } } }
public void Execute(Fixture context, Action next) { var fixture = new Ploeh.AutoFixture.Fixture().Customize(new AutoConfiguredNSubstituteCustomization()); context.Instance.GetType().TryInvoke("FixtureSetup", context.Instance, new object[] { fixture }); next(); context.Instance.GetType().TryInvoke("FixtureTearDown", context.Instance); }
public void Execute(Fixture context, Action next) { var registry = new Ploeh.AutoFixture.Fixture().Customize(new AutoNSubstituteCustomization()); Func<int> randomValue = () => { var rand = new Random((int)DateTime.Now.Ticks); return rand.Next(40, 100); }; registry.Customize<Customer>(x => x.With(p => p.Age, randomValue.Invoke())); context.TryField("Registry", registry); next(); }
void InjectFixtureData(Fixture fixture) { foreach (var injectionMethod in fixtures.Keys) injectionMethod.Invoke(fixture.Instance, new[] { fixtures[injectionMethod] }); }
public void Execute(Fixture context, Action next) { DeleteAllData(); next(); }
public void Execute(Fixture context, Action next) { var specificationSteps = context.Class.Type.GetMethods() .Where(stepSelector) .OrderBy(method => method, DeclarationOrderComparer.Default); foreach (var specificationStep in specificationSteps) { ExecuteStep(specificationStep, context); } next?.Invoke(); }
public void Execute(Fixie.Fixture fixture, Action next) { fixture.Class.Type.InvokeAll <TestFixtureSetUpAttribute>(fixture.Instance); next(); fixture.Class.Type.InvokeAll <TestFixtureTearDownAttribute>(fixture.Instance); }