1- namespace AgileObjects . ReadableExpressions . UnitTests . Extensions
2- {
3- using System . Collections ;
4- using System . Collections . Generic ;
5- using Common ;
6- using ReadableExpressions . Extensions ;
7- #if ! NET35
8- using Xunit ;
9- #else
10- using Fact = NUnit . Framework . TestAttribute ;
11-
12- [ NUnit . Framework . TestFixture ]
1+ namespace AgileObjects . ReadableExpressions . UnitTests . Extensions ;
2+
3+ using System . Collections ;
4+ using System . Collections . Generic ;
5+ using ReadableExpressions . Extensions ;
6+
7+ #if NET35
8+ [ NUnitTestFixture ]
139#endif
14- public class WhenGeneratingVariableNames
10+ public class WhenGeneratingVariableNames
11+ {
12+ [ Fact ]
13+ public void ShouldNameAStringVariable ( )
14+ {
15+ typeof ( string ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "string" ) ;
16+ }
17+
18+ [ Fact ]
19+ public void ShouldNameAnArrayTypeVariable ( )
20+ {
21+ typeof ( Box [ ] ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "boxArray" ) ;
22+ }
23+
24+ [ Fact ]
25+ public void ShouldNameAnIEnumerableTypeVariable ( )
26+ {
27+ typeof ( IEnumerable < Fuzz > ) . GetVariableNameInPascalCase ( ) . ShouldBe ( "FuzzIEnumerable" ) ;
28+ }
29+
30+ [ Fact ]
31+ public void ShouldNameAnICollectionTypeVariable ( )
32+ {
33+ typeof ( ICollection < Box > ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "boxICollection" ) ;
34+ }
35+
36+ [ Fact ]
37+ public void ShouldNameAnIListTypeVariable ( )
38+ {
39+ typeof ( IList < Body > ) . GetVariableNameInPascalCase ( ) . ShouldBe ( "BodyIList" ) ;
40+ }
41+
42+ [ Fact ]
43+ public void ShouldNameAListTypeVariable ( )
44+ {
45+ typeof ( List < Church > ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "churchList" ) ;
46+ }
47+
48+ [ Fact ]
49+ public void ShouldNameAHashSetTypeVariable ( )
50+ {
51+ typeof ( HashSet < int > ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "intHashSet" ) ;
52+ }
53+
54+ [ Fact ]
55+ public void ShouldNameAnArrayListVariable ( )
1556 {
16- [ Fact ]
17- public void ShouldNameAStringVariable ( )
18- {
19- typeof ( string ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "string" ) ;
20- }
21-
22- [ Fact ]
23- public void ShouldNameAnArrayTypeVariable ( )
24- {
25- typeof ( Box [ ] ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "boxArray" ) ;
26- }
27-
28- [ Fact ]
29- public void ShouldNameAnIEnumerableTypeVariable ( )
30- {
31- typeof ( IEnumerable < Fuzz > ) . GetVariableNameInPascalCase ( ) . ShouldBe ( "FuzzIEnumerable" ) ;
32- }
33-
34- [ Fact ]
35- public void ShouldNameAnICollectionTypeVariable ( )
36- {
37- typeof ( ICollection < Box > ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "boxICollection" ) ;
38- }
39-
40- [ Fact ]
41- public void ShouldNameAnIListTypeVariable ( )
42- {
43- typeof ( IList < Body > ) . GetVariableNameInPascalCase ( ) . ShouldBe ( "BodyIList" ) ;
44- }
45-
46- [ Fact ]
47- public void ShouldNameAListTypeVariable ( )
48- {
49- typeof ( List < Church > ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "churchList" ) ;
50- }
51-
52- [ Fact ]
53- public void ShouldNameAHashSetTypeVariable ( )
54- {
55- typeof ( HashSet < int > ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "intHashSet" ) ;
56- }
57-
58- [ Fact ]
59- public void ShouldNameAnArrayListVariable ( )
60- {
61- typeof ( ArrayList ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "arrayList" ) ;
62- }
63-
64- [ Fact ]
65- public void ShouldNameADictionaryTypeVariable ( )
66- {
67- typeof ( Dictionary < string , Church > ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "stringChurchDictionary" ) ;
68- }
69-
70- [ Fact ]
71- public void ShouldNameANullableLongVariable ( )
72- {
73- typeof ( long ? ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "nullableLong" ) ;
74- }
75-
76- [ Fact ]
77- public void ShouldNameAnArrayOfArraysVariable ( )
78- {
79- typeof ( int ? [ ] [ ] ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "nullableIntArrayArray" ) ;
80- }
81-
82- // See https://github.com/agileobjects/ReadableExpressions/issues/48
83- [ Fact ]
84- public void ShouldNameAGenericTypeInnerClassVariable ( )
85- {
86- typeof ( Issue48 < int > . Inner )
87- . GetVariableNameInPascalCase ( )
88- . ShouldBe ( $ "{ nameof ( WhenGeneratingVariableNames ) } _IntIssue48_Inner") ;
89- }
90-
91- [ Fact ]
92- public void ShouldNameAGenericGenericTypeArgument ( )
93- {
94- typeof ( Dictionary < int , Dictionary < string , List < byte > > > )
95- . GetVariableNameInPascalCase ( )
96- . ShouldBe ( "IntStringByteListDictionaryDictionary" ) ;
97- }
98-
99- #region Helper Members
100-
101- // ReSharper disable ClassNeverInstantiated.Local
102- private class Box { }
103-
104- private class Fuzz { }
105-
106- private class Church { }
107-
108- private class Body { }
109-
110- // ReSharper disable once UnusedTypeParameter
111- private class Issue48 < T >
112- {
113- public class Inner { }
114- }
115- // ReSharper restore ClassNeverInstantiated.Local
116-
117- #endregion
57+ typeof ( ArrayList ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "arrayList" ) ;
11858 }
119- }
59+
60+ [ Fact ]
61+ public void ShouldNameADictionaryTypeVariable ( )
62+ {
63+ typeof ( Dictionary < string , Church > ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "stringChurchDictionary" ) ;
64+ }
65+
66+ [ Fact ]
67+ public void ShouldNameANullableLongVariable ( )
68+ {
69+ typeof ( long ? ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "nullableLong" ) ;
70+ }
71+
72+ [ Fact ]
73+ public void ShouldNameAnArrayOfArraysVariable ( )
74+ {
75+ typeof ( int ? [ ] [ ] ) . GetVariableNameInCamelCase ( ) . ShouldBe ( "nullableIntArrayArray" ) ;
76+ }
77+
78+ // See https://github.com/agileobjects/ReadableExpressions/issues/48
79+ [ Fact ]
80+ public void ShouldNameAGenericTypeInnerClassVariable ( )
81+ {
82+ typeof ( Issue48 < int > . Inner )
83+ . GetVariableNameInPascalCase ( )
84+ . ShouldBe ( $ "{ nameof ( WhenGeneratingVariableNames ) } _IntIssue48_Inner") ;
85+ }
86+
87+ [ Fact ]
88+ public void ShouldNameAGenericGenericTypeArgument ( )
89+ {
90+ typeof ( Dictionary < int , Dictionary < string , List < byte > > > )
91+ . GetVariableNameInPascalCase ( )
92+ . ShouldBe ( "IntStringByteListDictionaryDictionary" ) ;
93+ }
94+
95+ #region Helper Members
96+
97+ // ReSharper disable ClassNeverInstantiated.Local
98+ private class Box { }
99+
100+ private class Fuzz { }
101+
102+ private class Church { }
103+
104+ private class Body { }
105+
106+ // ReSharper disable once UnusedTypeParameter
107+ private class Issue48 < T >
108+ {
109+ public class Inner { }
110+ }
111+ // ReSharper restore ClassNeverInstantiated.Local
112+
113+ #endregion
114+ }
0 commit comments