public async Task TestV2(string extraPath) { var requestUrl = new UrlToWFV2(ApiBaseUrl, PathToV2 + extraPath).ToUri(); LogRequestUrl(requestUrl); await VerifyWebException( test : async() => { using (var response = await TestRequest <WeatherForecastV2[]>(requestUrl, options => options.Converters.Add(new DateTimeJsonConverter()))) { } }, statusCode : HttpStatusCode.NotFound); }
public async Task TestWFV2(string extraPath) { var requestUrl = new UrlToWFV2(ApiBaseUrl, PathToV2WeatherForecast + extraPath).ToUri(); LogRequestUrl(requestUrl); await LogWebException(async() => { using (var response = await TestRequest <WeatherForecastV2[]>(requestUrl, options => options.Converters.Add(new DateTimeJsonConverter()))) { Assert.That(response.Data.Length, Is.EqualTo(5 * 3)); } }); }
public async Task TestV2(string endpoint, string date, int expectedNumberOfResults, string expectedFirstDate) { var requestUrl = new UrlToWFV2(ApiBaseUrl, endpoint) { From = date }.ToUri(); await LogWebException(async() => { using (var response = await TestRequest <WeatherForecastV1[]>(requestUrl)) { Assert.That(response.Data.Length, Is.EqualTo(expectedNumberOfResults)); Assert.That(response.Data[0].Date, Is.EqualTo(expectedFirstDate)); } }); }
public async Task TestWFWithValidAreaAndInvalidDateV2(string area, string date) { var requestUrl = new UrlToWFV2(ApiBaseUrl, PathToV2WeatherForecastArea) { Area = area, From = date }.ToUri(); LogRequestUrl(requestUrl); await VerifyWebException <ValidationErrorResponseModel>( test : async() => { using (var response = await TestRequest <WeatherForecastV2[]>(requestUrl, options => options.Converters.Add(new DateTimeJsonConverter()))) { } }, statusCode : HttpStatusCode.InternalServerError, verify : err => Assert.That(err.Title, Is.EqualTo($"'{date}' should be in yyyyMMdd format. (Parameter 'from')"))); }
public async Task TestWFWithValidAreaAndValidDateV2(string area, string date, int?days, DateTime?firstDate) { var requestUrl = new UrlToWFV2(ApiBaseUrl, PathToV2WeatherForecastArea) { Area = area, From = date, Days = days }.ToUri(); LogRequestUrl(requestUrl); await LogWebException(async() => { var now = DateTime.UtcNow; using (var response = await TestRequest <WeatherForecastV2[]>(requestUrl, options => options.Converters.Add(new DateTimeJsonConverter()))) { Assert.That(response.Data.Length, Is.EqualTo(days ?? 5)); Assert.That(response.Data.Min(d => d.Date), Is.EqualTo(firstDate ?? new DateTime(now.Year, now.Month, now.Day))); } }); }