12345678910111213141516171819202122232425262728 |
- // 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 Xunit;
- namespace Tests
- {
- public class Generate : Tests
- {
- [Fact]
- public void Generate_Arguments()
- {
- AssertThrows<ArgumentNullException>(() => EnumerableEx.Generate<int, int>(0, null, _ => _, _ => _));
- AssertThrows<ArgumentNullException>(() => EnumerableEx.Generate<int, int>(0, _ => true, null, _ => _));
- AssertThrows<ArgumentNullException>(() => EnumerableEx.Generate<int, int>(0, _ => true, _ => _, null));
- }
- [Fact]
- public void Generate1()
- {
- var res = EnumerableEx.Generate(0, x => x < 5, x => x + 1, x => x * x).ToList();
- Assert.True(Enumerable.SequenceEqual(res, [0, 1, 4, 9, 16]));
- }
- }
- }
|