public void AssertRequestBody(Req req) { if (req.Body == null) Assert.That(requestBody, Is.Null); else { Assert.That(requestBodyConsumer.Buffer.GetString(), Is.EqualTo(req.Body.GetString())); Assert.That(requestBodyConsumer.GotEnd, Is.True); } }
public TxLoop(TxContext context, Req req) { this.context = context; this.req = req; }
IEnumerable<TxCallbacks> Permute(Req req) { // XXX would be nice to increase this to 6. would need to buffer data in the transaction. // currently user must connect immediately, or before client writes req body data, // else data is lost :( var connectUpperBound = req.Body == null ? 0 : 2; var disconnectUpperBound = connectUpperBound == 0 ? -1 : 2; for (int i = 0; i < connectUpperBound; i++) { for (int j = i - 1; j < disconnectUpperBound; j++) { for (int k = -1; k < 6; k++) { var callbacks = CreateCallbacks(); var hooks = callbacks.Item2; if (i != -1) hooks[i].Add(() => context.ConnectToRequestBody()); if (j != i - 1 && j > -1) hooks[j].Add(() => context.CancelRequestBody()); if (k != -1) hooks[k].Add(() => context.CloseConnection()); //Console.WriteLine("i = {0}, j = {1}, k = {2}", i, j, k); yield return callbacks.Item1; } } } }