public void SetCollectionAdapter_Contains_ElementNotPresent_ReturnsFalse() { List <int> backingList = new List <int>() { 12, 13, 14 }; SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList); Assert.IsFalse(adapter.Contains(7)); }
public void SetCollectionAdapter_SetEquals_AreEqual_ReturnsTrue() { List <int> backingList = new List <int>() { 12, 13, 14 }; SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList); Assert.IsTrue(adapter.SetEquals(new int[] { 14, 12, 13, 14, 13, 12 })); }
public void SetCollectionAdapter_SetEquals_NotEqual_ReturnsFalse() { List <int> backingList = new List <int>() { 12, 13, 14 }; SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList); Assert.IsFalse(adapter.SetEquals(new int[] { 6, 7, 12, 18, 13, 9 })); }
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_Remove_ElementNotPresent_ReturnsFalse() { List <int> backingList = new List <int>() { 12, 13, 14 }; SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList); Assert.IsFalse(adapter.Remove(15)); CollectionAssert.AreEquivalent(new int[] { 12, 13, 14 }, backingList); }
public void SetCollectionAdapter_UnionWith_Succeeds() { List <int> backingList = new List <int>() { 12, 13, 14 }; SetCollectionAdapter <int> adapter = new SetCollectionAdapter <int>(backingList); adapter.UnionWith(new int[] { 7, 13, 8, 12, 13, 15 }); CollectionAssert.AreEquivalent(new int[] { 7, 8, 12, 13, 14, 15 }, backingList); }
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); }
public void SetCollectionAdapter_UnionWith_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.UnionWith(null)); #pragma warning restore CS8625 // Cannot convert null literal to non-nullable reference type. }
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]); }
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); }
public void SetCollectionAdapter_Ctor_Succeeds(bool shouldBeReadOnly) { List <string> content = new List <string>() { "foo", "bar", "baz" }; ICollection <string> collection = shouldBeReadOnly ? new ReadOnlyCollection <string>(content) : (ICollection <string>)content; SetCollectionAdapter <string> adapter = new SetCollectionAdapter <string>(collection); Assert.IsNotNull(adapter); Assert.AreEqual(shouldBeReadOnly, adapter.IsReadOnly); }