private static void ProcessResponse( Rfc3161RequestResponseStatus expectedStatus, Rfc3161TimestampRequest request, byte[] inputBytes, int paddingByteCount) { Rfc3161TimestampToken token; int bytesRead; Rfc3161RequestResponseStatus status; bool result = request.TryProcessResponse(inputBytes, out token, out status, out bytesRead); Assert.Equal(expectedStatus, status); if (expectedStatus == Rfc3161RequestResponseStatus.Accepted) { Assert.True(result, "request.TryProcessResponse return value"); } else { Assert.False(result, "request.TryProcessResponse return value"); } if (expectedStatus == Rfc3161RequestResponseStatus.DoesNotParse) { Assert.Equal(0, bytesRead); } else { Assert.Equal(inputBytes.Length - paddingByteCount, bytesRead); } switch (expectedStatus) { case Rfc3161RequestResponseStatus.Accepted: case Rfc3161RequestResponseStatus.HashMismatch: case Rfc3161RequestResponseStatus.NonceMismatch: case Rfc3161RequestResponseStatus.UnexpectedCertificates: case Rfc3161RequestResponseStatus.RequestedCertificatesMissing: case Rfc3161RequestResponseStatus.VersionTooNew: Assert.NotNull(token); break; default: Assert.Null(token); break; } if (result) { Rfc3161TimestampToken token2 = request.ProcessResponse(inputBytes, out int bytesRead2); Assert.Equal(bytesRead, bytesRead2); Assert.NotNull(token2); Assert.NotSame(token, token2); } else { Assert.Throws <CryptographicException>(() => request.ProcessResponse(inputBytes, out bytesRead)); } }