/// <summary> /// Finds the base image of the meme without any text /// </summary> /// <param name="id">The id of the meme you want to find</param> /// <returns></returns> public async Task <Uri> GetMemeBaseImage(int id) { GetMemeRoot x = await GetMemesAsync(); Meme matchedMeme = x.data.memes.Find(meme => meme.id.Contains(id.ToString())); return(new Uri(matchedMeme.url)); }
public void CaptionMeme() { string template_id = "0"; string toptext = "hello"; string bottomtext = "it's me"; GetMemeRoot x = ImgFlipAPISource.Instance.GetMemesAsync().Result; List<Meme> xList = x.data.memes; template_id = xList[0].id; CaptionMemeRoot z = ImgFlipAPISource.Instance.CaptionMemeAsync(template_id, username, password, toptext, bottomtext).Result; Assert.IsNotNull(z.data.url); }
/// <summary> /// Returns a meme object from a given search term. If there are multiple matches, returns the first match. /// If a request is made that ends in a plurality (like s), also searches for the single instance version of that /// term. /// </summary> /// <param name="searchTerm">The search term you want to find.</param> /// <returns></returns> public async Task <List <Meme> > FindMeme(String searchTerm) { GetMemeRoot x = await GetMemesAsync(); // we need to convert all the memes to lowercase so we can search foreach (Meme meme in x.data.memes) { meme.name = meme.name.ToLower(); } List <Meme> matchedMeme = x.data.memes.FindAll(meme => meme.name.Contains(searchTerm.ToLower())); // if the user asked for a pluarality (e.g. cats or penguins or dogs) if (matchedMeme.Count == 0 && searchTerm.Last() == 's') { string NonPluralTerm = searchTerm.Remove(searchTerm.LastIndexOf('s')); List <Meme> secondTryMatchMeme = x.data.memes.FindAll(meme => meme.name.Contains(NonPluralTerm.ToLower())); if (secondTryMatchMeme.Count > 0) { return(secondTryMatchMeme); } } return(matchedMeme); }
public void GetMemesReturnsList() { GetMemeRoot x = ImgFlipAPISource.Instance.GetMemesAsync().Result; List<Meme> xList = x.data.memes; Assert.IsTrue(xList.Count > 99); }