Example #1
0
        public void TestForwardsMax()
        {
            MovementSpeeds speeds = new MovementSpeeds(5, 5, 5)
            {
                ForwardSpeed = 10
            };

            Assert.AreEqual(speeds.Max, 10);
        }
Example #2
0
        public void TestSidewaysMax()
        {
            MovementSpeeds speeds = new MovementSpeeds(5, 5, 5)
            {
                SidewaysSpeed = 10
            };

            Assert.AreEqual(speeds.Max, 10);
        }
Example #3
0
        public void TestHashCode()
        {
            MovementSpeeds a = new MovementSpeeds(5, 10, 3);
            MovementSpeeds b = new MovementSpeeds(5, 10, 3);

            Assert.AreEqual(a.GetHashCode(), b.GetHashCode());

            b.ForwardSpeed = 0;

            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
Example #4
0
        public void TestEqualsOperator()
        {
            MovementSpeeds a = new MovementSpeeds(5, 10, 3);
            MovementSpeeds b = new MovementSpeeds(5, 10, 3);

            Assert.IsTrue(a == b);
            Assert.IsFalse(a != b);

            b.ForwardSpeed = 0;

            Assert.IsFalse(a == b);
        }
Example #5
0
        public void TestEquals()
        {
            MovementSpeeds a = new MovementSpeeds(5, 10, 3);
            MovementSpeeds b = new MovementSpeeds(5, 10, 3);

            Assert.IsTrue(a.Equals(b));
            Assert.IsFalse(a.Equals(new object()));

            b.ForwardSpeed = 0;

            Assert.IsFalse(a.Equals(b));
        }
Example #6
0
        private InMemoryCollidableBodies(
            MovementSpeeds movementSpeeds,
            Bodies bodies,
            Collisions collisions)
        {
            UnityEngine.Debug.Assert(movementSpeeds != null);
            this.movementSpeeds = movementSpeeds;

            UnityEngine.Debug.Assert(bodies != null);
            this.bodies = bodies;

            UnityEngine.Debug.Assert(collisions != null);
            this.collisions = collisions;
        }
Example #7
0
        public void Does_not_support_a_null_collection_of_movement_speeds()
        {
            MovementSpeeds movementSpeeds = null;
            var            bodies         = new DummyBodies();
            var            collisions     = new DummyCollisions();

            Assert.Throws <ArgumentNullException>(() =>
            {
                InMemoryCollidableBodies.WithCollections(
                    movementSpeeds,
                    bodies,
                    collisions);
            });
        }
Example #8
0
 /// <summary>
 ///     Create a <see cref="InMemoryCollidableBodies"/> with a given
 ///     <see cref="MovementSpeeds"/>, <see cref="Bodies"/>, and
 ///     <see cref="Collisions"/>.
 /// </summary>
 /// <param name="movementSpeeds">
 ///     The <see cref="MovementSpeeds"/>.
 /// </param>
 /// <param name="bodies">
 ///     The <see cref="Bodies"/>.
 /// </param>
 /// <param name="collisions">
 ///     The <see cref="Collisions"/>.
 /// </param>
 /// <returns>
 ///     A <see cref="InMemoryCollidableBodies"/> created with the given
 ///     <see cref="MovementSpeeds"/>, <see cref="Bodies"/>, and
 ///     <see cref="Collisions"/>.
 /// </returns>
 /// <exception cref="ArgumentNullException">
 ///     Thrown when the given <see cref="MovementSpeeds"/> is null.
 ///
 ///     -or-
 ///
 ///     Thrown when the given <see cref="Bodies"/> is null.
 ///
 ///     -or-
 ///
 ///     Thrown when the given <see cref="Collisions"/> is null.
 /// </exception>
 internal static InMemoryCollidableBodies WithCollections(
     MovementSpeeds movementSpeeds,
     Bodies bodies,
     Collisions collisions)
 {
     if (movementSpeeds == null)
     {
         throw new ArgumentNullException(nameof(movementSpeeds));
     }
     if (bodies == null)
     {
         throw new ArgumentNullException(nameof(bodies));
     }
     if (collisions == null)
     {
         throw new ArgumentNullException(nameof(collisions));
     }
     return(new InMemoryCollidableBodies(
                movementSpeeds,
                bodies,
                collisions));
 }
Example #9
0
 public void ChangeSpeed(MovementSpeeds new_speed)
 {
     movement_speed = new_speed;
     speed          = Constants.SPEEDS[(int)movement_speed];
 }