Example #1
0
        public void ExecuteSystemTest([NUnit.Framework.Range(1, 10, 1)] int totalSystemExecutions)
        {
            //  Setup
            Vector3 velocity         = new Vector3(10, 20, 30);
            Vector3 position         = new Vector3(1, 2, 3);
            Vector3 expectedPosition = position;

            _testEnity = Pools.pool.CreateEntity()
                         .AddPosition(position)
                         .AddVelocity(velocity);

            //Desired. Strong typing when CreateSystem<T> is called.
            VelocitySystem velocitySystem = Pools.pool.CreateSystem <VelocitySystem>() as VelocitySystem;

            //  This will run the system exacly once.
            for (var ex = 0; ex < totalSystemExecutions; ex++)
            {
                //for every execution
                velocitySystem.Execute();

                //we expect it to move by one velocity unit
                expectedPosition += velocity;
            }


            //  Assert
            Assert.AreEqual(expectedPosition, _testEnity.position.position, "The entity position will the original position plus one velocity.");
        }