public void IList_Generic_RemoveAt_IndexGreaterThanListCount_ThrowsArgumentOutOfRangeException(int count) { if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported) { SCG.IList <T> list = GenericIListFactory(count); T validAdd = CreateT(0); Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveAt(count)); Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveAt(count + 1)); Assert.Equal(count, list.Count); } }
/// <summary> /// Returns a set of ModifyEnumerable delegates that modify the enumerable passed to them. /// </summary> protected override SCG.IEnumerable <ModifyEnumerable> GetModifyEnumerables(ModifyOperation operations) { foreach (var item in base.GetModifyEnumerables(operations)) { yield return(item); } if (!AddRemoveClear_ThrowsNotSupported && (operations & ModifyOperation.Insert) == ModifyOperation.Insert) { yield return((SCG.IEnumerable <T> enumerable) => { SCG.IList <T> casted = ((SCG.IList <T>)enumerable); if (casted.Count > 0) { casted.Insert(0, CreateT(12)); return true; } return false; }); } if (!AddRemoveClear_ThrowsNotSupported && (operations & ModifyOperation.Remove) == ModifyOperation.Remove) { yield return((SCG.IEnumerable <T> enumerable) => { SCG.IList <T> casted = ((SCG.IList <T>)enumerable); if (casted.Count > 0) { casted.RemoveAt(0); return true; } return false; }); } }
public void IList_Generic_RemoveAt_OnReadOnlyList(int count) { if (IsReadOnly || AddRemoveClear_ThrowsNotSupported) { SCG.IList <T> list = GenericIListFactory(count); Assert.Throws <NotSupportedException>(() => list.RemoveAt(count / 2)); Assert.Equal(count, list.Count); } }
public void IList_Generic_RemoveAt_ZeroMultipleTimes(int count) { if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported) { SCG.IList <T> list = GenericIListFactory(count); Assert.All(Enumerable.Range(0, count), index => { list.RemoveAt(0); Assert.Equal(count - index - 1, list.Count); }); } }
public void IList_Generic_RemoveAt_AllValidIndices(int count) { if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported) { SCG.IList <T> list = GenericIListFactory(count); Assert.Equal(count, list.Count); Assert.All(Enumerable.Range(0, count).Reverse(), index => { list.RemoveAt(index); Assert.Equal(index, list.Count); }); } }