Skip to content
This repository was archived by the owner on May 1, 2024. It is now read-only.

Commit 83e35db

Browse files
committed
Add AddToNullCollection test
1 parent e8b93a4 commit 83e35db

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ObservableRangeCollection_Tests.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using System;
12
using System.Collections.Generic;
23
using System.Collections.Specialized;
34
using Xamarin.CommunityToolkit.ObjectModel;
@@ -178,6 +179,7 @@ public void RemoveRange_should_NOT_mutate_collection_when_source_data_is_not_pre
178179
class CollectionWrapper<T>
179180
{
180181
public readonly ObservableRangeCollection<T> Collection = new ObservableRangeCollection<T>();
182+
public ObservableRangeCollection<T> NullCollection;
181183
}
182184

183185
[Fact]
@@ -192,5 +194,19 @@ public void AddCollection()
192194

193195
Assert.Equal(toAdd, wrapper.Collection);
194196
}
197+
198+
[Fact]
199+
public void AddToNullCollection()
200+
{
201+
var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 };
202+
203+
Assert.Throws<ArgumentNullException>(() =>
204+
{
205+
var wrapper = new CollectionWrapper<int>()
206+
{
207+
NullCollection = { toAdd }
208+
};
209+
});
210+
}
195211
}
196212
}

0 commit comments

Comments
 (0)