public static void Execute(SpecificationPrimitive <Action> primitive) { Debug.Assert(primitive.ActionDelegate != null); if (primitive.TimeoutMs > 0) { #if SILVERLIGHT IAsyncResult asyncResult = AsyncDelegatesCompatibility.WorkingBeginInvoke(primitive.ActionDelegate, null, null); #else IAsyncResult asyncResult = primitive.ActionDelegate.BeginInvoke(null, null); #endif if (!asyncResult.AsyncWaitHandle.WaitOne(primitive.TimeoutMs)) { throw new Xunit.Sdk.TimeoutException(primitive.TimeoutMs); } else { #if SILVERLIGHT primitive.ActionDelegate.WorkingEndInvoke(asyncResult); #else primitive.ActionDelegate.EndInvoke(asyncResult); #endif } } else { primitive.ActionDelegate(); } }
private static void Reset() { _exceptions = new List <Action>(); _context = null; _do = null; _asserts = new List <SpecificationPrimitive <Action> >(); _observations = new List <SpecificationPrimitive <Action> >(); _skips = new List <SpecificationPrimitive <Action> >(); }
public static ISpecificationPrimitive Todo(string message, Action skippedAction) { EnsureThreadStaticInitialized(); SpecificationPrimitive <Action> skip = new SpecificationPrimitive <Action>(message, skippedAction); _skips.Add(skip); return(skip); }
public static ISpecificationPrimitive Observation(string message, Action observationAction) { EnsureThreadStaticInitialized(); var observation = new SpecificationPrimitive <Action>(message, observationAction); _observations.Add(observation); return(observation); }
public static ISpecificationPrimitive Assert(string message, Action assertAction) { EnsureThreadStaticInitialized(); SpecificationPrimitive <Action> assert = new SpecificationPrimitive <Action>(message, assertAction); _asserts.Add(assert); return(assert); }
public static ISpecificationPrimitive Do(string message, Action doAction) { EnsureThreadStaticInitialized(); if (_do == null) { _do = new SpecificationPrimitive <Action>(message, doAction); } else { _exceptions.Add(() => { throw new InvalidOperationException("Cannot have more than one Do statement in a specification"); }); } return(_do); }
public static ISpecificationPrimitive Context(string message, ContextDelegate arrange) { EnsureThreadStaticInitialized(); if (_context == null) { _context = new SpecificationPrimitive <ContextDelegate>(message, arrange); } else { _exceptions.Add(() => { throw new InvalidOperationException("Cannot have more than one Context statement in a specification"); }); } return(_context); }
public ObservationExecutor(SpecificationPrimitive <ContextDelegate> context, SpecificationPrimitive <Action> @do, IEnumerable <SpecificationPrimitive <Action> > observations) { _observations = observations; _context = context; _do = @do; }
public AssertExecutor(SpecificationPrimitive <ContextDelegate> context, SpecificationPrimitive <Action> @do, List <SpecificationPrimitive <Action> > asserts) { _asserts = asserts; _context = context; _do = @do; }