Here are the examples of the java api com.bestvike.linq.Linq.of() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1518 Examples
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip2_FirstEmptySecondMany() {
IEnumerable<Integer> first = Linq.of(new int[] {});
IEnumerable<Integer> second = Linq.of(new int[] { 2, 4, 8 });
IEnumerable<Tuple2<Integer, Integer>> expected = Linq.empty();
replacedertEquals(expected, first.zip(second));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void FirstIsNull() {
IEnumerable<Integer> first = null;
IEnumerable<Integer> second = Linq.of(new int[] { 2, 5, 9 });
replacedertThrows(NullPointerException.clreplaced, () -> first.zip(second, (x, y) -> x + y));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void ImplicitTypeParameters() {
IEnumerable<Integer> first = Linq.of(new int[] { 1, 2, 3 });
IEnumerable<Integer> second = Linq.of(new int[] { 2, 5, 9 });
IEnumerable<Integer> expected = Linq.of(new int[] { 3, 7, 12 });
replacedertEquals(expected, first.zip(second, (x, y) -> x + y));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void LambdaFuncChanged() {
IEnumerable<Integer> first = Linq.of(new int[] { 1, 2, 3, 4 });
IEnumerable<Integer> second = Linq.of(new int[] { 2, 4, 8 });
IEnumerable<Integer> expected = Linq.of(new int[] { 3, 6, 11 });
replacedertEquals(expected, first.zip(second, (x, y) -> x + y));
expected = Linq.of(new int[] { -1, -2, -5 });
replacedertEquals(expected, first.zip(second, (x, y) -> x - y));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip2_SecondEmptyFirstMany() {
IEnumerable<Integer> first = Linq.of(new int[] { 1, 2, 3 });
IEnumerable<Integer> second = Linq.of(new int[] {});
IEnumerable<Tuple2<Integer, Integer>> expected = Linq.empty();
replacedertEquals(expected, first.zip(second));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip3_SecondIsNull() {
IEnumerable<Integer> first = Linq.of(new int[] { 1, 2, 3 });
IEnumerable<Integer> second = null;
IEnumerable<Integer> third = Linq.of(new int[] { 4, 5, 6 });
replacedertThrows(ArgumentNullException.clreplaced, () -> first.zip(second, third));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip2_SecondEmptyFirstSingle() {
IEnumerable<Integer> first = Linq.of(new int[] { 1 });
IEnumerable<Integer> second = Linq.of(new int[] {});
IEnumerable<Tuple2<Integer, Integer>> expected = Linq.empty();
replacedertEquals(expected, first.zip(second));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip3_ThirdIsNull() {
IEnumerable<Integer> first = Linq.of(new int[] { 1, 2, 3 });
IEnumerable<Integer> second = Linq.of(new int[] { 4, 5, 6 });
IEnumerable<Integer> third = null;
replacedertThrows(ArgumentNullException.clreplaced, () -> first.zip(second, third));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip3_ThirdEmpty() {
IEnumerable<Integer> first = Linq.of(new int[] { 1, 2, 3 });
IEnumerable<Integer> second = Linq.of(new int[] { 4, 5, 6 });
IEnumerable<Integer> third = Linq.of(new int[0]);
IEnumerable<Tuple3<Integer, Integer, Integer>> expected = Linq.empty();
replacedertEquals(expected, first.zip(second, third));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip3_FirstIsNull() {
IEnumerable<Integer> first = null;
IEnumerable<Integer> second = Linq.of(new int[] { 4, 5, 6 });
IEnumerable<Integer> third = Linq.of(new int[] { 7, 8, 9 });
replacedertThrows(NullPointerException.clreplaced, () -> first.zip(second, third));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip2_FirstAndSecondEmpty() {
IEnumerable<Integer> first = Linq.of(new int[] {});
IEnumerable<Integer> second = Linq.of(new int[] {});
IEnumerable<Tuple2<Integer, Integer>> expected = Linq.empty();
replacedertEquals(expected, first.zip(second));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip2_FirstEmptySecondSingle() {
IEnumerable<Integer> first = Linq.of(new int[] {});
IEnumerable<Integer> second = Linq.of(new int[] { 2 });
IEnumerable<Tuple2<Integer, Integer>> expected = Linq.empty();
replacedertEquals(expected, first.zip(second));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void SecondIsNull() {
IEnumerable<Integer> first = Linq.of(new int[] { 1, 2, 3 });
IEnumerable<Integer> second = null;
replacedertThrows(ArgumentNullException.clreplaced, () -> first.zip(second, (x, y) -> x + y));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip2_FirstIsNull() {
IEnumerable<Integer> first = null;
IEnumerable<Integer> second = Linq.of(new int[] { 2, 5, 9 });
replacedertThrows(NullPointerException.clreplaced, () -> first.zip(second));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Zip2_SecondIsNull() {
IEnumerable<Integer> first = Linq.of(new int[] { 1, 2, 3 });
IEnumerable<Integer> second = null;
replacedertThrows(ArgumentNullException.clreplaced, () -> first.zip(second));
}
19
Source : ZipTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void ExplicitTypeParameters() {
IEnumerable<Integer> first = Linq.of(new int[] { 1, 2, 3 });
IEnumerable<Integer> second = Linq.of(new int[] { 2, 5, 9 });
IEnumerable<Integer> expected = Linq.of(new int[] { 3, 7, 12 });
replacedertEquals(expected, first.zip(second, (x, y) -> x + y));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void SameResultsRepeatCallsMultipleUnions() {
IEnumerable<Integer> q1 = Linq.of(2, 3, null, 2, null, 4, 5);
IEnumerable<Integer> q2 = Linq.of(1, 9, null, 4);
IEnumerable<Integer> q3 = Linq.of(null, 8, 2, 2, 3);
replacedertEquals(q1.unionBy(q2, IntKeySelector).unionBy(q3, IntKeySelector), q1.unionBy(q2, IntKeySelector).unionBy(q3, IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void SameResultsRepeatCallsStringQuery() {
IEnumerable<String> q1 = Linq.of("AAA", Empty, "q", "C", "#", "!@#$%^", "0987654321", "Calling Twice");
IEnumerable<String> q2 = Linq.of("!@#$%^", "C", "AAA", "", "Calling Twice", "SoS");
replacedertEquals(q1.unionBy(q2, StringKeySelector), q1.unionBy(q2, StringKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void SingleWithAllUnique() {
Integer[] first = { 2 };
Integer[] second = { 3, null, 4, 5 };
Integer[] expected = { 2, 3, null, 4, 5 };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void CountMultipleUnion() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
String[] third = { "Bob", "Albert", "Tim" };
replacedertEquals(9, Linq.of(first).unionBy(Linq.of(second), StringKeySelector).unionBy(Linq.of(third), StringKeySelector).count());
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void NonEmptyWithEmpty() {
int[] first = { 2, 4, 5, 3, 2, 3, 9 };
int[] second = {};
int[] expected = { 2, 4, 5, 3, 9 };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void SecondNullNoComparer() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
IEnumerable<String> second = null;
replacedertThrows(ArgumentNullException.clreplaced, () -> Linq.of(first).unionBy(second, StringKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void FirstNullCustomComparer() {
IEnumerable<String> first = null;
String[] second = { "ttaM", "Charlie", "Bbo" };
replacedertThrows(NullPointerException.clreplaced, () -> first.unionBy(Linq.of(second), StringKeySelector, new AnagramEqualityComparer()));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void FirstNullNoComparer() {
IEnumerable<String> first = null;
String[] second = { "ttaM", "Charlie", "Bbo" };
replacedertThrows(NullPointerException.clreplaced, () -> first.unionBy(Linq.of(second), StringKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void SameResultsRepeatCallsIntQuery() {
IEnumerable<Integer> q1 = Linq.of(2, 3, null, 2, null, 4, 5);
IEnumerable<Integer> q2 = Linq.of(1, 9, null, 4);
replacedertEquals(q1.unionBy(q2, IntKeySelector), q1.unionBy(q2, IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void EachHasRepeatsBetweenAndAmongstThemselves() {
Integer[] first = { 1, 2, 3, 4, null, 5, 1 };
Integer[] second = { 6, 2, 3, 4, 5, 6 };
Integer[] expected = { 1, 2, 3, 4, null, 5, 6 };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void Count() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
replacedertEquals(8, Linq.of(first).unionBy(Linq.of(second), StringKeySelector).count());
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void RepeatedElementsWithSingleElement() {
int[] first = { 1, 2, 3, 5, 3, 6 };
int[] second = { 7 };
int[] expected = { 1, 2, 3, 5, 6, 7 };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void CommonElementsShared() {
int[] first = { 1, 2, 3, 4, 5, 6 };
int[] second = { 6, 7, 7, 7, 8, 1 };
int[] expected = { 1, 2, 3, 4, 5, 6, 7, 8 };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void MultipleUnionsDifferentComparers() {
String[] first = { "Alpha", "Bravo", "Charlie", "Bravo", "Delta", "atleD", "ovarB" };
String[] second = { "Charlie", "Delta", "Echo", "Foxtrot", "Foxtrot", "choE" };
String[] third = { "trotFox", "Golf", "Alpha", "choE", "Tango" };
String[] plainThenAnagram = { "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Tango" };
String[] anagramThenPlain = { "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "trotFox", "Golf", "choE", "Tango" };
replacedertEquals(Linq.of(plainThenAnagram), Linq.of(first).unionBy(Linq.of(second), StringKeySelector).unionBy(Linq.of(third), StringKeySelector, new AnagramEqualityComparer()));
replacedertEquals(Linq.of(anagramThenPlain), Linq.of(first).unionBy(Linq.of(second), StringKeySelector, new AnagramEqualityComparer()).unionBy(Linq.of(third), StringKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void CustomComparer() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
String[] expected = { "Bob", "Robert", "Tim", "Matt", "Charlie" };
AnagramEqualityComparer comparer = new AnagramEqualityComparer();
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), StringKeySelector, comparer), comparer);
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void ToArray() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
String[] expected = { "Bob", "Robert", "Tim", "Matt", "miT", "ttaM", "Charlie", "Bbo" };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), StringKeySelector).toArray());
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void ToArrayMultipleUnion() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
String[] third = { "Bob", "Albert", "Tim" };
String[] expected = { "Bob", "Robert", "Tim", "Matt", "miT", "ttaM", "Charlie", "Bbo", "Albert" };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), StringKeySelector).unionBy(Linq.of(third), StringKeySelector).toArray());
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void RepeatEnumerating() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
IEnumerable<String> result = Linq.of(first).unionBy(Linq.of(second), StringKeySelector);
replacedertEquals(result, result);
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void ForcedToEnumeratorDoesntEnumerateMultipleUnions() {
IEnumerable<Integer> iterator = NumberRangeGuaranteedNotCollectionType(0, 3).unionBy(Linq.range(0, 3), IntKeySelector).unionBy(Linq.range(2, 4), IntKeySelector).unionBy(Linq.of(new int[] { 9, 2, 4 }), IntKeySelector);
// Don't insist on this behaviour, but check it's correct if it happens
IEnumerator<Integer> en = (IEnumerator<Integer>) iterator;
replacedertFalse(en != null && en.moveNext());
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void SecondNullCustomComparer() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
IEnumerable<String> second = null;
replacedertThrows(ArgumentNullException.clreplaced, () -> Linq.of(first).unionBy(second, StringKeySelector, new AnagramEqualityComparer()));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void SameElementRepeated() {
int[] first = { 1, 1, 1, 1, 1, 1 };
int[] second = { 1, 1, 1, 1, 1, 1 };
int[] expected = { 1 };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void ToList() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
String[] expected = { "Bob", "Robert", "Tim", "Matt", "miT", "ttaM", "Charlie", "Bbo" };
replacedertEquals(Linq.of(expected), Linq.of(Linq.of(first).unionBy(Linq.of(second), StringKeySelector).toList()));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void NullEqualityComparer() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
String[] expected = { "Bob", "Robert", "Tim", "Matt", "miT", "ttaM", "Charlie", "Bbo" };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), StringKeySelector, null));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void MultipleUnionsCustomComparer() {
Integer[] first = { 1, 102, 903, 204, null, 5, 601 };
Integer[] second = { 6, 202, 903, 204, 5, 106 };
Integer[] third = { 2, 308, 2, 103, 802, 308 };
Integer[] fourth = { null, 101, 207, 202, 207 };
Integer[] expected = { 1, 102, 903, 204, null, 5, 6, 308, 207 };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), IntKeySelector, new Modulo100EqualityComparer()).unionBy(Linq.of(third), IntKeySelector, new Modulo100EqualityComparer()).unionBy(Linq.of(fourth), IntKeySelector, new Modulo100EqualityComparer()));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void BothEmpty() {
int[] first = {};
int[] second = {};
replacedertEmpty(Linq.of(first).unionBy(Linq.of(second), IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void EachHasRepeatsBetweenAndAmongstThemselvesMultipleUnions() {
Integer[] first = { 1, 2, 3, 4, null, 5, 1 };
Integer[] second = { 6, 2, 3, 4, 5, 6 };
Integer[] third = { 2, 8, 2, 3, 2, 8 };
Integer[] fourth = { null, 1, 7, 2, 7 };
Integer[] expected = { 1, 2, 3, 4, null, 5, 6, 8, 7 };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), IntKeySelector).unionBy(Linq.of(third), IntKeySelector).unionBy(Linq.of(fourth), IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void RunOnce() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
String[] expected = { "Bob", "Robert", "Tim", "Matt", "Charlie" };
AnagramEqualityComparer comparer = new AnagramEqualityComparer();
replacedertEquals(Linq.of(expected), Linq.of(first).runOnce().unionBy(Linq.of(second).runOnce(), StringKeySelector, comparer), comparer);
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void ToListMultipleUnion() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
String[] third = { "Bob", "Albert", "Tim" };
String[] expected = { "Bob", "Robert", "Tim", "Matt", "miT", "ttaM", "Charlie", "Bbo", "Albert" };
replacedertEquals(Linq.of(expected), Linq.of(Linq.of(first).unionBy(Linq.of(second), StringKeySelector).unionBy(Linq.of(third), StringKeySelector).toList()));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void ManyEmpty() {
int[] first = {};
int[] second = {};
int[] third = {};
int[] fourth = {};
replacedertEmpty(Linq.of(first).unionBy(Linq.of(second), IntKeySelector).unionBy(Linq.of(third), IntKeySelector).unionBy(Linq.of(fourth), IntKeySelector));
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void RepeatEnumeratingMultipleUnions() {
String[] first = { "Bob", "Robert", "Tim", "Matt", "miT" };
String[] second = { "ttaM", "Charlie", "Bbo" };
String[] third = { "Matt", "Albert", "Ichabod" };
IEnumerable<String> result = Linq.of(first).unionBy(Linq.of(second), StringKeySelector).unionBy(Linq.of(third), StringKeySelector);
replacedertEquals(result, result);
}
19
Source : UnionByTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void EmptyWithNonEmpty() {
int[] first = {};
int[] second = { 2, 4, 5, 3, 2, 3, 9 };
int[] expected = { 2, 4, 5, 3, 9 };
replacedertEquals(Linq.of(expected), Linq.of(first).unionBy(Linq.of(second), IntKeySelector));
}
19
Source : ToMapTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
private static <T> void RunToDictionaryOnAllCollectionTypes(T[] items, Action1<Map<T, T>> validation) {
validation.apply(Linq.of(items).toMap(key -> key));
validation.apply(Linq.of(items).toMap(key -> key, value -> value));
validation.apply(Linq.of(items).toArray().toMap(key -> key));
validation.apply(Linq.of(items).toArray().toMap(key -> key, value -> value));
validation.apply(new TestEnumerable<>(items).toMap(key -> key));
validation.apply(new TestEnumerable<>(items).toMap(key -> key, value -> value));
validation.apply(new TestReadOnlyCollection<>(items).toMap(key -> key));
validation.apply(new TestReadOnlyCollection<>(items).toMap(key -> key, value -> value));
validation.apply(new TestCollection<>(items).toMap(key -> key));
validation.apply(new TestCollection<>(items).toMap(key -> key, value -> value));
}
19
Source : ToMapTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void NullCoalescedKeySelector() {
String[] elements = new String[] { null };
String[] keys = new String[] { Empty };
String[] source = new String[] { null };
replacedertMatches(Linq.of(keys), Linq.of(elements), Linq.of(source).toMap(e -> e == null ? Empty : e, e -> e));
}
19
Source : ToMapTest.java
with Apache License 2.0
from timandy
with Apache License 2.0
from timandy
@Test
void ToDictionary_KeyValueSelectorsWork() {
TestCollection<Integer> collection = new TestCollection<>(new Integer[] { 1, 2, 3, 4, 5, 6 });
Map<Integer, Integer> result = collection.toMap(key -> key + 10, val -> val + 100);
replacedertEquals(Linq.of(collection.Items).cast(Integer.clreplaced).select(o -> o + 10), Linq.of(result.keySet()).orderBy(x -> x));
replacedertEquals(Linq.of(collection.Items).cast(Integer.clreplaced).select(o -> o + 100), Linq.of(result.values()).orderBy(x -> x));
}
See More Examples