Beispiel #1
0
 public void Visit(WhenBlock block)
 {
     if (block.Condition == null || Visit(block.Condition).Number != 0)
     {
         Visit(block.Body);
     }
 }
Beispiel #2
0
 public static ThenBlock <TFactWork, TFactWork> ThenNotContainVersionType <TInput, TFactWork>(this WhenBlock <TInput, TFactWork> whenBlock)
     where TFactWork : IFactWork
 {
     return(whenBlock
            .ThenIsNotNull()
            .And("Get type of version.", work => Assert.IsNull(work.InputFactTypes?.FirstVersionFactType())));
 }
Beispiel #3
0
 /// <inheritdoc cref="ThenAssertErrorDetail{TInput}(WhenBlock{TInput, InvalidDeriveOperationException}, string, string)"/>
 public static ThenBlock <FactFactoryException, FactFactoryException> ThenAssertErrorDetail <TInput>(this WhenBlock <TInput, FactFactoryException> whenBlock, string errorCode, string errorMessage)
 {
     return(whenBlock
            .ThenIsNotNull()
            .And($"Check error with code {errorCode}", error =>
                 error.AssertErrorDetail(errorCode, errorMessage)));
 }
Beispiel #4
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);
            }));
        }
Beispiel #5
0
 /// <summary>
 /// Then block for check <see cref="FactBase{TFactValue}.Value"/>.
 /// </summary>
 /// <typeparam name="TInput">Input type</typeparam>
 /// <typeparam name="TFact">Fact type</typeparam>
 /// <typeparam name="TFactValue">Fact value type.</typeparam>
 /// <param name="whenBlock">Previous when block</param>
 /// <param name="expectedValue">Expected value</param>
 /// <returns>Then block</returns>
 public static ThenBlock <TFact, TFact> ThenFactValueEquals <TInput, TFact, TFactValue>(this WhenBlock <TInput, TFact> whenBlock, TFactValue expectedValue)
     where TFact : FactBase <TFactValue>
 {
     return(whenBlock
            .ThenIsNotNull()
            .AndAreEqual(fact => fact.Value, expectedValue,
                         errorMessage: $"A different meaning of the {typeof(TFact).Name} fact was expected", blockName: $"Check assert {typeof(TFact).Name} fact."));
 }
 /// <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)));
 }