public void Size_ReturnsCountOfValuesInside([Values(0, 1, 2, 3)] int from, [Values(0, 3, 5, 10)] int to) { var size = to - from + 1; var shipVector = new ShipVector(from, to); Assert.AreEqual(size, shipVector.Size); }
public void ShipVector_HappyPath([Values(0, 1, 2, 3)] int from, [Values(0, 3, 5, 10)] int to) { var shipVector = new ShipVector(from, to); Assert.NotNull(shipVector); Assert.AreEqual(from, shipVector.From); Assert.AreEqual(to, shipVector.To); }
public bool Validate(ShipVector vectorX, ShipVector vectorY) { if (ValidateVectorsSize(vectorX, vectorY)) { return(ValidateVectorsDiagonality(vectorX, vectorY)); } return(false); }
public void ShipVector_ValuesInReverseOrder_RevertsBack([Values(0, 3, 5, 10)] int from, [Values(0, 1, 2, 3)] int to) { var smallerValue = Math.Min(from, to); var biggerValue = Math.Max(from, to); var shipVector = new ShipVector(from, to); Assert.AreEqual(smallerValue, shipVector.From); Assert.AreEqual(biggerValue, shipVector.To); }
private List <IField> GetCoordinates(ShipVector vectorX, ShipVector vectorY) { if (vectorsValidator.Validate(vectorX, vectorY)) { var fieldLayout = new ShipLayout(vectorX, vectorY); return(fieldLayout.Values.Select(x => (IField) new Field(FieldTypes.Ship, x.PositionX, x.PositionY)) .ToList()); } throw new GameArgumentException("Wrong ship coordinates"); }
public void Values_ReturnsValuesInside([Values(0, 1, 2, 3)] int from, [Values(0, 3, 5, 10)] int to) { var values = new List <int>(); for (int i = from; i <= to; i++) { values.Add(i); } var shipVector = new ShipVector(from, to); Assert.AreEqual(values, shipVector.Values.ToList()); }
private bool ValidateVectorsSize(ShipVector vectorX, ShipVector vectorY) { if (vectorX.Size < AbsoluteMinimumVectorSize && vectorY.Size < AbsoluteMinimumVectorSize) { // at least one vector should have absolute minimum size return(false); } if (vectorX.Size < _gameSettings.ShipSizes.Min() && vectorY.Size < _gameSettings.ShipSizes.Min()) { // at least one vector should have game defined minimum size return(false); } if (vectorX.Size > _gameSettings.ShipSizes.Max() || vectorY.Size > _gameSettings.ShipSizes.Max()) { // neithers of vectors cannot have size bigger than game defined return(false); } return(true); }
public IShip Create(ShipVector vectorX, ShipVector vectorY) { return(new Ship(vectorX, vectorY, _shipVectorsValidator)); }
public void Ship_HasEqualCoordinatesCount(ShipVector vectorX, ShipVector vectorY) { _ship = new Ship(vectorX, vectorY, mockShipVectorsValidator.Object); Assert.AreEqual(vectorX.Size * vectorY.Size, _ship.Coordinates.Count); }
public Ship(ShipVector vectorX, ShipVector vectorY, IShipVectorsValidator vectorsValidator) { this.vectorsValidator = vectorsValidator; Coordinates = GetCoordinates(vectorX, vectorY); }
private static bool ValidateVectorsDiagonality(ShipVector vectorX, ShipVector vectorY) { return(vectorX.Size == 1 || vectorY.Size == 1); }
public void Ship_HasVectorLessThanSmallestShipSize_ReturnsFalse(ShipVector vectorX, ShipVector vectorY) { Assert.IsFalse(validator.Validate(vectorX, vectorY), $"Vectors smaller than {_gameSettings.ShipSizes.Min()} should not pass"); }
public void Ship_HasDiagonalVectors_ReturnsFalse(ShipVector vectorX, ShipVector vectorY) { Assert.IsFalse(validator.Validate(vectorX, vectorY), "Diagonal vectors should not pass"); }
public void Ship_HasVectorsExceedingBoard_ReturnsFalse(ShipVector vectorX, ShipVector vectorY) { Assert.IsFalse(validator.Validate(vectorX, vectorY), "Vectors exceeding board size should not pass"); }
public void Ship_HasProperVectors_ReturnsTrue(ShipVector vectorX, ShipVector vectorY) { Assert.IsTrue(validator.Validate(vectorX, vectorY), "Proper vectors not passed"); }
public void Ship_HasVectorMoreThanBiggestShipSize_ReturnsFalse(ShipVector vectorX, ShipVector vectorY) { Assert.IsFalse(validator.Validate(vectorX, vectorY), $"Vectors bigger than {_gameSettings.ShipSizes.Max()} should not pass"); }