public void Eager_Validation_Source_ValueTaskPredicate() { var target = new ThrowingAsyncEnumerable <bool>(); Assert.Throws <ArgumentNullException>(() => { var noIterate = AsyncEnumerable.Any((IAsyncEnumerable <bool>)null, QuickFunctions <bool> .IdentityWrapped); }); }
public void Eager_Validation_Predicate_ValueTaskPredicate() { var target = new ThrowingAsyncEnumerable <bool>(); Assert.Throws <ArgumentNullException>(() => { var noIterate = AsyncEnumerable.Any(target, (Func <bool, ValueTask <bool> >)null); }); }
public void Eager_Validation_Source_NoPredicate() { var target = new ThrowingAsyncEnumerable <bool>(); Assert.Throws <ArgumentNullException>(() => { var noIterate = AsyncEnumerable.Any((IAsyncEnumerable <bool>)null); }); }
public async Task <bool> ApplyFriendAsync(EaUser user, string fid) { var fuser = await _userManager.FindByIdAsync(fid); if (fuser == null) { return(false);//失败 } var has = await AsyncEnumerable.Any(f => f.IsEnable && f.Target == user.Id || f.Creator == user.Id); if (fuser.Id == user.Id || has) { return(false); } DbSet.Add(new Friend() { Creator = user.Id, Target = fid }); var res = await DbContext.SaveChangesAsync(); return(res > 0); }
public static Task <bool> AnyAsync <TSource>(this IAsyncEnumerable <TSource> source, Func <TSource, bool> predicate, CancellationToken cancellationToken = default) => AsyncEnumerable.Any(source, predicate, cancellationToken);