public void ChangeValueOfSquareReturnsCorrectNumberOfChanges(string stringSequence, int changeValue, int expectedChangeValue) { MagicSquare square = new MagicSquare(stringSequence); square = square.ChangeValueOfSquareAtLocation(0, 0, changeValue); square.GetNumberOfChanges().Should().Be(expectedChangeValue); }
public void MultipleChangesOutputCorrectChangeValue() { MagicSquare square = new MagicSquare("4,9,2,3,5,7,8,1,5"); square = square .ChangeValueOfSquareAtLocation(0, 0, 5) .ChangeValueOfSquareAtLocation(0, 0, 7) .ChangeValueOfSquareAtLocation(2, 2, 7); square.GetNumberOfChanges().Should().Be(5); }
public static MagicSquare ApplyPattern(string patternToMatch, MagicSquare square) { int counter = 0; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { square = square.ChangeValueOfSquareAtLocation(i, j, int.Parse(patternToMatch.Split(',')[counter])); counter++; } } return(square); }