// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the Apache 2.0 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 Cast : AsyncEnumerableTests { [Fact] public void Cast_Null() { Assert.Throws(() => AsyncEnumerable.Cast(default)); } [Fact] public async Task Cast1() { var xs = new object[] { 1, 2, 3, 4 }.ToAsyncEnumerable(); var ys = xs.Cast(); var e = ys.GetAsyncEnumerator(); await HasNextAsync(e, 1); await HasNextAsync(e, 2); await HasNextAsync(e, 3); await HasNextAsync(e, 4); await NoNextAsync(e); } [Fact] public void Cast2() { var xs = new[] { new EventArgs(), new EventArgs(), new EventArgs() }.ToAsyncEnumerable(); var ys = xs.Cast(); Assert.Same(xs, ys); } } }