예제 #1
0
        public async void PostAsync_MockSearchEndpoint_ReturnsSearchResultObject()
        {
            string     sampleJson   = File.ReadAllText("Data/BigMacSearch.json");
            var        mockClient   = new HttpClient(Util.MockHttpMessageHandlerFactory("https://api.nal.usda.gov/fdc/v1/search?api_key=DEMO_KEY", sampleJson));
            IRequester webRequester = new WebRequester(mockClient);

            var returnedObject = await webRequester.PostAsync <SearchResult>("https://api.nal.usda.gov/fdc/v1/search?api_key=DEMO_KEY", "{\"generalSearchInput\": \"big mac\"}");

            string searchInput = returnedObject.FoodSearchCriteria.GeneralSearchInput;

            Assert.Equal("big mac", searchInput);
        }