Skip to content

Commit 186ff01

Browse files
committed
Remove unnecessary constructor
1 parent 257250d commit 186ff01

File tree

4 files changed

+4
-44
lines changed

4 files changed

+4
-44
lines changed

CommunityToolkit.Mvvm/Collections/ReadOnlyObservableGroupedCollection{TKey,TValue}.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,6 @@ public ReadOnlyObservableGroupedCollection(IEnumerable<ReadOnlyObservableGroup<T
3838
{
3939
}
4040

41-
/// <summary>
42-
/// Initializes a new instance of the <see cref="ReadOnlyObservableGroupedCollection{TKey, TValue}"/> class.
43-
/// </summary>
44-
/// <param name="collection">The initial data to add in the grouped collection.</param>
45-
public ReadOnlyObservableGroupedCollection(IEnumerable<IGrouping<TKey, TValue>> collection)
46-
: this(collection.Select(static g => new ReadOnlyObservableGroup<TKey, TValue>(g.Key, g)))
47-
{
48-
}
49-
5041
private void OnSourceCollectionChanged(object? sender, NotifyCollectionChangedEventArgs e)
5142
{
5243
// Even if NotifyCollectionChangedEventArgs allows multiple items, the actual implementation

CommunityToolkit.Mvvm/Collections/ReadOnlyObservableGroup{TKey,TValue}.cs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
using System.Collections.Generic;
65
using System.Collections.ObjectModel;
76
using System.Linq;
87

@@ -37,17 +36,6 @@ public ReadOnlyObservableGroup(ObservableGroup<TKey, TValue> group)
3736
Key = group.Key;
3837
}
3938

40-
/// <summary>
41-
/// Initializes a new instance of the <see cref="ReadOnlyObservableGroup{TKey, TValue}"/> class.
42-
/// </summary>
43-
/// <param name="key">The key of the group.</param>
44-
/// <param name="collection">The collection of items to add in the group.</param>
45-
public ReadOnlyObservableGroup(TKey key, IEnumerable<TValue> collection)
46-
: base(new ObservableCollection<TValue>(collection))
47-
{
48-
Key = key;
49-
}
50-
5139
/// <inheritdoc/>
5240
public TKey Key { get; }
5341

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void Ctor_ObservableGroup_ShouldHaveExpectedInitialState()
3838
[TestMethod]
3939
public void Ctor_WithKeyAndCollection_ShouldHaveExpectedInitialState()
4040
{
41-
int[]? source = new[] { 1, 2, 3 };
41+
ObservableCollection<int> source = new() { 1, 2, 3 };
4242
ReadOnlyObservableGroup<string, int>? group = new("key", source);
4343

4444
Assert.AreEqual(group.Key, "key");

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

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,32 +47,13 @@ public void Ctor_WithObservableGroupedCollection_ShoudInitializeObject()
4747
CollectionAssert.AreEquivalent(readOnlyGroup.ElementAt(1), new[] { 2, 4, 6 });
4848
}
4949

50-
[TestMethod]
51-
public void Ctor_WithListOfIGroupingSource_ShoudInitializeObject()
52-
{
53-
List<IGrouping<string, int>>? source = new()
54-
{
55-
new IntGroup("A", new[] { 1, 3, 5 }),
56-
new IntGroup("B", new[] { 2, 4, 6 }),
57-
};
58-
ReadOnlyObservableGroupedCollection<string, int>? readOnlyGroup = new(source);
59-
60-
Assert.AreEqual(readOnlyGroup.Count, 2);
61-
62-
Assert.AreEqual(readOnlyGroup.ElementAt(0).Key, "A");
63-
CollectionAssert.AreEquivalent(readOnlyGroup.ElementAt(0), new[] { 1, 3, 5 });
64-
65-
Assert.AreEqual(readOnlyGroup.ElementAt(1).Key, "B");
66-
CollectionAssert.AreEquivalent(readOnlyGroup.ElementAt(1), new[] { 2, 4, 6 });
67-
}
68-
6950
[TestMethod]
7051
public void Ctor_WithListOfReadOnlyObservableGroupSource_ShoudInitializeObject()
7152
{
72-
List<ReadOnlyObservableGroup<string, int>>? source = new()
53+
ObservableCollection<ReadOnlyObservableGroup<string, int>>? source = new()
7354
{
74-
new ReadOnlyObservableGroup<string, int>("A", new[] { 1, 3, 5 }),
75-
new ReadOnlyObservableGroup<string, int>("B", new[] { 2, 4, 6 }),
55+
new ReadOnlyObservableGroup<string, int>("A", new ObservableCollection<int> { 1, 3, 5 }),
56+
new ReadOnlyObservableGroup<string, int>("B", new ObservableCollection<int> { 2, 4, 6 }),
7657
};
7758
ReadOnlyObservableGroupedCollection<string, int>? readOnlyGroup = new(source);
7859

0 commit comments

Comments
 (0)