Exemple #1
0
        public async void PostRawAsync_MockSearchEndpoint_ReturnsJsonString()
        {
            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);

            string returnedString = await webRequester.PostRawAsync("https://api.nal.usda.gov/fdc/v1/search?api_key=DEMO_KEY", "{\"generalSearchInput\": \"big mac\"}");

            Assert.Equal(sampleJson, returnedString);
        }