// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT License. // See the LICENSE file in the project root for more information. using System; using System.Linq; using System.Threading.Tasks; using Xunit; namespace Tests { public class Empty : AsyncEnumerableTests { [Fact] public async Task Empty_Basics() { var xs = AsyncEnumerable.Empty(); await NoNextAsync(xs.GetAsyncEnumerator()); Assert.Equal(0, xs.GetAsyncEnumerator().Current); } [Fact] public async Task Empty_IAsyncPartition() { var xs = AsyncEnumerable.Empty(); Assert.Equal(0, await xs.CountAsync()); Assert.Equal(0, await xs.Skip(1).CountAsync()); Assert.Equal(0, await xs.Take(1).CountAsync()); await AssertThrowsAsync(xs.FirstAsync().AsTask()); await AssertThrowsAsync(xs.LastAsync().AsTask()); await AssertThrowsAsync(xs.SingleAsync().AsTask()); Assert.Empty(await xs.ToArrayAsync()); Assert.Empty(await xs.ToListAsync()); } } }