public void AnyShipAlive_MockIShip_ReturnTrue() { BattleshipsGrid _battleshipsGrig = new BattleshipsGrid(); var mock = new Mock <IShip>(); _battleshipsGrig.AddShip(mock.Object); _battleshipsGrig.AddShip(mock.Object); _battleshipsGrig.AddShip(mock.Object); _battleshipsGrig.AddShip(mock.Object); _battleshipsGrig.AddShip(mock.Object); mock.Setup(ship => ship.IsAlive()).Returns(true); var actual = _battleshipsGrig.AnyShipAlive(); Assert.True(actual); }
public void ShotResult_MockMultipleIShip_ReturnShotResult() { var mock1 = new Mock <IShip>(); var mock2 = new Mock <IShip>(); BattleshipsGrid _battleshipsGrig = new BattleshipsGrid(); _battleshipsGrig.Size = 10; _battleshipsGrig.AddShip(mock1.Object); _battleshipsGrig.AddShip(mock2.Object); mock1.Setup(ship => ship.Shot(1, 1)).Returns(ShotResult.Hit); mock2.Setup(ship => ship.Shot(1, 1)).Returns(ShotResult.Miss); var actual = _battleshipsGrig.Shot(1, 1); Assert.Equal(ShotResult.Hit, actual); }
public void ShotResult_MockIShip_ReturnShotResult() { var mock = new Mock <IShip>(); BattleshipsGrid _battleshipsGrig = new BattleshipsGrid(); _battleshipsGrig.Size = 10; _battleshipsGrig.AddShip(mock.Object); mock.Setup(ship => ship.Shot(1, 1)).Returns(ShotResult.Hit); mock.Setup(ship => ship.Shot(1, 2)).Returns(ShotResult.Miss); var actual11 = _battleshipsGrig.Shot(1, 1); var actual12 = _battleshipsGrig.Shot(1, 2); Assert.Equal(ShotResult.Hit, actual11); Assert.Equal(ShotResult.Miss, actual12); }