Exemplo n.º 1
0
        public void MoveTileStart_ShouldCallHandlersWaveLike()
        {
            // Act
            var uc1 = new OneUnitControllerMock();

            uc1.SetOnPosition(new IntVector2(3, 3));
            _waveEventRiser.AddPositionChangedHandler(uc1.Handler, uc1);

            var uc2 = new OneUnitControllerMock();

            uc2.SetOnPosition(new IntVector2(4, 4));
            _waveEventRiser.AddPositionChangedHandler(uc2.Handler, uc2);

            var uc3 = new OneUnitControllerMock();

            uc3.SetOnPosition(new IntVector2(2, 2));
            _waveEventRiser.AddPositionChangedHandler(uc3.Handler, uc3);

            var uc4 = new OneUnitControllerMock();

            uc4.SetOnPosition(new IntVector2(1, 1));
            _waveEventRiser.AddPositionChangedHandler(uc4.Handler, uc4);

            Mock.Raise(() => _baseActionController.MoveTileStart += null);

            var expectedSequence = new List <IntVector2>();

            expectedSequence.Add(new IntVector2(1, 1));
            expectedSequence.Add(new IntVector2(2, 2));
            expectedSequence.Add(new IntVector2(3, 3));
            expectedSequence.Add(new IntVector2(4, 4));
            // Assert
            Assert.True(expectedSequence.SequenceEqual(HandlerSequenceHolder.CalledHandlers));
        }
Exemplo n.º 2
0
        public void Overtake_OneUnit_ShouldRaiseCompleteIfUnitInRange()
        {
            // Arrange
            bool actualComplete = false;
            var  unitEvents     = Mock.Create <IUnitEvents>();

            Mock.Arrange(() => _baseActionController.Position).Returns(new IntVector2(0, 1));
            OneUnitControllerMock oneUnitController = new OneUnitControllerMock(unitEvents);

            oneUnitController.SetOnPosition(new IntVector2(0, 0));
            _targetOvertaker = new TargetOvertaker(_wayHostileController, _baseActionController);

            // Act
            _targetOvertaker.OvertakeComplete += () => actualComplete = true;
            _targetOvertaker.Overtake(oneUnitController);

            // Assert
            Assert.True(actualComplete);
        }