public async Task <int> CountAsync(CancellationToken cancellationToken) { AggregateCountResult result = await _countSource .FirstOrDefaultAsync(cancellationToken) .ConfigureAwait(false); return((int)(result?.Count ?? 0L)); }
public void FirstOrDefault_should_throw_when_aggregate_is_null( [Values(false, true)] bool async) { IAggregateFluent <Person> subject = null; Action action; if (async) { action = () => subject.FirstOrDefaultAsync().GetAwaiter().GetResult(); } else { action = () => subject.FirstOrDefault(); } action.ShouldThrow <ArgumentNullException>().And.ParamName.Should().Be("aggregate"); }