コード例 #1
0
        public void GetAllAlbums()
        {
            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>");

            AlbumLogic.CreateAlbumByTags(User().Email, "Cats", tagsList);

            Assert.AreEqual(UserLogic.GetAllAlbums(user.Email).Count, 1);
        }
コード例 #2
0
 public IActionResult GenerateAlbum([FromQuery] string[] tag, [FromQuery] string name = "")
 {
     try
     {
         string     email = HttpContext.User.Claims.First().Value;
         List <Tag> tags  = new List <Tag>();
         foreach (string t in tag)
         {
             tags.Add(Tag.ByName(t));
         }
         return(Ok(AlbumModel.ToModel(Albums.CreateAlbumByTags(email, name, tags))));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }