Example #1
0
        public void SetCollectionAdapter_IntersectWith_RemovesElementsNotContainedByOther()
        {
            List <int> backingList = new List <int>()
            {
                12, 13, 14, 15, 16
            };
            SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList);

            adapter.IntersectWith(new int[] { 7, 16, 94, 14, 14, 14, 14 });

            CollectionAssert.AreEquivalent(new int[] { 14, 16 }, backingList);
        }
Example #2
0
        public void SetCollectionAdapter_IntersectWith_Null_ThrowsArgumentNull()
        {
            List <int> backingList = new List <int>()
            {
                12, 13, 14
            };
            SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList);

            Assert.ThrowsException <ArgumentNullException>(
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
                () => adapter.IntersectWith(null));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
        }
Example #3
0
        public void SetCollectionAdapter_IntersectWith_IsReadOnly_ThrowsNotSupported()
        {
            ICollection <int> backingList = new ReadOnlyCollection <int>(new List <int>()
            {
                12, 13, 14
            });
            SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList);

            NotSupportedException e = Assert.ThrowsException <NotSupportedException>(
                () => adapter.IntersectWith(new int[] { 7, 12 }));

            Assert.AreEqual(
                ExceptionMessages.CollectionIsReadOnly,
                e.Message);
        }