public void TestOneA(OneAInputModel input, OneAOutputModel expectedOutput) { var output = this.calculationService.CalculateOneA(input); Assert.Equal(expectedOutput.VertexOne.XCoordinate, output.VertexOne.XCoordinate); Assert.Equal(expectedOutput.VertexOne.YCoordinate, output.VertexOne.YCoordinate); Assert.Equal(expectedOutput.VertexTwo.XCoordinate, output.VertexTwo.XCoordinate); Assert.Equal(expectedOutput.VertexTwo.YCoordinate, output.VertexTwo.YCoordinate); Assert.Equal(expectedOutput.VertexThree.XCoordinate, output.VertexThree.XCoordinate); Assert.Equal(expectedOutput.VertexThree.YCoordinate, output.VertexThree.YCoordinate); }
public OneAOutputModel CalculateOneA(OneAInputModel inputModel) { var outputModel = new OneAOutputModel { Input = $"{inputModel.Row}{inputModel.Column}" }; var rowNumber = this.CalculateRowNumber(inputModel.Row) - 1; //It is known that the length of each triangle is 10 so that can be used to find the started coord var xCord = (long)Math.Floor((double)(inputModel.Column - 1) / 2) * this.TriangleLength; var yCord = rowNumber * this.TriangleLength; //If the column is an odd give the points as the same format as 1b //If the column is an even the triangle is flipped //V2x, V2y and V3x, V3y are always in the same position while V1x and V1y are always the right angle if (inputModel.Column % 2 == 0) { //State it is an even column to help with the view on the UI outputModel.EvenColumn = true; //Add the length of the triangle where necessary outputModel.VertexOne = this.NewVertexModel(xCord + this.TriangleLength, yCord); outputModel.VertexTwo = this.NewVertexModel(xCord, yCord); outputModel.VertexThree = this.NewVertexModel(xCord + this.TriangleLength, yCord + this.TriangleLength); } else { //Add the length of the triangle where necessary outputModel.VertexOne = this.NewVertexModel(xCord, yCord + this.TriangleLength); outputModel.VertexTwo = this.NewVertexModel(xCord, yCord); outputModel.VertexThree = this.NewVertexModel(xCord + this.TriangleLength, yCord + this.TriangleLength); } return(outputModel); }