Skip to content

Commit dd2a72d

Browse files
committed
Rename unit test methods for consistency
1 parent 274a3c0 commit dd2a72d

File tree

5 files changed

+62
-73
lines changed

5 files changed

+62
-73
lines changed

tests/CommunityToolkit.Mvvm.UnitTests/Collections/Test_ObservableGroup.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ namespace CommunityToolkit.Mvvm.UnitTests.Collections;
1313
public class Test_ObservableGroup
1414
{
1515
[TestMethod]
16-
public void Ctor_ShouldHaveExpectedState()
16+
public void Test_ObservableGroup_Ctor_ShouldHaveExpectedState()
1717
{
1818
ObservableGroup<string, int> group = new("key");
1919

@@ -22,7 +22,7 @@ public void Ctor_ShouldHaveExpectedState()
2222
}
2323

2424
[TestMethod]
25-
public void Ctor_WithGrouping_ShouldHaveExpectedState()
25+
public void Test_ObservableGroup_Ctor_WithGrouping_ShouldHaveExpectedState()
2626
{
2727
IntGroup source = new("key", new[] { 1, 2, 3 });
2828
ObservableGroup<string, int> group = new(source);
@@ -32,7 +32,7 @@ public void Ctor_WithGrouping_ShouldHaveExpectedState()
3232
}
3333

3434
[TestMethod]
35-
public void Ctor_WithCollection_ShouldHaveExpectedState()
35+
public void Test_ObservableGroup_Ctor_WithCollection_ShouldHaveExpectedState()
3636
{
3737
int[] source = new[] { 1, 2, 3 };
3838
ObservableGroup<string, int> group = new("key", source);
@@ -42,7 +42,7 @@ public void Ctor_WithCollection_ShouldHaveExpectedState()
4242
}
4343

4444
[TestMethod]
45-
public void Add_ShouldRaiseEvent()
45+
public void Test_ObservableGroup_Add_ShouldRaiseEvent()
4646
{
4747
bool collectionChangedEventRaised = false;
4848
int[] source = new[] { 1, 2, 3 };
@@ -58,7 +58,7 @@ public void Add_ShouldRaiseEvent()
5858
}
5959

6060
[TestMethod]
61-
public void Update_ShouldRaiseEvent()
61+
public void Test_ObservableGroup_Update_ShouldRaiseEvent()
6262
{
6363
bool collectionChangedEventRaised = false;
6464
int[] source = new[] { 1, 2, 3 };
@@ -74,7 +74,7 @@ public void Update_ShouldRaiseEvent()
7474
}
7575

7676
[TestMethod]
77-
public void Remove_ShouldRaiseEvent()
77+
public void Test_ObservableGroup_Remove_ShouldRaiseEvent()
7878
{
7979
bool collectionChangedEventRaised = false;
8080
int[] source = new[] { 1, 2, 3 };
@@ -90,7 +90,7 @@ public void Remove_ShouldRaiseEvent()
9090
}
9191

9292
[TestMethod]
93-
public void Clear_ShouldRaiseEvent()
93+
public void Test_ObservableGroup_Clear_ShouldRaiseEvent()
9494
{
9595
bool collectionChangedEventRaised = false;
9696
int[] source = new[] { 1, 2, 3 };
@@ -108,7 +108,7 @@ public void Clear_ShouldRaiseEvent()
108108
[TestMethod]
109109
[DataRow(0)]
110110
[DataRow(3)]
111-
public void IReadOnlyObservableGroup_ShouldReturnExpectedValues(int count)
111+
public void Test_ObservableGroup_IReadOnlyObservableGroup_ShouldReturnExpectedValues(int count)
112112
{
113113
ObservableGroup<string, int> group = new("key", Enumerable.Range(0, count));
114114
IReadOnlyObservableGroup iReadOnlyObservableGroup = group;
@@ -119,35 +119,35 @@ public void IReadOnlyObservableGroup_ShouldReturnExpectedValues(int count)
119119

120120
[TestMethod]
121121
[ExpectedException(typeof(ArgumentNullException))]
122-
public void Ctor_NullKey()
122+
public void Test_ObservableGroup_Ctor_NullKey()
123123
{
124124
_ = new ObservableGroup<string, int>((string)null!);
125125
}
126126

127127
[TestMethod]
128128
[ExpectedException(typeof(ArgumentNullException))]
129-
public void Ctor_NullGroup()
129+
public void Test_ObservableGroup_Ctor_NullGroup()
130130
{
131131
_ = new ObservableGroup<string, int>((IGrouping<string, int>)null!);
132132
}
133133

134134
[TestMethod]
135135
[ExpectedException(typeof(ArgumentNullException))]
136-
public void Ctor_NullKeyWithNotNullElements()
136+
public void Test_ObservableGroup_Ctor_NullKeyWithNotNullElements()
137137
{
138138
_ = new ObservableGroup<string, int>(null!, new int[0]);
139139
}
140140

141141
[TestMethod]
142142
[ExpectedException(typeof(ArgumentNullException))]
143-
public void Ctor_NotNullKeyWithNullElements()
143+
public void Test_ObservableGroup_Ctor_NotNullKeyWithNullElements()
144144
{
145145
_ = new ObservableGroup<string, int>("A", null!);
146146
}
147147

148148
[TestMethod]
149149
[ExpectedException(typeof(ArgumentNullException))]
150-
public void Ctor_NullKeySetter()
150+
public void Test_ObservableGroup_Ctor_NullKeySetter()
151151
{
152152
ObservableGroup<string, int> group = new("A");
153153

tests/CommunityToolkit.Mvvm.UnitTests/Collections/Test_ObservableGroupedCollection.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ namespace CommunityToolkit.Mvvm.UnitTests.Collections;
1414
public class Test_ObservableGroupedCollection
1515
{
1616
[TestMethod]
17-
public void Ctor_ShouldHaveExpectedValues()
17+
public void Test_ObservableGroupedCollection_Ctor_ShouldHaveExpectedValues()
1818
{
1919
ObservableGroupedCollection<string, int> groupCollection = new();
2020

2121
Assert.AreEqual(groupCollection.Count, 0);
2222
}
2323

2424
[TestMethod]
25-
public void Ctor_WithGroups_ShouldHaveExpectedValues()
25+
public void Test_ObservableGroupedCollection_Ctor_WithGroups_ShouldHaveExpectedValues()
2626
{
2727
List<IGrouping<string, int>> groups = new()
2828
{
@@ -42,7 +42,7 @@ public void Ctor_WithGroups_ShouldHaveExpectedValues()
4242

4343
[TestMethod]
4444
[ExpectedException(typeof(ArgumentNullException))]
45-
public void Ctor_NullCollection()
45+
public void Test_ObservableGroupedCollection_Ctor_NullCollection()
4646
{
4747
_ = new ObservableGroupedCollection<string, int>(null!);
4848
}

tests/CommunityToolkit.Mvvm.UnitTests/Collections/Test_ObservableGroupedCollectionExtensions.cs

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace CommunityToolkit.Mvvm.UnitTests.Collections;
1212
public class Test_ObservableGroupedCollectionExtensions
1313
{
1414
[TestMethod]
15-
public void First_WhenGroupExists_ShouldReturnFirstGroup()
15+
public void Test_ObservableGroupedCollectionExtensions_FirstGroupByKey_WhenGroupExists_ShouldReturnFirstGroup()
1616
{
1717
ObservableGroupedCollection<string, int> groupedCollection = new();
1818

@@ -29,7 +29,7 @@ public void First_WhenGroupExists_ShouldReturnFirstGroup()
2929

3030
[TestMethod]
3131
[ExpectedException(typeof(InvalidOperationException))]
32-
public void First_WhenGroupDoesNotExist_ShouldThrow()
32+
public void Test_ObservableGroupedCollectionExtensions_FirstGroupByKey_WhenGroupDoesNotExist_ShouldThrow()
3333
{
3434
ObservableGroupedCollection<string, int> groupedCollection = new();
3535

@@ -39,7 +39,7 @@ public void First_WhenGroupDoesNotExist_ShouldThrow()
3939
}
4040

4141
[TestMethod]
42-
public void FirstOrDefault_WhenGroupExists_ShouldReturnFirstGroup()
42+
public void Test_ObservableGroupedCollectionExtensions_FirstGroupByKeyOrDefault_WhenGroupExists_ShouldReturnFirstGroup()
4343
{
4444
ObservableGroupedCollection<string, int> groupedCollection = new();
4545

@@ -55,7 +55,7 @@ public void FirstOrDefault_WhenGroupExists_ShouldReturnFirstGroup()
5555
}
5656

5757
[TestMethod]
58-
public void FirstOrDefault_WhenGroupDoesNotExist_ShouldReturnNull()
58+
public void Test_ObservableGroupedCollectionExtensions_FirstGroupByKeyOrDefault_WhenGroupDoesNotExist_ShouldReturnNull()
5959
{
6060
ObservableGroupedCollection<string, int> groupedCollection = new();
6161

@@ -67,7 +67,7 @@ public void FirstOrDefault_WhenGroupDoesNotExist_ShouldReturnNull()
6767
}
6868

6969
[TestMethod]
70-
public void ElementAt_WhenGroupExistsAndIndexInRange_ShouldReturnFirstGroupValue()
70+
public void Test_ObservableGroupedCollectionExtensions_FirstGroupByKey_WhenGroupExistsAndIndexInRange_ShouldReturnFirstGroupValue()
7171
{
7272
ObservableGroupedCollection<string, int> groupedCollection = new();
7373

@@ -84,7 +84,7 @@ public void ElementAt_WhenGroupExistsAndIndexInRange_ShouldReturnFirstGroupValue
8484
[DataRow(-1)]
8585
[DataRow(3)]
8686
[ExpectedException(typeof(ArgumentOutOfRangeException))]
87-
public void ElementAt_WhenGroupExistsAndIndexOutOfRange_ShouldReturnThrow(int index)
87+
public void Test_ObservableGroupedCollectionExtensions_FirstGroupByKey_WhenGroupExistsAndIndexOutOfRange_ShouldReturnThrow(int index)
8888
{
8989
ObservableGroupedCollection<string, int> groupedCollection = new();
9090

@@ -96,18 +96,7 @@ public void ElementAt_WhenGroupExistsAndIndexOutOfRange_ShouldReturnThrow(int in
9696
}
9797

9898
[TestMethod]
99-
[ExpectedException(typeof(InvalidOperationException))]
100-
public void ElementAt_WhenGroupDoesNotExist_ShouldThrow()
101-
{
102-
ObservableGroupedCollection<string, int> groupedCollection = new();
103-
104-
_ = groupedCollection.AddGroup("A", new[] { 23 });
105-
106-
_ = groupedCollection.FirstGroupByKey("I do not exist")[0];
107-
}
108-
109-
[TestMethod]
110-
public void ElementAtOrDefault_WhenGroupExistsAndIndexInRange_ShouldReturnValue()
99+
public void Test_ObservableGroupedCollectionExtensions_FirstGroupByKey_WhenGroupExistsAndIndexInRange_ShouldReturnValue()
111100
{
112101
ObservableGroupedCollection<string, int> groupedCollection = new();
113102

@@ -121,7 +110,7 @@ public void ElementAtOrDefault_WhenGroupExistsAndIndexInRange_ShouldReturnValue(
121110
}
122111

123112
[TestMethod]
124-
public void AddGroup_WithItem_ShouldAddGroup()
113+
public void Test_ObservableGroupedCollectionExtensions_AddGroup_WithItem_ShouldAddGroup()
125114
{
126115
ObservableGroupedCollection<string, int> groupedCollection = new();
127116

@@ -134,7 +123,7 @@ public void AddGroup_WithItem_ShouldAddGroup()
134123
}
135124

136125
[TestMethod]
137-
public void AddGroup_WithCollection_ShouldAddGroup()
126+
public void Test_ObservableGroupedCollectionExtensions_AddGroup_WithCollection_ShouldAddGroup()
138127
{
139128
ObservableGroupedCollection<string, int> groupedCollection = new();
140129

@@ -147,7 +136,7 @@ public void AddGroup_WithCollection_ShouldAddGroup()
147136
}
148137

149138
[TestMethod]
150-
public void AddGroup_WithParamsCollection_ShouldAddGroup()
139+
public void Test_ObservableGroupedCollectionExtensions_AddGroup_WithParamsCollection_ShouldAddGroup()
151140
{
152141
ObservableGroupedCollection<string, int> groupedCollection = new();
153142

@@ -160,7 +149,7 @@ public void AddGroup_WithParamsCollection_ShouldAddGroup()
160149
}
161150

162151
[TestMethod]
163-
public void AddItem_WhenTargetGroupDoesNotExists_ShouldCreateAndAddNewGroup()
152+
public void Test_ObservableGroupedCollectionExtensions_AddItem_WhenTargetGroupDoesNotExists_ShouldCreateAndAddNewGroup()
164153
{
165154
ObservableGroupedCollection<string, int> groupedCollection = new();
166155

@@ -173,7 +162,7 @@ public void AddItem_WhenTargetGroupDoesNotExists_ShouldCreateAndAddNewGroup()
173162
}
174163

175164
[TestMethod]
176-
public void AddItem_WhenSingleTargetGroupAlreadyExists_ShouldAddItemToExistingGroup()
165+
public void Test_ObservableGroupedCollectionExtensions_AddItem_WhenSingleTargetGroupAlreadyExists_ShouldAddItemToExistingGroup()
177166
{
178167
ObservableGroupedCollection<string, int> groupedCollection = new();
179168

@@ -202,7 +191,7 @@ public void AddItem_WhenSingleTargetGroupAlreadyExists_ShouldAddItemToExistingGr
202191
}
203192

204193
[TestMethod]
205-
public void AddItem_WhenSeveralTargetGroupsAlreadyExist_ShouldAddItemToFirstExistingGroup()
194+
public void Test_ObservableGroupedCollectionExtensions_AddItem_WhenSeveralTargetGroupsAlreadyExist_ShouldAddItemToFirstExistingGroup()
206195
{
207196
ObservableGroupedCollection<string, int> groupedCollection = new();
208197

@@ -235,7 +224,7 @@ public void AddItem_WhenSeveralTargetGroupsAlreadyExist_ShouldAddItemToFirstExis
235224
}
236225

237226
[TestMethod]
238-
public void RemoveGroup_WhenGroupDoesNotExists_ShouldDoNothing()
227+
public void Test_ObservableGroupedCollectionExtensions_RemoveGroup_WhenGroupDoesNotExists_ShouldDoNothing()
239228
{
240229
ObservableGroupedCollection<string, int> groupedCollection = new();
241230

@@ -249,7 +238,7 @@ public void RemoveGroup_WhenGroupDoesNotExists_ShouldDoNothing()
249238
}
250239

251240
[TestMethod]
252-
public void RemoveGroup_WhenSingleGroupExists_ShouldRemoveGroup()
241+
public void Test_ObservableGroupedCollectionExtensions_RemoveGroup_WhenSingleGroupExists_ShouldRemoveGroup()
253242
{
254243
ObservableGroupedCollection<string, int> groupedCollection = new();
255244

@@ -264,7 +253,7 @@ public void RemoveGroup_WhenSingleGroupExists_ShouldRemoveGroup()
264253
}
265254

266255
[TestMethod]
267-
public void RemoveGroup_WhenSeveralGroupsExist_ShouldRemoveFirstGroup()
256+
public void Test_ObservableGroupedCollectionExtensions_RemoveGroup_WhenSeveralGroupsExist_ShouldRemoveFirstGroup()
268257
{
269258
ObservableGroupedCollection<string, int> groupedCollection = new();
270259

@@ -286,7 +275,7 @@ public void RemoveGroup_WhenSeveralGroupsExist_ShouldRemoveFirstGroup()
286275
[TestMethod]
287276
[DataRow(true)]
288277
[DataRow(false)]
289-
public void RemoveItem_WhenGroupDoesNotExist_ShouldDoNothing(bool removeGroupIfEmpty)
278+
public void Test_ObservableGroupedCollectionExtensions_RemoveItem_WhenGroupDoesNotExist_ShouldDoNothing(bool removeGroupIfEmpty)
290279
{
291280
ObservableGroupedCollection<string, int> groupedCollection = new();
292281

@@ -307,7 +296,7 @@ public void RemoveItem_WhenGroupDoesNotExist_ShouldDoNothing(bool removeGroupIfE
307296
[TestMethod]
308297
[DataRow(true)]
309298
[DataRow(false)]
310-
public void RemoveItem_WhenGroupExistsAndItemDoesNotExist_ShouldDoNothing(bool removeGroupIfEmpty)
299+
public void Test_ObservableGroupedCollectionExtensions_RemoveItem_WhenGroupExistsAndItemDoesNotExist_ShouldDoNothing(bool removeGroupIfEmpty)
311300
{
312301
ObservableGroupedCollection<string, int> groupedCollection = new();
313302

@@ -328,7 +317,7 @@ public void RemoveItem_WhenGroupExistsAndItemDoesNotExist_ShouldDoNothing(bool r
328317
[TestMethod]
329318
[DataRow(true)]
330319
[DataRow(false)]
331-
public void RemoveItem_WhenGroupAndItemExist_ShouldRemoveItemFromGroup(bool removeGroupIfEmpty)
320+
public void Test_ObservableGroupedCollectionExtensions_RemoveItem_WhenGroupAndItemExist_ShouldRemoveItemFromGroup(bool removeGroupIfEmpty)
332321
{
333322
ObservableGroupedCollection<string, int> groupedCollection = new();
334323

@@ -349,7 +338,7 @@ public void RemoveItem_WhenGroupAndItemExist_ShouldRemoveItemFromGroup(bool remo
349338
[TestMethod]
350339
[DataRow(true, true)]
351340
[DataRow(false, false)]
352-
public void RemoveItem_WhenRemovingLastItem_ShouldRemoveGroupIfRequired(bool removeGroupIfEmpty, bool expectGroupRemoved)
341+
public void Test_ObservableGroupedCollectionExtensions_RemoveItem_WhenRemovingLastItem_ShouldRemoveGroupIfRequired(bool removeGroupIfEmpty, bool expectGroupRemoved)
353342
{
354343
ObservableGroupedCollection<string, int> groupedCollection = new();
355344

0 commit comments

Comments
 (0)