public static ActionResult <MineResultResponse> Post([Required, FromBody] List <MineModel> mines) { foreach (var mine in mines) { if (mines.Count(m => m.X == mine.X && m.Y == mine.Y) > 1) { return(new BadRequestObjectResult("You put two mines on the same square, that's a No-No.")); } } return(MineResults.GetForAllMines(mines)); }
public void Get_BigStartingMine_PassedThroughToResults() { // Arrange List <MineModel> mines = new List <MineModel> { new MineModel(1, 1, 1), new MineModel(2, 1, 0), new MineModel(28, 32, 105) }; // Act var results = MineResults.GetForAllMines( mines); //output.WriteLine(JsonConvert.SerializeObject(result.MinesThatExploded, Formatting.Indented)); // Assert Assert.True(results.PossibleStartingMines.Any(m => m.X == 28 && m.Y == 32) && results.MinesExploded == 3); }
public void Get_TwoHugeMines_BothIncluded() { // Arrange List <MineModel> mines = new List <MineModel> { new MineModel(1, 1, 1), new MineModel(2, 1, 0), new MineModel(28, 32, 105), new MineModel(28, 33, 105) }; // Act var results = MineResults.GetForAllMines( mines); //output.WriteLine(JsonConvert.SerializeObject(result.MinesThatExploded, Formatting.Indented)); // Assert Assert.Equal(2, results.PossibleStartingMines.Count()); }