public async Task <IActionResult> CreateUrl([FromBody] UrlViewModel urlViewModel) { try { await _urlService.CreateUrlAsync(urlViewModel); return(Created("", urlViewModel)); } catch (UrlValidationException ex) { return(BadRequest(ex.Errors)); } }
public void Url_Should_Be_Created_Received_And_Deleted_Successfully() { var url = new UrlViewModel { OriginalUrl = "www.google.com", ShortUrl = "googl" }; Assert.That(() => _urlService.CreateUrlAsync(url), Throws.Nothing); var result = _urlService.GetUrlByKeyAsync("googl"); Assert.IsNotNull(result); Assert.That(() => _urlService.DeleteUrlAsync("googl"), Throws.Nothing); }