55public class StrainTests
66{
77 [ Fact ]
8- public void Empty_keep ( )
8+ public void Keep_on_empty_list_returns_empty_list ( )
99 {
10- Assert . Equal ( new LinkedList < int > ( ) , new LinkedList < int > ( ) . Keep ( x => x < 10 ) ) ;
10+ int [ ] expected = [ ] ;
11+ int [ ] input = [ ] ;
12+ Assert . Equal ( expected , input . Keep ( x => true ) . ToArray ( ) ) ;
1113 }
1214
1315 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
14- public void Keep_everything ( )
16+ public void Keeps_everything ( )
1517 {
16- Assert . Equal ( new HashSet < int > { 1 , 2 , 3 } , new HashSet < int > { 1 , 2 , 3 } . Keep ( x => x < 10 ) ) ;
18+ int [ ] expected = [ 1 , 3 , 5 ] ;
19+ int [ ] input = [ 1 , 3 , 5 ] ;
20+ Assert . Equal ( expected , input . Keep ( x => true ) . ToArray ( ) ) ;
1721 }
1822
1923 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
20- public void Keep_nothing ( )
24+ public void Keeps_nothing ( )
2125 {
22- Assert . Equal ( new HashSet < int > ( ) , new HashSet < int > { 1 , 2 , 3 } . Keep ( x => x > 10 ) ) ;
26+ int [ ] expected = [ ] ;
27+ int [ ] input = [ 1 , 3 , 5 ] ;
28+ Assert . Equal ( expected , input . Keep ( x => false ) . ToArray ( ) ) ;
2329 }
2430
2531 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
26- public void Keep_first_and_last ( )
32+ public void Keeps_first_and_last ( )
2733 {
28- Assert . Equal ( new [ ] { 1 , 3 } , new [ ] { 1 , 2 , 3 } . Keep ( x => x % 2 != 0 ) ) ;
34+ int [ ] expected = [ 1 , 3 ] ;
35+ int [ ] input = [ 1 , 2 , 3 ] ;
36+ Assert . Equal ( expected , input . Keep ( x => x % 2 == 1 ) . ToArray ( ) ) ;
2937 }
3038
3139 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
32- public void Keep_neither_first_nor_last ( )
40+ public void Keeps_neither_first_nor_last ( )
3341 {
34- Assert . Equal ( new List < int > { 2 , 4 } , new List < int > { 1 , 2 , 3 , 4 , 5 } . Keep ( x => x % 2 == 0 ) ) ;
42+ int [ ] expected = [ 2 ] ;
43+ int [ ] input = [ 1 , 2 , 3 ] ;
44+ Assert . Equal ( expected , input . Keep ( x => x % 2 == 0 ) . ToArray ( ) ) ;
3545 }
3646
3747 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
38- public void Keep_strings ( )
48+ public void Keeps_strings ( )
3949 {
40- var words = "apple zebra banana zombies cherimoya zelot" . Split ( ' ' ) ;
41- Assert . Equal ( "zebra zombies zelot" . Split ( ' ' ) , words . Keep ( x => x . StartsWith ( "z" ) ) ) ;
50+ string [ ] expected = [ "zebra" , "zombies" , "zealot" ] ;
51+ string [ ] input = [ "apple" , "zebra" , "banana" , "zombies" , "cherimoya" , "zealot" ] ;
52+ Assert . Equal ( expected , input . Keep ( x => x . StartsWith ( 'z' ) ) . ToArray ( ) ) ;
4253 }
4354
4455 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
45- public void Keep_arrays ( )
56+ public void Keeps_lists ( )
4657 {
47- var actual = new [ ]
48- {
49- new [ ] { 1 , 2 , 3 } ,
50- new [ ] { 5 , 5 , 5 } ,
51- new [ ] { 5 , 1 , 2 } ,
52- new [ ] { 2 , 1 , 2 } ,
53- new [ ] { 1 , 5 , 2 } ,
54- new [ ] { 2 , 2 , 1 } ,
55- new [ ] { 1 , 2 , 5 }
56- } ;
57- var expected = new [ ] { new [ ] { 5 , 5 , 5 } , new [ ] { 5 , 1 , 2 } , new [ ] { 1 , 5 , 2 } , new [ ] { 1 , 2 , 5 } } ;
58- Assert . Equal ( expected , actual . Keep ( x => x . Contains ( 5 ) ) ) ;
58+ int [ ] [ ] expected = [ [ 5 , 5 , 5 ] , [ 5 , 1 , 2 ] , [ 1 , 5 , 2 ] , [ 1 , 2 , 5 ] ] ;
59+ int [ ] [ ] input = [ [ 1 , 2 , 3 ] , [ 5 , 5 , 5 ] , [ 5 , 1 , 2 ] , [ 2 , 1 , 2 ] , [ 1 , 5 , 2 ] , [ 2 , 2 , 1 ] , [ 1 , 2 , 5 ] ] ;
60+ Assert . Equal ( expected , input . Keep ( x => x . Contains ( 5 ) ) . ToArray ( ) ) ;
5961 }
6062
6163 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
62- public void Empty_discard ( )
64+ public void Discard_on_empty_list_returns_empty_list ( )
6365 {
64- Assert . Equal ( new LinkedList < int > ( ) , new LinkedList < int > ( ) . Discard ( x => x < 10 ) ) ;
66+ int [ ] expected = [ ] ;
67+ int [ ] input = [ ] ;
68+ Assert . Equal ( expected , input . Discard ( x => true ) . ToArray ( ) ) ;
6569 }
6670
6771 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
68- public void Discard_everything ( )
72+ public void Discards_everything ( )
6973 {
70- Assert . Equal ( new HashSet < int > ( ) , new HashSet < int > { 1 , 2 , 3 } . Discard ( x => x < 10 ) ) ;
74+ int [ ] expected = [ ] ;
75+ int [ ] input = [ 1 , 3 , 5 ] ;
76+ Assert . Equal ( expected , input . Discard ( x => true ) . ToArray ( ) ) ;
7177 }
7278
7379 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
74- public void Discard_nothing ( )
80+ public void Discards_nothing ( )
7581 {
76- Assert . Equal ( new HashSet < int > { 1 , 2 , 3 } , new HashSet < int > { 1 , 2 , 3 } . Discard ( x => x > 10 ) ) ;
82+ int [ ] expected = [ 1 , 3 , 5 ] ;
83+ int [ ] input = [ 1 , 3 , 5 ] ;
84+ Assert . Equal ( expected , input . Discard ( x => false ) . ToArray ( ) ) ;
7785 }
7886
7987 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
80- public void Discard_first_and_last ( )
88+ public void Discards_first_and_last ( )
8189 {
82- Assert . Equal ( new [ ] { 2 } , new [ ] { 1 , 2 , 3 } . Discard ( x => x % 2 != 0 ) ) ;
90+ int [ ] expected = [ 2 ] ;
91+ int [ ] input = [ 1 , 2 , 3 ] ;
92+ Assert . Equal ( expected , input . Discard ( x => x % 2 == 1 ) . ToArray ( ) ) ;
8393 }
8494
8595 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
86- public void Discard_neither_first_nor_last ( )
96+ public void Discards_neither_first_nor_last ( )
8797 {
88- Assert . Equal ( new List < int > { 1 , 3 , 5 } , new List < int > { 1 , 2 , 3 , 4 , 5 } . Discard ( x => x % 2 == 0 ) ) ;
98+ int [ ] expected = [ 1 , 3 ] ;
99+ int [ ] input = [ 1 , 2 , 3 ] ;
100+ Assert . Equal ( expected , input . Discard ( x => x % 2 == 0 ) . ToArray ( ) ) ;
89101 }
90102
91103 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
92- public void Discard_strings ( )
104+ public void Discards_strings ( )
93105 {
94- var words = "apple zebra banana zombies cherimoya zelot" . Split ( ' ' ) ;
95- Assert . Equal ( "apple banana cherimoya" . Split ( ' ' ) , words . Discard ( x => x . StartsWith ( "z" ) ) ) ;
106+ string [ ] expected = [ "apple" , "banana" , "cherimoya" ] ;
107+ string [ ] input = [ "apple" , "zebra" , "banana" , "zombies" , "cherimoya" , "zealot" ] ;
108+ Assert . Equal ( expected , input . Discard ( x => x . StartsWith ( 'z' ) ) . ToArray ( ) ) ;
96109 }
97110
98111 [ Fact ( Skip = "Remove this Skip property to run this test" ) ]
99- public void Discard_arrays ( )
112+ public void Discards_lists ( )
100113 {
101- var actual = new [ ]
102- {
103- new [ ] { 1 , 2 , 3 } ,
104- new [ ] { 5 , 5 , 5 } ,
105- new [ ] { 5 , 1 , 2 } ,
106- new [ ] { 2 , 1 , 2 } ,
107- new [ ] { 1 , 5 , 2 } ,
108- new [ ] { 2 , 2 , 1 } ,
109- new [ ] { 1 , 2 , 5 }
110- } ;
111- var expected = new [ ] { new [ ] { 1 , 2 , 3 } , new [ ] { 2 , 1 , 2 } , new [ ] { 2 , 2 , 1 } } ;
112- Assert . Equal ( expected , actual . Discard ( x => x . Contains ( 5 ) ) ) ;
114+ int [ ] [ ] expected = [ [ 1 , 2 , 3 ] , [ 2 , 1 , 2 ] , [ 2 , 2 , 1 ] ] ;
115+ int [ ] [ ] input = [ [ 1 , 2 , 3 ] , [ 5 , 5 , 5 ] , [ 5 , 1 , 2 ] , [ 2 , 1 , 2 ] , [ 1 , 5 , 2 ] , [ 2 , 2 , 1 ] , [ 1 , 2 , 5 ] ] ;
116+ Assert . Equal ( expected , input . Discard ( x => x . Contains ( 5 ) ) . ToArray ( ) ) ;
113117 }
114- }
118+ }
0 commit comments