1+ // ---------------------------------------------------------------------------------------------------------------------
2+ // Imports
3+ // ---------------------------------------------------------------------------------------------------------------------
4+ using CodeOfChaos . Extensions ;
5+
6+ namespace Tests . CodeOfChaos . Extensions ;
7+
8+ // ---------------------------------------------------------------------------------------------------------------------
9+ // Code
10+ // ---------------------------------------------------------------------------------------------------------------------
11+ public class StringCaseExtensionTests {
12+
13+ // Tests for ToCamelCase
14+ [ Test ]
15+ [ Arguments ( "a" , "a" ) ]
16+ [ Arguments ( "A" , "a" ) ]
17+ [ Arguments ( "aA" , "aA" ) ]
18+ [ Arguments ( "aa" , "aa" ) ]
19+ [ Arguments ( "aaA" , "aaA" ) ]
20+ [ Arguments ( "a1a" , "a1A" ) ]
21+ [ Arguments ( "AlphaBeta" , "alphaBeta" ) ]
22+ [ Arguments ( "AlphaBetaGamma" , "alphaBetaGamma" ) ]
23+ [ Arguments ( "AlphaBetaGammaDelta" , "alphaBetaGammaDelta" ) ]
24+ [ Arguments ( "snake_case" , "snakeCase" ) ]
25+ [ Arguments ( "snake_case_with_numbers_123" , "snakeCaseWithNumbers123" ) ]
26+ [ Arguments ( "snake_case_with_numbers_123_and_more" , "snakeCaseWithNumbers123AndMore" ) ]
27+ [ Arguments ( "period.case" , "periodCase" ) ]
28+ [ Arguments ( "period.case.with.numbers.123" , "periodCaseWithNumbers123" ) ]
29+ [ Arguments ( "period.case.with.numbers.123.and.more" , "periodCaseWithNumbers123AndMore" ) ]
30+ [ Arguments ( "kebab-case" , "kebabCase" ) ]
31+ [ Arguments ( "kebab-case-with-numbers-123" , "kebabCaseWithNumbers123" ) ]
32+ [ Arguments ( "kebab-case-with-numbers-123-and-more" , "kebabCaseWithNumbers123AndMore" ) ]
33+ public async Task ToCamelCase_ShouldWork ( string input , string expected ) {
34+ // Arrange
35+
36+ // Act
37+ var result = input . ToCamelCase ( ) ;
38+
39+ // Assert
40+ await Assert . That ( result ) . IsEqualTo ( expected ) ;
41+ }
42+
43+ // Tests for ToPascalCase
44+ [ Test ]
45+ [ Arguments ( "a" , "A" ) ]
46+ [ Arguments ( "A" , "A" ) ]
47+ [ Arguments ( "aA" , "AA" ) ]
48+ [ Arguments ( "aa" , "Aa" ) ]
49+ [ Arguments ( "aaA" , "AaA" ) ]
50+ [ Arguments ( "a1a" , "A1A" ) ]
51+ [ Arguments ( "AlphaBeta" , "AlphaBeta" ) ]
52+ [ Arguments ( "AlphaBetaGamma" , "AlphaBetaGamma" ) ]
53+ [ Arguments ( "AlphaBetaGammaDelta" , "AlphaBetaGammaDelta" ) ]
54+ [ Arguments ( "snake_case" , "SnakeCase" ) ]
55+ [ Arguments ( "snake_case_with_numbers_123" , "SnakeCaseWithNumbers123" ) ]
56+ [ Arguments ( "snake_case_with_numbers_123_and_more" , "SnakeCaseWithNumbers123AndMore" ) ]
57+ [ Arguments ( "period.case" , "PeriodCase" ) ]
58+ [ Arguments ( "period.case.with.numbers.123" , "PeriodCaseWithNumbers123" ) ]
59+ [ Arguments ( "period.case.with.numbers.123.and.more" , "PeriodCaseWithNumbers123AndMore" ) ]
60+ [ Arguments ( "kebab-case" , "KebabCase" ) ]
61+ [ Arguments ( "kebab-case-with-numbers-123" , "KebabCaseWithNumbers123" ) ]
62+ [ Arguments ( "kebab-case-with-numbers-123-and-more" , "KebabCaseWithNumbers123AndMore" ) ]
63+ public async Task ToPascalCase_ShouldWork ( string input , string expected ) {
64+ // Arrange
65+
66+ // Act
67+ var result = input . ToPascalCase ( ) ;
68+
69+ // Assert
70+ await Assert . That ( result ) . IsEqualTo ( expected ) ;
71+ }
72+
73+ // Tests for ToKebabCase
74+ [ Test ]
75+ [ Arguments ( "a" , "a" ) ]
76+ [ Arguments ( "A" , "a" ) ]
77+ [ Arguments ( "aA" , "a-a" ) ]
78+ [ Arguments ( "aa" , "aa" ) ]
79+ [ Arguments ( "aaA" , "aa-a" ) ]
80+ [ Arguments ( "a1a" , "a-1-a" ) ]
81+ [ Arguments ( "AlphaBeta" , "alpha-beta" ) ]
82+ [ Arguments ( "AlphaBetaGamma" , "alpha-beta-gamma" ) ]
83+ [ Arguments ( "AlphaBetaGammaDelta" , "alpha-beta-gamma-delta" ) ]
84+ [ Arguments ( "snake_case" , "snake-case" ) ]
85+ [ Arguments ( "snake_case_with_numbers_123" , "snake-case-with-numbers-123" ) ]
86+ [ Arguments ( "snake_case_with_numbers_123_and_more" , "snake-case-with-numbers-123-and-more" ) ]
87+ [ Arguments ( "period.case" , "period-case" ) ]
88+ [ Arguments ( "period.case.with.numbers.123" , "period-case-with-numbers-123" ) ]
89+ [ Arguments ( "period.case.with.numbers.123.and.more" , "period-case-with-numbers-123-and-more" ) ]
90+ [ Arguments ( "kebab-case" , "kebab-case" ) ]
91+ [ Arguments ( "kebab-case-with-numbers-123" , "kebab-case-with-numbers-123" ) ]
92+ [ Arguments ( "kebab-case-with-numbers-123-and-more" , "kebab-case-with-numbers-123-and-more" ) ]
93+ public async Task ToKebabCase_ShouldWork ( string input , string expected ) {
94+ // Arrange
95+
96+ // Act
97+ var result = input . ToKebabCase ( ) ;
98+
99+ // Assert
100+ await Assert . That ( result ) . IsEqualTo ( expected ) ;
101+ }
102+
103+ // Tests for ToSnakeCase
104+ [ Test ]
105+ [ Arguments ( "a" , "a" ) ]
106+ [ Arguments ( "A" , "a" ) ]
107+ [ Arguments ( "aA" , "a_a" ) ]
108+ [ Arguments ( "aa" , "aa" ) ]
109+ [ Arguments ( "aaA" , "aa_a" ) ]
110+ [ Arguments ( "a1a" , "a_1_a" ) ]
111+ [ Arguments ( "AlphaBeta" , "alpha_beta" ) ]
112+ [ Arguments ( "AlphaBetaGamma" , "alpha_beta_gamma" ) ]
113+ [ Arguments ( "AlphaBetaGammaDelta" , "alpha_beta_gamma_delta" ) ]
114+ [ Arguments ( "snake_case" , "snake_case" ) ]
115+ [ Arguments ( "snake_case_with_numbers_123" , "snake_case_with_numbers_123" ) ]
116+ [ Arguments ( "snake_case_with_numbers_123_and_more" , "snake_case_with_numbers_123_and_more" ) ]
117+ [ Arguments ( "period.case" , "period_case" ) ]
118+ [ Arguments ( "period.case.with.numbers.123" , "period_case_with_numbers_123" ) ]
119+ [ Arguments ( "period.case.with.numbers.123.and.more" , "period_case_with_numbers_123_and_more" ) ]
120+ [ Arguments ( "kebab-case" , "kebab_case" ) ]
121+ [ Arguments ( "kebab-case-with-numbers-123" , "kebab_case_with_numbers_123" ) ]
122+ [ Arguments ( "kebab-case-with-numbers-123-and-more" , "kebab_case_with_numbers_123_and_more" ) ]
123+ public async Task ToSnakeCase_ShouldWork ( string input , string expected ) {
124+ // Arrange
125+
126+ // Act
127+ var result = input . ToSnakeCase ( ) ;
128+
129+ // Assert
130+ await Assert . That ( result ) . IsEqualTo ( expected ) ;
131+ }
132+
133+ // Tests for ToPeriodSeparatedCase
134+ [ Test ]
135+ [ Arguments ( "a" , "a" ) ]
136+ [ Arguments ( "A" , "a" ) ]
137+ [ Arguments ( "aA" , "a.a" ) ]
138+ [ Arguments ( "aa" , "aa" ) ]
139+ [ Arguments ( "aaA" , "aa.a" ) ]
140+ [ Arguments ( "a1a" , "a.1.a" ) ]
141+ [ Arguments ( "AlphaBeta" , "alpha.beta" ) ]
142+ [ Arguments ( "AlphaBetaGamma" , "alpha.beta.gamma" ) ]
143+ [ Arguments ( "AlphaBetaGammaDelta" , "alpha.beta.gamma.delta" ) ]
144+ [ Arguments ( "snake_case" , "snake.case" ) ]
145+ [ Arguments ( "snake_case_with_numbers_123" , "snake.case.with.numbers.123" ) ]
146+ [ Arguments ( "snake_case_with_numbers_123_and_more" , "snake.case.with.numbers.123.and.more" ) ]
147+ [ Arguments ( "period.case" , "period.case" ) ]
148+ [ Arguments ( "period.case.with.numbers.123" , "period.case.with.numbers.123" ) ]
149+ [ Arguments ( "period.case.with.numbers.123.and.more" , "period.case.with.numbers.123.and.more" ) ]
150+ [ Arguments ( "kebab-case" , "kebab.case" ) ]
151+ [ Arguments ( "kebab-case-with-numbers-123" , "kebab.case.with.numbers.123" ) ]
152+ [ Arguments ( "kebab-case-with-numbers-123-and-more" , "kebab.case.with.numbers.123.and.more" ) ]
153+ public async Task ToPeriodSeparatedCase_ShouldWork ( string input , string expected ) {
154+ // Arrange
155+
156+ // Act
157+ var result = input . ToPeriodSeparatedCase ( ) ;
158+
159+ // Assert
160+ await Assert . That ( result ) . IsEqualTo ( expected ) ;
161+ }
162+ }
0 commit comments