public async ValueTask <int> Hyperlinq_Async()
        {
            var sum = 0;

            await foreach (var item in AsyncValueEnumerable.Repeat(1, Count))
            {
                sum += item;
            }
            return(sum);
        }
        public async ValueTask Repeat_Any_With_ValidData_Must_Succeed(int value, int count)
        {
            // Arrange
            var expected = Enumerable.Any(Enumerable.Repeat(value, count));

            // Act
            var result = await AsyncValueEnumerable.Repeat(value, count).AnyAsync();

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
        public void Repeat_With_NegativeCount_Must_Throw(int count)
        {
            // Arrange

            // Act
            Action action = () => _ = AsyncValueEnumerable.Repeat(0, count);

            // Assert
            _ = action.Must()
                .Throw <ArgumentOutOfRangeException>()
                .EvaluateTrue(exception => exception.ParamName == "count");
        }
        public void Repeat_Take_With_ValidData_Must_Succeed(int value, int count, int take)
        {
            // Arrange
            var expected = Enumerable.Take(Enumerable.Repeat(value, count), take);

            // Act
            var result = AsyncValueEnumerable.Repeat(value, count).Take(take);

            // Assert
            _ = result.Must()
                .BeAsyncEnumerableOf <int>()
                .BeEqualTo(expected);
        }
        public async ValueTask Repeat_ToList_With_ValidData_Must_Succeed(int value, int count)
        {
            // Arrange
            var expected = Enumerable.ToList(Enumerable.Repeat(value, count));

            // Act
            var result = await AsyncValueEnumerable.Repeat(value, count).ToListAsync();

            // Assert
            _ = result.Must()
                .BeOfType <List <int> >()
                .BeAsyncEnumerableOf <int>()
                .BeEqualTo(expected);
        }
Esempio n. 6
0
        public async ValueTask Repeat_All_With_ValidData_Must_Succeed(int value, int count)
        {
            // Arrange
            var expected = Enumerable.Repeat(value, count).All(item => false);

            // Act
            var result = await AsyncValueEnumerable
                         .Repeat(value, count)
                         .AllAsync(item => false)
                         .ConfigureAwait(false);

            // Assert
            _ = result.Must()
                .BeEqualTo(expected);
        }
Esempio n. 7
0
 public ValueTask <int[]> Hyperlinq_Async()
 => AsyncValueEnumerable.Repeat(0, Count).ToArrayAsync();