コード例 #1
0
        public void Search_ReturnsPopulatedResults()
        {
            var sampleResponse = new NutritionixSearchResponse
                {
                    TotalResults = 1,
                    Results = new[] { new NutritionixSearchResult() }
                };
            string json = JsonConvert.SerializeObject(sampleResponse);
            MockResponse(json);

            var client = new NutritionixClient();
            var request = new NutritionixSearchRequest { Query = "foobar" };
            NutritionixSearchResponse response = client.SearchItems(request);

            Assert.AreEqual(1, response.Results.Length);
        }
コード例 #2
0
        public void Search_ReturnsEmptyResults_WhenResultsIsNull()
        {
            var sampleResponse = new NutritionixSearchResponse
                {
                    TotalResults = 0,
                    Results = null
                };
            string json = JsonConvert.SerializeObject(sampleResponse);
            MockResponse(json);

            var client = new NutritionixClient();
            var request = new NutritionixSearchRequest { Query = "foobar" };
            NutritionixSearchResponse response = client.SearchItems(request);

            Assert.IsNotNull(response.Results);
            Assert.AreEqual(0, response.Results.Length);
        }