コード例 #1
0
        public void DoNotIssueMoveIntoStationaryAnt()
        {
            var mock = new MockFactory();
            var outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();

            using (mock.Ordered)
            {
                outputAdapterMock.Expects.One.MethodWith(adapter => adapter.NotifyEndOfTurn());
            }

            var trackerManager = new OwnAntTrackingManager(outputAdapterMock.MockObject);

            MapTile origin = GameContext.Map.At(3, 4);
            MapTile destination = origin.North;
            var ant = new Ant(origin);

            destination.CurrentAnt = new Ant(destination);
            origin.CurrentAnt = ant;

            trackerManager.HasProcessedAllInputMoves();
            trackerManager.EnrollToMove(ant, destination);
            trackerManager.FinalizeAllMoves();

            Assert.IsNotNull(origin.CurrentAnt);
            Assert.AreEqual(ant, origin.CurrentAnt);

            mock.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #2
0
        public GameManager(IGameOutputAdapter outputAdapter)
        {
            this._outputAdapter = outputAdapter;
            var ownAntTrackingManager = new OwnAntTrackingManager(outputAdapter);

            this._turnResultManagers = new ITurnResultManager[]
                                           {
                                               new OwnAntPreProcessManager(ownAntTrackingManager),
                                               new MapExplorationManager(),
                                               new HeatMapTurnManager(),
                                               new FoodResourceManager(),
                                               new OwnAntPostProcessManager(ownAntTrackingManager),
                                           };
        }
コード例 #3
0
        public void TwoAntsCannotMoveIntoSameTile()
        {
            var mock = new MockFactory();
            var outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();

            using (mock.Ordered)
            {
                outputAdapterMock.Expects.One
                    .Method(adapter => adapter.MoveAnt(0, 0, 0))
                    .WithAnyArguments();

                outputAdapterMock.Expects.One.MethodWith(adapter => adapter.NotifyEndOfTurn());
            }

            var trackerManager = new OwnAntTrackingManager(outputAdapterMock.MockObject);

            MapTile origin1 = GameContext.Map.At(3, 4);
            MapTile destination = origin1.North;
            MapTile origin2 = destination.North;
            var ant1 = new Ant(origin1);
            var ant2 = new Ant(origin2);

            origin1.CurrentAnt = ant1;
            origin2.CurrentAnt = ant2;

            trackerManager.HasProcessedAllInputMoves();
            trackerManager.EnrollToMove(ant1, destination);
            trackerManager.EnrollToMove(ant2, destination);
            trackerManager.FinalizeAllMoves();

            trackerManager.AntHasMovedTo(destination.Row, destination.Column);

            mock.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #4
0
        public void SimpleTrackingCase()
        {
            var mock = new MockFactory();
            var outputAdapterMock = mock.CreateMock<IGameOutputAdapter>();

            using (mock.Ordered)
            {
                outputAdapterMock.Expects.One
                    .Method(adapter => adapter.MoveAnt(0, 0, 0))
                    .WithAnyArguments();

                outputAdapterMock.Expects.One.MethodWith(adapter => adapter.NotifyEndOfTurn());
            }

            var trackerManager = new OwnAntTrackingManager(outputAdapterMock.MockObject);

            MapTile origin = GameContext.Map.At(3, 4);
            MapTile destination = origin.North;
            var ant = new Ant(origin);

            origin.CurrentAnt = ant;

            trackerManager.HasProcessedAllInputMoves();
            trackerManager.EnrollToMove(ant, destination);
            trackerManager.FinalizeAllMoves();

            Assert.IsNull(origin.CurrentAnt);

            trackerManager.AntHasMovedTo(destination.Row, destination.Column);

            Assert.IsNull(origin.CurrentAnt);
            Assert.AreEqual(ant, destination.CurrentAnt);

            mock.VerifyAllExpectationsHaveBeenMet();
        }
コード例 #5
0
 public OwnAntPreProcessManager(OwnAntTrackingManager ownAntTrackingManager)
 {
     this._ownAntTrackingManager = ownAntTrackingManager;
 }