/// <summary>
        /// Performs the validation logic asynchronously and returns a task of <see cref="RuleResult"/>.
        /// </summary>
        /// <param name="validated">The object being validated</param>
        /// <param name="context">Contextual information about the validation</param>
        /// <param name="token">An object which may be used to cancel the process</param>
        /// <returns>A task which provides a result object, indicating the result of validation</returns>
        public Task <RuleResult> GetResultAsync(ICollection <T> validated, RuleContext context, CancellationToken token = default)
        {
            // Because both NotNull & NotEmpty<T> are synchronous, it is safe to use .Result
            var notNullResult  = notNull.GetResultAsync(validated, context, token).Result;
            var notEmptyResult = notEmpty.GetResultAsync(validated, context, token).Result;

            return(notNullResult.IsPass && notEmptyResult.IsPass ? PassAsync() : FailAsync());
        }
 public void GetResultAsyncShouldReturnPassWithANonEmptyQueryable(NotEmpty <string> sut, [RuleContext] RuleContext context)
 {
     Assert.That(() => sut.GetResultAsync(new List <string> {
         "Foo", "Bar"
     }.AsQueryable(), context), Is.PassingValidationResult);
 }
 public void GetResultAsyncShouldReturnFailWithAnEmptyQueryable(NotEmpty <string> sut, [RuleContext] RuleContext context)
 {
     Assert.That(() => sut.GetResultAsync(new List <string>().AsQueryable(), context), Is.FailingValidationResult);
 }
 public void GetResultAsyncShouldReturnPassWithANonEmptyString(NotEmpty sut, [RuleContext] RuleContext context)
 {
     Assert.That(() => sut.GetResultAsync("Foo".AsQueryable(), context), Is.PassingValidationResult);
 }
 public void GetResultAsyncShouldReturnFailWithAnEmptyString(NotEmpty sut, [RuleContext] RuleContext context)
 {
     Assert.That(() => sut.GetResultAsync(String.Empty, context), Is.FailingValidationResult);
 }
 public void GetResultAsyncShouldReturnPassWithANonEmptyArray(NotEmpty sut, [RuleContext] RuleContext context)
 {
     Assert.That(() => sut.GetResultAsync(new [] { "Foo", "Bar" }, context), Is.PassingValidationResult);
 }