public async Task <string> GetRecipeAsJson(string recipeName) { var recipeXml = await _recipesApi.MakeHttpRequestForRecipe(recipeName); var doc = new XmlDocument(); doc.LoadXml(recipeXml); var jsonResult = JsonConvert.SerializeXmlNode(doc); return(jsonResult); }
public async Task MakeHttpRequestForRecipe_Logs_Recipe() { var logger = new Mock <IApplicationLogger>(); var api = new RecipesApi(logger.Object); var result = await api.MakeHttpRequestForRecipe("mashed_potatoes"); logger.Verify(mock => mock.LogInfo( It.IsAny <string>(), It.IsAny <ConsoleColor>()), Times.AtLeastOnce()); }
public async Task MakeHttpRequestForRecipe_Gets_Value_From_Database_Given_Recipe() { var logger = new Mock <IApplicationLogger>(); var api = new RecipesApi(logger.Object); var result = await api.MakeHttpRequestForRecipe("mashed_potatoes"); using var reader = new StringReader(result); var recipe = (Recipe)xml.Deserialize(reader); recipe.Should().NotBeNull(); recipe.Name.Should().Be("Mashed Potatoes"); }