public void ReqTooManyTest()
        {
            StructReArray <TestStruct> pool = new StructReArray <TestStruct>(10, 1000,
                                                                             ClearAction, MoveAction);

            List <int> ids = new List <int>();

            for (int i = 0; i < 15; i++)
            {
                ids.Add(pool.Request());
            }

            for (int i = 0; i < 15; i++)
            {
                Assert.IsFalse(ids[i] == -1);
            }

            for (int i = 0; i < pool.Count; i++)
            {
                pool.Values[i].X += i;
            }

            foreach (int id in ids)
            {
                if (id != -1)
                {
                    Assert.AreEqual(id, pool.Values[pool.IdsToIndices[id]].X);
                }
            }

            Assert.AreEqual(pool.Count, 15);
        }
        public void ReqAdvTooManyTest()
        {
            StructReArray <TestStructAdv> pool = new StructReArray <TestStructAdv>(10, 1000,
                                                                                   ClearActionAdv, MoveActionAdv);

            int    testpasses   = 0;
            Action testCallback = () => { testpasses++; };

            List <int> ids = new List <int>();

            for (int i = 0; i < 15; i++)
            {
                int id = pool.Request();
                ids.Add(id);
                pool.Values[pool.IdsToIndices[id]].Setup(i, testCallback);
            }

            foreach (int id in ids)
            {
                Assert.IsFalse(id == -1);
            }

            foreach (int id in ids)
            {
                pool.Values[pool.IdsToIndices[id]].Callback();
            }

            Assert.AreEqual(ids.Count, testpasses);
        }
        public void ReqAndRemoveTest()
        {
            StructReArray <TestStruct> pool = new StructReArray <TestStruct>(10, 1000,
                                                                             ClearAction, MoveAction);

            List <int> ids = new List <int>();

            for (int i = 0; i < 10; i++)
            {
                ids.Add(pool.Request());
            }

            foreach (int id in ids)
            {
                Assert.IsFalse(id == -1);
            }

            for (int i = 0; i < pool.Count; i++)
            {
                pool.Values[i].X += i;
            }

            foreach (int id in ids)
            {
                Assert.AreEqual(id, pool.Values[pool.IdsToIndices[id]].X);
            }

            for (int i = 5; i < 8; i++)
            {
                pool.ReturnId(ids[i]);                                    // return 5, 6, and 7
            }
            Assert.IsTrue(pool.Count == 7);                               // down from 10
            Assert.IsTrue(pool.Values[pool.IdsToIndices[ids[9]]].X == 9); // verify that accessing id9 still works

            // request 3 new structs, to fill back up to 10
            List <int> newids = new List <int>();

            for (int i = 0; i < 3; i++)
            {
                newids.Add(pool.Request());
            }

            foreach (int id in newids)
            {
                Assert.IsFalse(id == -1);
            }

            Assert.IsTrue(pool.Count == 10); // back to 10
            foreach (int id in newids)
            {
                Assert.AreEqual(0, pool.Values[pool.IdsToIndices[id]].X); // verify that returned structs were cleared
            }
        }