protected override void Act() { lastProcessRequestInput = input; lastProcessRequestsThrewException = false; output = null; input.Stub(input.requestResponsePair); asyncRequestProcessor.ProcessRequestsAsync(input.requestResponsePair.Item1, args => output = args); // this uglyness is only here because of the async stuff int counter = 0; while (output == null) { if (++counter == 20) { throw new InvalidOperationException("time out... the callback should've been called already"); } Thread.Sleep(10); } }
public override void Arrange() { input = new DomainGenerator() .With <ProcessRequestsAsynchronouslyInput>( g => g.For(i => i.Stub, inputpair => requestProcessor.Stub <IRequestProcessor>( r => r.Process(inputpair.Item1)) .Return(inputpair.Item2) .Repeat.Once() .WhenCalled(arg => lastProcessRequestsThrewException = false), inputpair => requestProcessor.Stub <IRequestProcessor>( r => r.Process(inputpair.Item1)) .Return(inputpair.Item2) .Repeat.Once() .WhenCalled(arg => { lastProcessRequestsThrewException = true; throw new Exception(); }))) .One <ProcessRequestsAsynchronouslyInput>(); }
public override void Arrange() { input = new DomainGenerator() .With<ProcessRequestsAsynchronouslyInput>( g => g.For(i => i.Stub, inputpair => requestProcessor.Stub<IRequestProcessor>( r => r.Process(inputpair.Item1)) .Return(inputpair.Item2) .Repeat.Once() .WhenCalled(arg => lastProcessRequestsThrewException = false), inputpair => requestProcessor.Stub<IRequestProcessor>( r => r.Process(inputpair.Item1)) .Return(inputpair.Item2) .Repeat.Once() .WhenCalled(arg => { lastProcessRequestsThrewException = true; throw new Exception(); }))) .One<ProcessRequestsAsynchronouslyInput>(); }