Exemple #1
0
        public void TestPreviousKnownBreakingEdgecases()
        {
            var updateList = new UpdateList();

            // we have to create another ref to the functions so we can self remove within closures
            Action <float> func2 = null;
            Action <float> func0 = null;

            Action <float> update2 = dt =>
            {
                // Do nothing special
            };

            Action <float> update1 = dt =>
            {
                updateList.Remove(func2);
            };

            Action <float> update0 = dt =>
            {
                updateList.Remove(func0);
            };

            func2 = update2;
            func0 = update0;

            updateList.Add(update0);
            updateList.Add(update1);
            updateList.Add(update2);

            updateList.Update(0f);

            Assert.IsFalse(updateList.Contains(update0));
            Assert.IsTrue(updateList.Contains(update1));
            Assert.IsFalse(updateList.Contains(update2));

            // now dead test that index 2 is not marked as dead. by adding new updates, running them and checking they still exist
            updateList.Remove(update1);

            Action <float> update3Index0 = dt => { };
            Action <float> update4Index1 = dt => { };
            Action <float> update5Index2 = dt => { };


            updateList.Add(update3Index0);
            updateList.Add(update4Index1);
            updateList.Add(update5Index2);

            updateList.Update(0f);

            Assert.IsTrue(updateList.Contains(update3Index0));
            Assert.IsTrue(updateList.Contains(update4Index1));
            Assert.IsTrue(updateList.Contains(update5Index2));
        }
Exemple #2
0
        public void ExpectUpdateToPassDeltaTimeToAllFunctions()
        {
            const float dtParam = 0.112f;

            Action <float> func = dt =>
            {
                Assert.AreEqual(dt, dtParam);
            };

            var updateList = new UpdateList();

            updateList.Add(func);
            updateList.Update(dtParam);
        }
Exemple #3
0
        public void ExpectAddedFunctionToBeCalledWhenUpdated()
        {
            var            wasCalled = false;
            Action <float> func      = dt =>
            {
                wasCalled = true;
            };

            var updateList = new UpdateList();

            updateList.Add(func);
            Assert.IsFalse(wasCalled);
            updateList.Update(0f);
            Assert.IsTrue(wasCalled);
        }
Exemple #4
0
        public void ExpectFunctionToNotBeCalledIfRemoveWasCalled()
        {
            var            wasCalled = false;
            Action <float> func      = dt =>
            {
                wasCalled = true;
            };

            var updateList = new UpdateList();

            updateList.Add(func);
            Assert.IsFalse(wasCalled);
            updateList.Remove(func);
            Assert.IsFalse(wasCalled);

            updateList.Update(0f);
            Assert.IsFalse(wasCalled);
        }
Exemple #5
0
        public void ExpectRemoveAndReAddWithinAnUpdateLoopToNotRemove()
        {
            var updateList = new UpdateList();

            Action <float> func2 = dt => { };
            Action <float> func1 = dt =>
            {
                updateList.Remove(func2);
                updateList.Add(func2);
            };

            updateList.Add(func1);
            updateList.Add(func2);

            updateList.Update(0f);

            Assert.IsTrue(updateList.Contains(func2));
        }
Exemple #6
0
        public void ExpectContainsToReturnFalseAfterRemoveWasCalledDuringFrame()
        {
            // we have to create another ref to the function so we can self remove within closure
            Action <float> funcRef = null;

            var updateList = new UpdateList();

            Action <float> func = dt =>
            {
                updateList.Remove(funcRef);

                Assert.IsFalse(updateList.Contains(funcRef));
            };

            funcRef = func;

            updateList.Add(funcRef);

            updateList.Update(0f);
        }