public async Task GetHolidays_Throws_Exception_When_InValidData() { var content = new CalendarificApiResponse <HolidaysResponse>() { meta = new Meta() { code = 404, error_type = "call failed", error_detail = @"Missing required call parameters. See https:\/\/calendarific.com\/ for details." }, response = null }; _calendarificClient.GetHolidays(Arg.Any <HolidayParameters>()) .Returns(new ApiResponse <CalendarificApiResponse <HolidaysResponse> >(Substitute.For <HttpResponseMessage>(), content)); _subjectUnderTest = new CalendarificService(_mapper, _calendarificClient); await Should.ThrowAsync <InvalidOperationException>(async() => await _subjectUnderTest.GetHolidays(new HolidayParameters())); }
public async Task <Holiday[]> GetHolidays(HolidayParameters holidayParameters) { var data = await _calendarificClient.GetHolidays(holidayParameters); await data.EnsureSuccessStatusCodeAsync(); data.Content.EnsureSuccessStatusCode(); var holidays = _mapper.Map <ApiHoliday[], Holiday[]>(data.Content.response.holidays); return(holidays); }