<commit_before>using DarkSky.Services;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;

namespace DarkSky.IntegrationTests.Services
{
	public class DarkSkyServiceIntegrationTests : IDisposable
	{
		readonly string _apiEnvVar = "DarkSkyApiKey";
		readonly double _latitude = 42.915;
		readonly double _longitude = -78.741;
		DarkSkyService _darkSky;

		public DarkSkyServiceIntegrationTests()
		{
			var configBuilder = new ConfigurationBuilder()
				.AddEnvironmentVariables();
			var config = configBuilder.Build();
			var apiKey = config.GetValue<string>(_apiEnvVar);
			Assert.False(string.IsNullOrWhiteSpace(apiKey), $"You must set the environment variable {_apiEnvVar}");
			_darkSky = new DarkSkyService(apiKey);
		}

		[Fact]
		public async Task BuffaloForecastCombineAllOptions()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				ExtendHourly = true,
				DataBlocksToExclude = new List<string> { "flags" },
				LanguageCode = "x-pig-latin",
				MeasurementUnits = "si"
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Daily.Data.Count, 8);
			Assert.Equal(forecast.Response.Hourly.Data.Count, 169);
			Assert.Null(forecast.Response.Flags);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastEverythingParsed()
		{
			JsonConvert.DefaultSettings = () => new JsonSerializerSettings
			{
				MissingMemberHandling = MissingMemberHandling.Error
			};
			var forecast = await _darkSky.GetForecast(_latitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastExclude()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				DataBlocksToExclude = new List<string> { "daily" }
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Null(forecast.Response.Daily);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastExtendHourly()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				ExtendHourly = true
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Hourly.Data.Count, 169);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastPigLatin()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				LanguageCode = "x-pig-latin"
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastReturnsFullObject()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude);
			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Hourly.Data.Count, 49);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastTimeMachine()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				UnixTimeInSeconds = new DateTimeOffset(DateTime.UtcNow.AddHours(2)).ToUnixTimeSeconds()
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Daily.Data.Count, 1);
			Assert.Null(forecast.Response.Minutely);
			// Contrary to documentation, Alerts is not always omitted for time machine requests.
			// Assert.Null(forecast.Response.Alerts);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastUnits()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				MeasurementUnits = "si"
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloTimeMachineForecastCombineAllOptions()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				UnixTimeInSeconds = new DateTimeOffset(DateTime.UtcNow.AddHours(2)).ToUnixTimeSeconds(),
				DataBlocksToExclude = new List<string> { "flags" },
				LanguageCode = "x-pig-latin",
				MeasurementUnits = "si"
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Daily.Data.Count, 1);
			Assert.Equal(forecast.Response.Hourly.Data.Count, 24);
			Assert.Null(forecast.Response.Minutely);
			// Contrary to documentation, Alerts is not always omitted for time machine requests.
			// Assert.Null(forecast.Response.Alerts);
			Assert.Null(forecast.Response.Flags);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		public void Dispose()
		{
			_darkSky = null;
			JsonConvert.DefaultSettings = () => new JsonSerializerSettings
			{
				MissingMemberHandling = MissingMemberHandling.Ignore
			};
		}
	}
}<commit_msg>Add unit test for culture change<commit_after>using DarkSky.Services;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
using System.Globalization;

namespace DarkSky.IntegrationTests.Services
{
	public class DarkSkyServiceIntegrationTests : IDisposable
	{
		readonly string _apiEnvVar = "DarkSkyApiKey";
		readonly double _latitude = 42.915;
		readonly double _longitude = -78.741;
		DarkSkyService _darkSky;

		public DarkSkyServiceIntegrationTests()
		{
			var configBuilder = new ConfigurationBuilder()
				.AddEnvironmentVariables();
			var config = configBuilder.Build();
			var apiKey = config.GetValue<string>(_apiEnvVar);
			Assert.False(string.IsNullOrWhiteSpace(apiKey), $"You must set the environment variable {_apiEnvVar}");
			_darkSky = new DarkSkyService(apiKey);
		}

		[Fact]
		public async Task BuffaloForecastCombineAllOptions()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				ExtendHourly = true,
				DataBlocksToExclude = new List<string> { "flags" },
				LanguageCode = "x-pig-latin",
				MeasurementUnits = "si"
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Daily.Data.Count, 8);
			Assert.Equal(forecast.Response.Hourly.Data.Count, 169);
			Assert.Null(forecast.Response.Flags);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastCombineAllOptionsGermanCulture()
		{
			CultureInfo.CurrentCulture = new CultureInfo("de-DE");
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				ExtendHourly = true,
				DataBlocksToExclude = new List<string> { "flags" },
				LanguageCode = "x-pig-latin",
				MeasurementUnits = "si"
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Daily.Data.Count, 8);
			Assert.Equal(forecast.Response.Hourly.Data.Count, 169);
			Assert.Null(forecast.Response.Flags);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastEverythingParsed()
		{
			JsonConvert.DefaultSettings = () => new JsonSerializerSettings
			{
				MissingMemberHandling = MissingMemberHandling.Error
			};
			var forecast = await _darkSky.GetForecast(_latitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastExclude()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				DataBlocksToExclude = new List<string> { "daily" }
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Null(forecast.Response.Daily);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastExtendHourly()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				ExtendHourly = true
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Hourly.Data.Count, 169);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastPigLatin()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				LanguageCode = "x-pig-latin"
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastReturnsFullObject()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude);
			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Hourly.Data.Count, 49);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastTimeMachine()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				UnixTimeInSeconds = new DateTimeOffset(DateTime.UtcNow.AddHours(2)).ToUnixTimeSeconds()
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Daily.Data.Count, 1);
			Assert.Null(forecast.Response.Minutely);
			// Contrary to documentation, Alerts is not always omitted for time machine requests.
			// Assert.Null(forecast.Response.Alerts);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloForecastUnits()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				MeasurementUnits = "si"
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		[Fact]
		public async Task BuffaloTimeMachineForecastCombineAllOptions()
		{
			var forecast = await _darkSky.GetForecast(_latitude, _longitude, new DarkSkyService.OptionalParameters
			{
				UnixTimeInSeconds = new DateTimeOffset(DateTime.UtcNow.AddHours(2)).ToUnixTimeSeconds(),
				DataBlocksToExclude = new List<string> { "flags" },
				LanguageCode = "x-pig-latin",
				MeasurementUnits = "si"
			});

			Assert.NotNull(forecast);
			Assert.NotNull(forecast.Response);
			Assert.NotNull(forecast.Headers);
			Assert.Equal(forecast.Response.Daily.Data.Count, 1);
			Assert.Equal(forecast.Response.Hourly.Data.Count, 24);
			Assert.Null(forecast.Response.Minutely);
			// Contrary to documentation, Alerts is not always omitted for time machine requests.
			// Assert.Null(forecast.Response.Alerts);
			Assert.Null(forecast.Response.Flags);
			Assert.Equal(forecast.Response.Latitude, _latitude);
			Assert.Equal(forecast.Response.Longitude, _longitude);
		}

		public void Dispose()
		{
			_darkSky = null;
			JsonConvert.DefaultSettings = () => new JsonSerializerSettings
			{
				MissingMemberHandling = MissingMemberHandling.Ignore
			};
			CultureInfo.CurrentCulture = new CultureInfo("en-US");
		}
	}
}
{'fraction_non_alphanumeric': 0.11026260422348633, 'fraction_numerical': 0.004207901503935167, 'mean_word_length': 4.636363636363637, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3525015', 'n_tokens_mistral': 4714, 'n_tokens_neox': 3953, 'n_words': 671}