コード例 #1
0
        public void SetCollectionAdapter_ExceptWith_RemovesContainedElements()
        {
            List <int> backingList = new List <int>()
            {
                12, 13, 14
            };
            SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList);

            adapter.ExceptWith(new int[] { 7, 13, 28, 12, 13, 13, 12 });

            Assert.AreEqual(1, backingList.Count);
            Assert.AreEqual(14, backingList[0]);
        }
コード例 #2
0
        public void SetCollectionAdapter_ExceptWith_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.ExceptWith(null));
#pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type.
        }
コード例 #3
0
        public void SetCollectionAdapter_ExceptWith_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.ExceptWith(new int[] { 7, 12 }));

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