public void WillInvokeFiredEventWithTheRightArgs() { var eventInvoked = false; var field = new BattleField(10); field.PlaceShip(GetFourDeckShip()); FiredEventArgs arguments = null; //subscribe field.Fired += (sender, args) => { eventInvoked = true; arguments = args; }; var fireCoordinate = new Coordinate('a', 2); field.Fire(fireCoordinate); Assert.IsTrue(eventInvoked); Assert.AreEqual(fireCoordinate, arguments.Coordinate); Assert.IsTrue(arguments.Result == CellState.Exploded); }
public void WillInvokeShipDestroyedEventWithTheRightArguments() { var eventInvoked = false; var ship = GetFourDeckShip(); var field = new BattleField(10); field.PlaceShip(ship); ShipDestroyedEventArgs arguments = null; //subscribe field.ShipDestroyed += (sender, args) => { eventInvoked = true; arguments = args; }; field.Fire(new Coordinate('a', 1)); field.Fire(new Coordinate('a', 2)); field.Fire(new Coordinate('a', 3)); field.Fire(new Coordinate('a', 4)); Assert.IsTrue(eventInvoked); Assert.AreEqual(ship.Id, arguments.Ship.Id); Assert.IsTrue(arguments.SurroundedCells.Any()); }