예제 #1
0
        /// <summary>
        /// Check for errors.
        /// </summary>
        /// <typeparam name="TInput">Input type</typeparam>
        /// <param name="whenBlock">When block</param>
        /// <param name="errorCode">Error code</param>
        /// <param name="errorMessage">Error message</param>
        /// <returns>Result of checking.</returns>
        public static ThenBlock <InvalidDeriveOperationException, InvalidDeriveOperationException> ThenAssertErrorDetail <TInput>(this WhenBlock <TInput, InvalidDeriveOperationException> whenBlock, string errorCode, string errorMessage)
        {
            return(whenBlock
                   .Then($"Check error with code {errorCode}", error =>
            {
                if (error == null)
                {
                    AssertErrorDetail(null, errorCode, errorMessage);
                }
                else if (error.Details == null)
                {
                    new FactFactoryException(null);
                }

                new FactFactoryException(error.Details.Select(detail => (ErrorDetail)detail).ToList()).AssertErrorDetail(errorCode, errorMessage);
            }));
        }
 /// <summary>
 /// Check error code and reason.
 /// </summary>
 /// <param name="whenBlock"></param>
 /// <param name="code"></param>
 /// <param name="reason"></param>
 /// <returns></returns>
 public static ThenBlock <GetcuReoneException, GetcuReoneException> ThenAssertError <TIn>(this WhenBlock <TIn, GetcuReoneException> whenBlock, string code, string reason)
 {
     return(whenBlock.Then($"Check error. Code <{code}>, Reason <{reason}>.",
                           error => AssertError(error, code, reason)));
 }