Ejemplo n.º 1
0
        public void Test_TryToMove()
        {
            IInfo           info  = A.Fake <IInfo>();
            IBoardFunctions board = A.Fake <IBoardFunctions>();
            IRandomTest     rnd   = A.Fake <IRandomTest>();

            IDynamicObject ant = new Ant(info, rnd)
            {
                X = 0, Y = 0, Agility = 1, BoardFunctions = board
            };

            A.CallTo(() => rnd.Next(A <int> .Ignored, A <int> .Ignored)).Returns(1);

            //gameLogic.ActAliveObject(dynamicObject);

            ant.TryToMove();
            A.CallTo(() => board.TryToMove(0, 0, 1, 1)).MustHaveHappened();
        }
Ejemplo n.º 2
0
        public void Test_ActDepressed()
        {
            //initialize
            IBoardFunctions board = A.Fake <IBoardFunctions>();
            IInfo           info  = A.Fake <IInfo>();
            IProducerConsumerMessages <string> pc = A.Fake <IProducerConsumerMessages <string> >();
            IRandomTest    rnd = A.Fake <IRandomTest>();
            IDynamicObject ant = new Ant(info, rnd)
            {
                BoardFunctions = board, X = 1, Y = 1, ProducerConsumer = pc
            };

            List <IDynamicObject> l = new List <IDynamicObject>();
            var positions           = new List <(int, int)> {
                (0, 0), (1, 0), (2, 1)
            };

            foreach (var p in positions)
            {
                var obj = A.Fake <IDynamicObject>();
                A.CallTo(() => obj.X).ReturnsLazily(() => p.Item1);
                A.CallTo(() => obj.Y).ReturnsLazily(() => p.Item2);
                A.CallTo(() => obj.State).Returns(State.Alive);
                l.Add(obj);
            }

            var dynamicObject = A.Fake <IDynamicObject>();

            A.CallTo(() => board.GetNearObjects(ant.X, ant.Y, 1)).Returns(l);
            A.CallTo(() => info.MaxObjectsPerArea).Returns(3);
            A.CallTo(() => info.MinObjectsPerArea).Returns(1);

            //act
            ant.SetState(State.Depressed);
            ant.Action();

            //assert
            Assert.AreEqual(State.Alive, ant.State);
        }