Ejemplo n.º 1
0
        public void GivenADroneOutsideOfBattlefieldArea_WhenAddingDrone_ThenWillThrowInvalidOperationException()
        {
            _droneMock.Setup(x => x.IsInBattlefieldArea()).Returns(false);
            var battlefieldContext = new BattlefieldContext();

            Assert.That(() => battlefieldContext.AddDrone(_droneMock.Object), Throws.InstanceOf <InvalidOperationException>());
        }
Ejemplo n.º 2
0
        public void GivenADroneInsideDefaultUnlimitedBattlefieldArea_WhenAddingDrone_ThenWillNotThrowAnyException()
        {
            _droneMock.Setup(x => x.IsInBattlefieldArea()).Returns(true);
            var battlefieldContext = new BattlefieldContext();

            Assert.That(() => battlefieldContext.AddDrone(_droneMock.Object), Throws.Nothing);
        }
Ejemplo n.º 3
0
        public void GivenAnUnsetBattlefieldArea_WhenAddingDrone_ThenWillAssignUnlimitedBattlefieldArea()
        {
            _droneMock.Setup(x => x.IsInBattlefieldArea()).Returns(true);
            var battlefieldContext = new BattlefieldContext();

            battlefieldContext.AddDrone(_droneMock.Object);

            _droneMock.Verify(x => x.SetBattlefieldArea(It.IsAny <UnlimitedBattlefieldArea>()), Times.Once);
        }
Ejemplo n.º 4
0
        public void GivenAnInsertedDroneOutsideOfFutureArea_WhenUpdatingBattlefieldArea_ThenWillThrowInvalidOperationException()
        {
            _droneMock.Setup(x => x.IsInBattlefieldArea()).Returns(true);
            var battlefieldContext = new BattlefieldContext();

            battlefieldContext.AddDrone(_droneMock.Object);
            _droneMock.Setup(x => x.IsInBattlefieldArea()).Returns(false);

            Assert.That(() => battlefieldContext.SetBattlefieldArea(_battlefieldAreaMock.Object), Throws.InstanceOf <InvalidOperationException>());
        }
Ejemplo n.º 5
0
        public void GivenAnInsertedDrone_WhenUpdatingBattlefieldArea_ThenWillSetBattlefieldAreaOfDrone()
        {
            _droneMock.Setup(x => x.IsInBattlefieldArea()).Returns(true);
            var battlefieldContext = new BattlefieldContext();

            battlefieldContext.AddDrone(_droneMock.Object);

            battlefieldContext.SetBattlefieldArea(_battlefieldAreaMock.Object);

            _droneMock.Verify(x => x.SetBattlefieldArea(_battlefieldAreaMock.Object), Times.Once);
        }
Ejemplo n.º 6
0
        private IBattlefieldContext Parse(TextReader textReader)
        {
            BattlefieldContext battlefieldContext = new BattlefieldContext();
            string             line;
            int lineNumber = 1;

            while ((line = textReader.ReadLine()) != null)
            {
                var number  = lineNumber;
                var handler = _lineHandlers.FirstOrDefault(kv => kv.Key(number));
                handler.Value.Process(battlefieldContext, line);
                lineNumber++;
            }

            return(battlefieldContext);
        }
Ejemplo n.º 7
0
        public void GivenNoAddedDrones_WhenAddingDroneCommand_ThenWillThrowInvalidOperationException()
        {
            var battlefieldContext = new BattlefieldContext();

            Assert.That(() => battlefieldContext.AddDroneCommand(_droneCommandMock.Object), Throws.InstanceOf <InvalidOperationException>());
        }