public void should_remove_duplicate_members_with_distinct() { int[] numbers = { 1, 3, 2, 3, 2, 4, 1 }; var distinctNumbers = numbers.Distinct(); Print <int> .PrintSequence(distinctNumbers); }
public void should_get_the_common_members_in_two_array_with_intersect() { digits = new List <string> { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; string[] num = { "1", "2", "3", "zero", "one", "two" }; var commonMembers = digits.Intersect(num); Print <string> .PrintSequence(commonMembers); }
public void should_unite_two_list_with_distinct_members_by_union() { digits = new List <string> { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; string[] num = { "1", "2", "3", "zero", "one", "two" }; var unitedNum = digits.Union(num); Print <string> .PrintSequence(unitedNum); }
public void should_group_members_with_typeOf() { object[] numbers = { null, 1.12, "two", 3, "four", 5, 's', 7.0 }; var doubles = numbers.OfType <double>(); Console.WriteLine("Numbers stored as doubles:"); Print <double> .PrintSequence(doubles); }
public void should_get_members_in_two_sequences_with_duplicates_by_concat() { digits = new List <string> { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; string[] num = { "1", "2", "3", "zero", "one", "two" }; var allMembers = digits.Concat(num); Print <string> .PrintSequence(allMembers); }
public void should_get_members_in_one_sequence_but_not_in_another_with_except() { digits = new List <string> { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; string[] num = { "1", "2", "3", "zero", "one", "two" }; var specialMembers = digits.Except(num); Print <string> .PrintSequence(specialMembers); }
public void should_return_all_members_that_satisfy_rules_with_takeWhile() { var digits = new List <string> { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; var digitsLongerThanThreeWithTakeWhile = digits.TakeWhile(d => d.Length > 3); var digitsLongerThanFourWithWhere = digits.Where(d => d.Length > 3); Print <string> .PrintSequence(digitsLongerThanThreeWithTakeWhile); Console.WriteLine("\n"); Print <string> .PrintSequence(digitsLongerThanFourWithWhere); }
public void should_reverse_members_of_list_with_reverse() { digits = new List <string> { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; var reversedList = digits.ToArray().Reverse(); digits.Reverse(); Print <string> .PrintSequence(reversedList); Console.WriteLine("\n"); Print <string> .PrintSequence(digits); }
public void should_join_two_sequence_with_join() { digits = new List <string> { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" }; string[] num = { "1", "2", "3", "zero", "one", "two" }; var joinedNum = digits.Join(num, d => d, n => n, (d, n) => d); var joinedNum1 = from d in digits join n in num on d equals n select d; Print <string> .PrintSequence(joinedNum); Print <string> .PrintSequence(joinedNum1); }
public void should_generate_sequence_with_repeat() { var repeatedSequence = Enumerable.Repeat("ten", 10); Print <string> .PrintSequence(repeatedSequence); }
public void should_generate_sequence_with_range() { var rangedSequence = Enumerable.Range(10, 10); Print <int> .PrintSequence(rangedSequence); }