public void CreateAlbum() { List <string> tags = new List <string>(); tags.Add("Cat"); tags.Add("Feline"); List <Tag> tagsList = new List <Tag>(); tagsList.Add(Tag.ByName("Cat")); tagsList.Add(Tag.ByName("Feline")); 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(tags); User user = SessionLogic.SignUp(User()); Photo photo = UserLogic.AddPhoto(user.Email, Photo(), "<encodedImageInBase64>"); Album generatedAlbum = AlbumLogic.CreateAlbumByTags(User().Email, "Cats", tagsList); Assert.IsTrue(generatedAlbum.Photos().Contains(photo)); }
public void UploadPhoto() { 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 photo = UserLogic.AddPhoto(user.Email, Photo(), "<encodedImageInBase64>"); Assert.IsTrue(photo.Latitude == Photo().Latitude&& photo.Longitude == Photo().Longitude&& photo.Type == Photo().Type&& photo.Location == Photo().Location); }
public IActionResult UploadPhoto([FromBody] PhotoModel photoFromRequest) { try { string email = HttpContext.User.Claims.First().Value; return(Ok(PhotoModel.ToModel(Users.AddPhoto(email, photoFromRequest.ToEntity(), photoFromRequest.ImageBase64)))); } catch (Exception e) { return(BadRequest(e.Message)); } }
public void SearchByTags() { List <string> tags = new List <string>(); tags.Add("Cat"); tags.Add("Feline"); List <Tag> tagsList = new List <Tag>(); tagsList.Add(Tag.ByName("Cat")); tagsList.Add(Tag.ByName("Feline")); 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(tags); User user = SessionLogic.SignUp(User()); Photo photo = UserLogic.AddPhoto(user.Email, Photo(), "<encodedImageInBase64>"); List <Photo> returnedPhotos = PhotoLogic.SearchByTags(user.Email, tagsList); Assert.AreEqual(returnedPhotos[0], photo); }