public void ThrowsOnNull() { var list = new DeletableObjectList <TestDeletable>(); Action addingNull = () => list.Add(null); Assert.Throws <ArgumentNullException>(addingNull); }
public void AddsObjectToList() { var list = new DeletableObjectList <TestDeletable>(); var deletable = new TestDeletable(); list.Add(deletable); Assert.Equal(deletable, list.Single()); }
public void AddsObjectToList() { var list = new DeletableObjectList <TestDeletable>(); var deletable = new TestDeletable(); list.Add(deletable); list.Should().ContainSingle().Which.Should().Be(deletable); }
createPopulatedList(int itemsToAdd) { var list = new DeletableObjectList <TestDeletable>(); var items = getDeletables(itemsToAdd); foreach (var item in items) { list.Add(item); } return(list, items); }
public void CanAddMultipleItems(int itemsToAdd) { var list = new DeletableObjectList <TestDeletable>(); var items = getDeletables(itemsToAdd); foreach (var item in items) { list.Add(item); } Assert.True(items.SequenceEqual(list)); }
public void CanAddMultipleItems(int itemsToAdd) { var list = new DeletableObjectList <TestDeletable>(); var items = getDeletables(itemsToAdd); foreach (var item in items) { list.Add(item); } list.Should().BeEquivalentTo(items, withExactSameItems); }
public void Add(GameObject obj) { if (obj.Game != null) { throw new Exception("Sad!"); } gameObjects.Add(obj); ObjectBeingAdded = obj; obj.Add(this); ObjectBeingAdded = null; // event on added }
public void IsAccurateWhenAddingAndRemoving(PositiveInt itemsToAdd, int randomSeed) { var itemCount = itemsToAdd.Get; var random = new System.Random(randomSeed); var list = new DeletableObjectList <TestDeletable>(); foreach (var i in Enumerable.Range(1, itemCount)) { list.Add(new TestDeletable()); Assert.Equal(i, list.ApproximateCount); } foreach (var i in Enumerable.Range(1, itemCount)) { list.Remove(list.RandomElement(random)); Assert.Equal(itemCount - i, list.ApproximateCount); } }
public void AddToList(DeletableObjectList <T> list) { if (this.List != null) { return; } this.List = list; this.Deleted = false; if (list.Last != null) { this.Prev = list.Last; this.Prev.Next = (T)this; } this.ChangingList = true; list.Add((T)this); this.ChangingList = false; }
protected override void CallMethod(DeletableObjectList <TestDeletable> list) => list.Add(new TestDeletable());