public async Task <IHttpActionResult> PostItemAsync([FromBody] Item item) { if (!PostIsItemValid(item)) { return(BadRequest(ModelState)); } var createdItem = await _itemCreatingService.CreateAsync(item); var itemUrl = _urlService.GetItemUrl(createdItem.Id); return(Created(itemUrl, createdItem)); }
public void GetItemUrl_ReturnsCreatedUrl() { var routeName = _routeNames.ItemRouteName; var id = Guid.Parse("EAB88043-345B-44F9-9839-296579D8AC62"); var expectedUrl = new Uri($"http://localhost/{id}/tests"); _urlHelper .Link(routeName, Arg.Is <object>(value => CompareIds(value, id))) .Returns(expectedUrl.ToString()); var actualUrl = _urlService.GetItemUrl(id); Assert.That(actualUrl, Is.EqualTo(expectedUrl)); }