public void SetCollectionAdapter_Add_ElementPresent_ReturnsFalse() { List <int> backingList = new List <int>() { 12, 13, 14 }; SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList); Assert.IsFalse(adapter.Add(13)); Assert.AreEqual(3, backingList.Count); }
public void SetCollectionAdapter_Add_ElementNotPresent_ReturnsTrue() { List <int> backingList = new List <int>() { 12, 13, 14 }; SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList); Assert.IsTrue(adapter.Add(7)); CollectionAssert.Contains(backingList, 7); }
public void SetCollectionAdapter_Add_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.Add(7)); Assert.AreEqual( ExceptionMessages.CollectionIsReadOnly, e.Message); }