diff --git a/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ObservableRangeCollection_Tests.cs b/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ObservableRangeCollection_Tests.cs index 3f35d07fc..beba839f1 100644 --- a/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ObservableRangeCollection_Tests.cs +++ b/src/CommunityToolkit/Xamarin.CommunityToolkit.UnitTests/ObjectModel/ObservableRangeCollection_Tests.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Collections.Specialized; using Xamarin.CommunityToolkit.ObjectModel; @@ -178,6 +179,7 @@ public void RemoveRange_should_NOT_mutate_collection_when_source_data_is_not_pre class CollectionWrapper { public readonly ObservableRangeCollection Collection = new ObservableRangeCollection(); + public ObservableRangeCollection NullCollection; } [Fact] @@ -192,5 +194,19 @@ public void AddCollection() Assert.Equal(toAdd, wrapper.Collection); } + + [Fact] + public void AddToNullCollection() + { + var toAdd = new[] { 3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5, 8, 9, 7, 9, 3, 2, 3 }; + + Assert.Throws(() => + { + var wrapper = new CollectionWrapper() + { + NullCollection = { toAdd } + }; + }); + } } } \ No newline at end of file