public async Task ShouldReturnRandomImageUriForBreed() { // Arrange var breed = "african"; var httpClient = PrepareHttpClient(breed); _mockHttpClientFactory.Setup(f => f.CreateClient(It.IsAny <string>())).Returns(httpClient); var expectedUri = "https://images.dog.ceo/breeds/" + breed + ".jpg"; // Act var uri = await dogService.GetRandomPictureUrlAsync(breed); // Assert Assert.Equal(new Uri(expectedUri), uri); }
public async Task GetDogPicAsync(CommandContext ctx, [RemainingText, Description("Optional: The breed of the dogger")] string breed = "") { await ctx.TriggerTypingAsync(); Uri pictureURL = breed.IsEmpty() ? await(_dogService?.GetRandomPictureUrlAsync()) : await(_dogService?.GetRandomPictureUrlAsync(breed.ToLowerInvariant())); if (pictureURL == null) { await ctx.ErrorAsync($"Could not get a dog pic :(. Try using {ctx.Prefix}dogbreeds to get a list of dog breeds I can show you"); return; } DiscordEmbedBuilder builder = new DiscordEmbedBuilder() .WithColor(dogColor) .WithImageUrl(pictureURL); await ctx.RespondAsync(embed : builder.Build()); }