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

            var returnedObject = await webRequester.GetAsync <Food>("https://api.nal.usda.gov/fdc/v1/170720?api_key=DEMO_KEY");

            string description = returnedObject.Description;

            Assert.Equal("McDONALD'S, BIG MAC", description);
        }