@@ -17,28 +17,28 @@ public void SetUp()
1717 }
1818
1919 [ Test ]
20- public void no_stats_if_no_words ( )
20+ public void should_be_empty_if_no_words ( )
2121 {
2222 CollectionAssert . IsEmpty ( stat . GetStatistics ( ) ) ;
2323 }
2424
2525 [ Test ]
26- public void same_word_twice ( )
27- {
28- stat . AddWord ( "xxx" ) ;
29- stat . AddWord ( "xxx" ) ;
30- CollectionAssert . AreEqual ( new [ ] { Tuple . Create ( 2 , "xxx" ) } , stat . GetStatistics ( ) ) ;
31- }
32-
33- [ Test ]
34- public void single_word ( )
26+ public void should_return_one_tuple_if_used_single_word ( )
3527 {
3628 stat . AddWord ( "hello" ) ;
3729 CollectionAssert . AreEqual ( new [ ] { Tuple . Create ( 1 , "hello" ) } , stat . GetStatistics ( ) ) ;
38- }
30+ }
31+
32+ [ Test ]
33+ public void should_return_one_tuple_if_used_same_word_twice ( )
34+ {
35+ stat . AddWord ( "xxx" ) ;
36+ stat . AddWord ( "xxx" ) ;
37+ CollectionAssert . AreEqual ( new [ ] { Tuple . Create ( 2 , "xxx" ) } , stat . GetStatistics ( ) ) ;
38+ }
3939
4040 [ Test ]
41- public void two_same_words_one_other ( )
41+ public void should_return_single_tuple_for_same_words ( )
4242 {
4343 stat . AddWord ( "hello" ) ;
4444 stat . AddWord ( "world" ) ;
@@ -48,58 +48,90 @@ public void two_same_words_one_other()
4848 }
4949
5050 [ Test ]
51- public void empty_word ( )
51+ public void should_return_one_tuple_if_used_empty_word ( )
5252 {
5353 stat . AddWord ( "" ) ;
5454 var s = stat . GetStatistics ( ) ;
5555 CollectionAssert . AreNotEqual ( new [ ] { Tuple . Create ( 1 , "" ) } , stat . GetStatistics ( ) ) ;
5656 }
5757
5858 [ Test ]
59- public void two_same_words_length_more_10_chars ( )
60- {
61- stat . AddWord ( "aaaaaaaaaaab" ) ;
62- stat . AddWord ( "aaaaaaaaaaaa" ) ;
63- CollectionAssert . AreEqual ( new [ ] { Tuple . Create ( 2 , "aaaaaaaaaa" ) } , stat . GetStatistics ( ) ) ;
64- }
65-
66- [ Test ]
67- public void two_words_diff_regs ( )
59+ public void should_return_one_tuple_if_used_two_same_words_in_different_registers ( )
6860 {
6961 stat . AddWord ( "AAAA" ) ;
7062 stat . AddWord ( "aaaa" ) ;
7163 CollectionAssert . AreEqual ( new [ ] { Tuple . Create ( 2 , "aaaa" ) } , stat . GetStatistics ( ) ) ;
7264 }
7365
7466 [ Test ]
75- public void sorting_words ( )
67+ public void should_return_tuples_sorted_alphabetically_if_used_same_number_of_words ( )
7668 {
7769 stat . AddWord ( "a" ) ;
7870 stat . AddWord ( "b" ) ;
7971 CollectionAssert . AreEqual ( ( new [ ] { Tuple . Create ( 1 , "a" ) , Tuple . Create ( 1 , "b" ) } ) , stat . GetStatistics ( ) ) ;
8072 }
8173
8274 [ Test ]
83- public void null_test ( )
75+ public void should_be_empty_if_used_null_word ( )
8476 {
8577 stat . AddWord ( null ) ;
8678 Assert . AreEqual ( 0 , stat . GetStatistics ( ) . Count ( ) ) ;
8779
8880 }
8981
9082 [ Test ]
91- public void eleventh_symbol ( )
83+ public void should_return_one_tuple_if_difference_is_in_eleventh_symbol ( )
9284 {
9385 stat . AddWord ( "aaaaaaaaaaa" ) ;
9486 stat . AddWord ( "aaaaaaaaaab" ) ;
9587 CollectionAssert . AreEqual ( new [ ] { Tuple . Create ( 2 , "aaaaaaaaaa" ) } , stat . GetStatistics ( ) ) ;
9688 }
9789
9890 [ Test ]
99- public void non_english ( )
91+ public void should_work_with_non_english_and_russian_letters ( )
92+ {
93+ stat . AddWord ( "Ä" ) ;
94+ CollectionAssert . AreEqual ( new [ ] { Tuple . Create ( 1 , "ä" ) } , stat . GetStatistics ( ) ) ;
95+ }
96+
97+ [ Test ]
98+ public void two_statistics_must_not_interfere ( )
99+ {
100+ var stat2 = createStat ( ) ;
101+ stat . AddWord ( "a" ) ;
102+ Assert . AreEqual ( 0 , stat2 . GetStatistics ( ) . Count ( ) ) ;
103+ }
104+
105+ [ Test , Timeout ( 2000 ) ]
106+ public void can_handle_big_number_of_words ( )
107+ {
108+ for ( var i = 0 ; i < 1000 ; i ++ )
109+ {
110+
111+ for ( var j = 0 ; j < i ; j ++ )
112+ {
113+ stat . AddWord ( i . ToString ( ) ) ;
114+ }
115+ }
116+
117+ var s = stat . GetStatistics ( ) . ToList ( ) ;
118+
119+ for ( var i = 0 ; i < 1000 - 2 ; i ++ )
120+ Assert . GreaterOrEqual ( s [ i ] . Item1 , s [ i + 1 ] . Item1 ) ;
121+ }
122+
123+ [ Test ]
124+ public void groups_check ( )
100125 {
101- stat . AddWord ( "Ä ä)" ) ;
102- CollectionAssert . AreEqual ( new [ ] { Tuple . Create ( 1 , "hello" ) } , stat . GetStatistics ( ) ) ;
126+ stat . AddWord ( "3" ) ;
127+ stat . AddWord ( "3" ) ;
128+ stat . AddWord ( "2" ) ;
129+ stat . AddWord ( "2" ) ;
130+ stat . AddWord ( "1" ) ;
131+ stat . AddWord ( "1" ) ;
132+ stat . AddWord ( "0" ) ;
133+ stat . AddWord ( "0" ) ;
134+ CollectionAssert . AreEqual ( new [ ] { Tuple . Create ( 2 , "0" ) , Tuple . Create ( 2 , "1" ) , Tuple . Create ( 2 , "2" ) , Tuple . Create ( 2 , "3" ) } , stat . GetStatistics ( ) ) ;
103135 }
104136 }
105137}
0 commit comments