public void Handle_WhenAppropriateTileDoesNotExist_ShouldThrowNotFoundException() { // arrange var command = new CreateNoughtPlayerGameTileCommand { GameId = 1, X = 3, Y = 3 }; var handler = new CreateNoughtPlayerGameTileCommandHandler(Context); // act // assert Should.ThrowAsync <NotFoundException>(() => handler.Handle(command, CancellationToken.None)); }
public async Task Handle_WhenAppropriateTileExists_ShouldCreateNoughtPlayerGameTile() { // arrange var command = new CreateNoughtPlayerGameTileCommand { GameId = 1, X = 3, Y = 3 }; var handler = new CreateNoughtPlayerGameTileCommandHandler(Context); // act int result = await handler.Handle(command, CancellationToken.None); NoughtPlayerGameTile entity = Context.NoughtPlayerGameTiles.Find(result); // assert entity.ShouldNotBeNull(); entity.Game.Id.ShouldBe(command.GameId); ((int)entity.Tile.X).ShouldBe(command.X); ((int)entity.Tile.Y).ShouldBe(command.Y); }