public IActionResult AddTag(Guid id, [FromQuery] string tag) { try { return(Ok(PhotoModel.ToModel(Photos.AddTag(id, Tag.ByName(tag))))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void AddTag() { GoogleServices.SetupSequence(g => g.UploadImage(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())); GoogleServices.SetupSequence(g => g.GetImageURL(It.IsAny <string>())) .Returns("https://storage.googleapis.com/example"); GoogleServices.SetupSequence(g => g.GetImageTags(It.IsAny <string>())) .Returns(new List <string>()); User user = SessionLogic.SignUp(User()); Photo photoToUpdate = UserLogic.AddPhoto(user.Email, Photo(), "<encodedImageInBase64>"); Tag tag = Tag.ByName("Cat"); Photo updatedPhoto = PhotoLogic.AddTag(photoToUpdate.Id, tag); Assert.IsTrue(updatedPhoto.Tags.Exists(t => t.Name == tag.Name)); }