public void Contains_Selector_With_Comparer_And_Contains_Must_ReturnTrue(int[] source, Selector <int, string> selector) { // Arrange var value = System.Linq.Enumerable.Last( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = Array .Select <int, string>((ReadOnlySpan <int>)source.AsSpan(), selector) .Contains(value, EqualityComparer <string> .Default); // Assert _ = result.Must() .BeTrue(); }
public void Contains_Selector_With_Null_And_Contains_Must_ReturnTrue(int[] source, Selector <int, string> selector) { // Arrange var value = System.Linq.Enumerable.Last( System.Linq.Enumerable.Select(source, selector.AsFunc())); var wrapped = Wrap.AsValueEnumerable(source); // Act var result = ValueEnumerable .Select <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int, string>(wrapped, selector) .Contains(value, null); // Assert _ = result.Must() .BeTrue(); }
public void ToArray_With_Selector_Must_Succeed(int[] source, Selector <int, string> selector) { // Arrange var expected = System.Linq.Enumerable.ToArray( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = Array .Select <int, string>((ReadOnlyMemory <int>)source.AsMemory(), selector) .ToArray(); // Assert _ = result.Must() .BeArrayOf <string>() .BeEqualTo(expected); }
public void Contains_Selector_With_Comparer_And_Contains_Must_ReturnTrue(int[] source, Selector <int, string> selector) { // Arrange var value = System.Linq.Enumerable.Last( System.Linq.Enumerable.Select(source, selector.AsFunc())); var wrapped = Wrap.AsValueReadOnlyCollection(source); // Act var result = ValueReadOnlyCollection .Select <Wrap.ValueReadOnlyCollection <int>, Wrap.Enumerator <int>, int, string>(wrapped, selector) .Contains(value, EqualityComparer <string> .Default); // Assert _ = result.Must() .BeTrue(); }
public void Single_Selector_With_Single_Must_Return_Some(int[] source, Selector <int, string> selector) { // Arrange var expected = System.Linq.Enumerable.Single( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = Array .Select <int, string>(source.AsSpan(), selector) .Single(); // Assert _ = result.Match( value => value.Must().BeEqualTo(expected), () => throw new Exception()); }
public async ValueTask ContainsAsync_Selector_With_Comparer_And_Contains_Must_ReturnTrue(int[] source, Selector <int, string> selector) { // Arrange var value = System.Linq.Enumerable.Last( System.Linq.Enumerable.Select(source, selector.AsFunc())); var wrapped = Wrap.AsAsyncValueEnumerable(source); // Act var result = await AsyncValueEnumerable .Select <Wrap.AsyncValueEnumerable <int>, Wrap.AsyncEnumerator <int>, int, string>(wrapped, selector.AsAsync()) .ContainsAsync(value, EqualityComparer <string> .Default); // Assert _ = result.Must() .BeTrue(); }
public void First_Selector_With_ValidData_Must_Return_Some(int[] source, Selector <int, string> selector) { // Arrange var expected = System.Linq.Enumerable.First( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = Array .Select <int, string>((ReadOnlyMemory <int>)source.AsMemory(), selector) .First(); // Assert _ = result.Match( value => value.Must().BeEqualTo(expected), () => throw new Exception()); }
public void ToArray_With_Selector_Must_Succeed(int[] source, Selector <int, string> selector) { // Arrange var wrapped = Wrap.AsValueReadOnlyList(source); var expected = System.Linq.Enumerable.ToArray( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = ReadOnlyList .Select <Wrap.ValueReadOnlyList <int>, int, string>(wrapped, selector) .ToArray(); // Assert _ = result.Must() .BeArrayOf <string>() .BeEqualTo(expected); }
public void ToList_With_Selector_Must_Succeed(int[] source, Selector <int, string> selector) { // Arrange var expected = System.Linq.Enumerable.ToList( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = Array .Select <int, string>((ReadOnlySpan <int>)source.AsSpan(), selector) .ToList(); // Assert _ = result.Must() .BeOfType <List <string> >() .BeEnumerableOf <string>() .BeEqualTo(expected); }
public void WhereSelect_With_ValidData_Must_Succeed(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var wrapped = Wrap.AsValueReadOnlyList(source); var expected = System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(wrapped, predicate.AsFunc()), selector.AsFunc()); // Act var result = ReadOnlyList .Where <Wrap.ValueReadOnlyList <int>, int>(wrapped, predicate) .Select(selector); // Assert _ = result.Must() .BeEnumerableOf <string>() .BeEqualTo(expected); }
public void Contains_Predicate_Selector_With_Null_And_Contains_Must_ReturnTrue(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var value = System.Linq.Enumerable.Last( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc())); // Act var result = Array .Where <int>((ReadOnlySpan <int>)source.AsSpan(), predicate) .Select(selector) .Contains(value, null); // Assert _ = result.Must() .BeTrue(); }
public async ValueTask ContainsAsync_Predicate_Selector_With_Null_And_Contains_Must_ReturnTrue(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var value = System.Linq.Enumerable.Last( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc())); var wrapped = Wrap.AsAsyncValueEnumerable(source); // Act var result = await AsyncValueEnumerable .Where <Wrap.AsyncValueEnumerable <int>, Wrap.AsyncEnumerator <int>, int>(wrapped, predicate.AsAsync()) .Select(selector.AsAsync()) .ContainsAsync(value, null); // Assert _ = result.Must() .BeTrue(); }
public async ValueTask ToArrayAsync_Selector_With_ValidData_Must_Succeed(int[] source, Selector <int, string> selector) { // Arrange var wrapped = Wrap .AsAsyncValueEnumerable(source); var expected = System.Linq.Enumerable.ToArray( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = await AsyncValueEnumerable .Select <Wrap.AsyncValueEnumerable <int>, Wrap.AsyncEnumerator <int>, int, string>(wrapped, selector.AsAsync()) .ToArrayAsync(); // Assert _ = result.Must() .BeArrayOf <string>() .BeEqualTo(expected); }
public void First_Predicate_Selector_With_ValidData_Must_Return_Some(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var expected = System.Linq.Enumerable.First( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc())); // Act var result = Array .Where <int>(source.AsSpan(), predicate) .Select(selector) .First(); // Assert _ = result.Match( value => value.Must().BeEqualTo(expected), () => throw new Exception()); }
public void ForEach_ActionAt_Selector_With_ValidData_Must_Succeed(int[] source, Selector <int, string> selector) { // Arrange var result = new List <(string, int)>(); var expected = new List <(string, int)>(); System.Linq.EnumerableEx.ForEach( System.Linq.Enumerable.Select(source, selector.AsFunc()), (item, index) => expected.Add((item, index))); // Act Array .Select <int, string>((ReadOnlySpan <int>)source.AsSpan(), selector) .ForEach((item, index) => result.Add((item, index))); // Assert _ = result.Must() .BeEnumerableOf <(string, int)>() .BeEqualTo(expected); }
public void ToArray_With_Predicate_Selector_Must_Succeed(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var expected = System.Linq.Enumerable.ToArray( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc())); // Act var result = Array .Where <int>((ReadOnlySpan <int>)source.AsSpan(), predicate) .Select(selector) .ToArray(); // Assert _ = result.Must() .BeArrayOf <string>() .BeEqualTo(expected); }
public void Contains_Predicate_Selector_With_Comparer_And_Contains_Must_ReturnTrue(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var value = System.Linq.Enumerable.Last( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc())); var wrapped = Wrap.AsValueEnumerable(source); // Act var result = ValueEnumerable .Where <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped, predicate) .Select(selector) .Contains(value, EqualityComparer <string> .Default); // Assert _ = result.Must() .BeTrue(); }
public void First_Selector_With_ValidData_Must_Return_Some(int[] source, Selector <int, string> selector) { // Arrange var wrapped = Wrap .AsValueEnumerable(source); var expected = System.Linq.Enumerable.First( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = ValueEnumerable .Select <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int, string>(wrapped, selector) .First(); // Assert _ = result.Match( value => value.Must().BeEqualTo(expected), () => throw new Exception()); }
public async ValueTask SingleAsync_Selector_With_SingleAsync_Must_Return_Some(int[] source, Selector <int, string> selector) { // Arrange var wrapped = Wrap .AsAsyncValueEnumerable(source); var expected = System.Linq.Enumerable.Single( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = await AsyncValueEnumerable .Select <Wrap.AsyncValueEnumerable <int>, Wrap.AsyncEnumerator <int>, int, string>(wrapped, selector.AsAsync()) .SingleAsync(); // Assert _ = result.Match( value => value.Must().BeEqualTo(expected), () => throw new Exception()); }
public void ForEach_Action_Selector_With_ValidData_Must_Succeed(int[] source, Selector <int, string> selector) { // Arrange var result = new List <string>(); var expected = new List <string>(); System.Linq.EnumerableEx.ForEach( System.Linq.Enumerable.Select(source, selector.AsFunc()), item => expected.Add(item)); // Act Array .Select <int, string>(source.AsMemory(), selector) .ForEach(item => result.Add(item)); // Assert _ = result.Must() .BeEnumerableOf <string>() .BeEqualTo(expected); }
public async ValueTask ForEachAsync_Action_Selector_With_ValidData_Must_Succeed(int[] source, Selector <int, string> selector) { // Arrange var wrapped = Wrap.AsAsyncValueEnumerable(source); var result = new List <string>(); var expected = new List <string>(); System.Linq.EnumerableEx.ForEach( System.Linq.Enumerable.Select(source, selector.AsFunc()), item => expected.Add(item)); // Act await AsyncValueEnumerable .Select <Wrap.AsyncValueEnumerable <int>, Wrap.AsyncEnumerator <int>, int, string>(wrapped, selector.AsAsync()) .ForEachAsync((item, cancellationToken) => { result.Add(item); return(new ValueTask()); }); // Assert _ = result.Must() .BeEnumerableOf <string>() .BeEqualTo(expected); }
public void ForEach_Action_Selector_With_ValidData_Must_Succeed(int[] source, Selector <int, string> selector) { // Arrange var wrapped = Wrap.AsValueEnumerable(source); var result = new List <string>(); var expected = new List <string>(); System.Linq.EnumerableEx.ForEach( System.Linq.Enumerable.Select(source, selector.AsFunc()), item => expected.Add(item)); // Act ValueEnumerable .Select <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int, string>(wrapped, selector) .ForEach(item => result.Add(item)); // Assert _ = result.Must() .BeEnumerableOf <string>() .BeEqualTo(expected); }
public void ToList_Selector_With_ValidData_Must_Succeed(int[] source, Selector <int, string> selector) { // Arrange var wrapped = Wrap .AsValueEnumerable(source); var expected = System.Linq.Enumerable.ToList( System.Linq.Enumerable.Select(source, selector.AsFunc())); // Act var result = ValueEnumerable .Select <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int, string>(wrapped, selector) .ToList(); // Assert _ = result.Must() .BeOfType <List <string> >() .BeEnumerableOf <string>() .BeEqualTo(expected); }
public void ToList_With_Predicate_Selector_Must_Succeed(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var expected = System.Linq.Enumerable.ToList( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc())); // Act var result = Array .Where <int>(source.AsMemory(), predicate) .Select(selector) .ToList(); // Assert _ = result.Must() .BeOfType <List <string> >() .BeEnumerableOf <string>() .BeEqualTo(expected); }
public void ElementAt_Selector_With_ValidData_Must_Return_Some(int[] source, Selector <int, string> selector) { for (var index = 0; index < source.Length; index++) { // Arrange var expected = System.Linq.Enumerable.ElementAt( System.Linq.Enumerable.Select(source, selector.AsFunc()), index); // Act var result = Array .Select <int, string>(source, selector) .ElementAt(index); // Assert _ = result.Match( value => value.Must().BeEqualTo(expected), () => throw new Exception()); } }
public async ValueTask ElementAtAsync_Selector_With_ValidData_Must_Return_Some(int[] source, Selector <int, string> selector) { for (var index = 0; index < source.Length; index++) { // Arrange var wrapped = Wrap.AsAsyncValueEnumerable(source); var expected = System.Linq.Enumerable.ElementAt( System.Linq.Enumerable.Select(source, selector.AsFunc()), index); // Act var result = await AsyncValueEnumerable .Select <Wrap.AsyncValueEnumerable <int>, Wrap.AsyncEnumerator <int>, int, string>(wrapped, selector.AsAsync()) .ElementAtAsync(index); // Assert _ = result.Match( value => value.Must().BeEqualTo(expected), () => throw new Exception()); } }
public void ToArray_Predicate_Selector_With_ValidData_Must_Succeed(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var wrapped = Wrap .AsValueEnumerable(source); var expected = System.Linq.Enumerable.ToArray( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc())); // Act var result = ValueEnumerable .Where <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped, predicate) .Select(selector) .ToArray(); // Assert _ = result.Must() .BeArrayOf <string>() .BeEqualTo(expected); }
public void ForEach_ActionAt_Predicate_Selector_With_ValidData_Must_Succeed(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var result = new List <(string, int)>(); var expected = new List <(string, int)>(); System.Linq.EnumerableEx.ForEach( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc()), (item, index) => expected.Add((item, index))); // Act Array .Where <int>(source.AsMemory(), predicate) .Select(selector) .ForEach((item, index) => result.Add((item, index))); // Assert _ = result.Must() .BeEnumerableOf <(string, int)>() .BeEqualTo(expected); }
public void ForEach_Action_Predicate_Selector_With_ValidData_Must_Succeed(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var result = new List <string>(); var expected = new List <string>(); System.Linq.EnumerableEx.ForEach( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc()), item => expected.Add(item)); // Act Array .Where <int>((ReadOnlySpan <int>)source.AsSpan(), predicate) .Select(selector) .ForEach(item => result.Add(item)); // Assert _ = result.Must() .BeEnumerableOf <string>() .BeEqualTo(expected); }
public void Single_Predicate_Selector_With_Single_Must_Return_Some(int[] source, Predicate <int> predicate, Selector <int, string> selector) { // Arrange var wrapped = Wrap .AsValueEnumerable(source); var expected = System.Linq.Enumerable.Single( System.Linq.Enumerable.Select( System.Linq.Enumerable.Where(source, predicate.AsFunc()), selector.AsFunc())); // Act var result = ValueEnumerable .Where <Wrap.ValueEnumerable <int>, Wrap.Enumerator <int>, int>(wrapped, predicate) .Select(selector) .Single(); // Assert _ = result.Match( value => value.Must().BeEqualTo(expected), () => throw new Exception()); }