コード例 #1
0
            public void ThrowsOnNull()
            {
                var list = new DeletableObjectList <TestDeletable>();

                Action addingNull = () => list.Add(null);

                Assert.Throws <ArgumentNullException>(addingNull);
            }
コード例 #2
0
            public void AddsObjectToList()
            {
                var list      = new DeletableObjectList <TestDeletable>();
                var deletable = new TestDeletable();

                list.Add(deletable);

                Assert.Equal(deletable, list.Single());
            }
コード例 #3
0
            public void AddsObjectToList()
            {
                var list      = new DeletableObjectList <TestDeletable>();
                var deletable = new TestDeletable();

                list.Add(deletable);

                list.Should().ContainSingle().Which.Should().Be(deletable);
            }
コード例 #4
0
        createPopulatedList(int itemsToAdd)
        {
            var list  = new DeletableObjectList <TestDeletable>();
            var items = getDeletables(itemsToAdd);

            foreach (var item in items)
            {
                list.Add(item);
            }
            return(list, items);
        }
コード例 #5
0
            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));
            }
コード例 #6
0
            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);
            }
コード例 #7
0
ファイル: GameState.cs プロジェクト: Mattias1/td
        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
        }
コード例 #8
0
            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);
                }
            }
コード例 #9
0
ファイル: DeletableObject.cs プロジェクト: amulware/yatl
        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;
        }
コード例 #10
0
 protected override void CallMethod(DeletableObjectList <TestDeletable> list)
 => list.Add(new TestDeletable());