<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace Google.Maps.Test.Integrations
{
	public class HttpGetResponseFromResource : Google.Maps.Internal.Http.HttpGetResponse
	{
		System.Reflection.Assembly S_testAssembly = Assembly.GetAssembly(typeof(HttpGetResponseFromResource));

		public HttpGetResponseFromResource(Uri uri) : base(uri)
		{
		}

		private string _resourcePath;
		public string ResourcePath { get { return this._resourcePath; } }

		protected override System.IO.StreamReader GetStreamReader(Uri uri)
		{
			System.Text.StringBuilder queryString = new StringBuilder(uri.Query);
			queryString.Remove(0, 1); //remove the initial "?"
			queryString.Replace("&sensor=false",""); //clear off sensor=false
			queryString.Replace("&sensor=true", ""); // clear off sensor=true

			this._resourcePath = "Google.Maps.Test.Integrations.json_queries." + queryString.ToString() + ".json";

			Stream resourceStream = S_testAssembly.GetManifestResourceStream(this._resourcePath);
			return new StreamReader(resourceStream);
		}
	}

	public class HttpGetResponseFromResourceFactory : Google.Maps.Internal.Http.HttpGetResponseFactory
	{
		public override Internal.Http.HttpGetResponse CreateResponse(Uri uri)
		{
			return new HttpGetResponseFromResource(uri);
		}
	}
}
<commit_msg>Added a more descriptive error message when a json_query resource isn't found.<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.IO;

namespace Google.Maps.Test.Integrations
{
	public class HttpGetResponseFromResource : Google.Maps.Internal.Http.HttpGetResponse
	{
		System.Reflection.Assembly S_testAssembly = Assembly.GetAssembly(typeof(HttpGetResponseFromResource));

		public HttpGetResponseFromResource(Uri uri) : base(uri)
		{
		}

		private string _resourcePath;
		public string ResourcePath { get { return this._resourcePath; } }

		protected override System.IO.StreamReader GetStreamReader(Uri uri)
		{
			System.Text.StringBuilder queryString = new StringBuilder(uri.Query);
			queryString.Remove(0, 1); //remove the initial "?"
			queryString.Replace("&sensor=false",""); //clear off sensor=false
			queryString.Replace("&sensor=true", ""); // clear off sensor=true

			this._resourcePath = "Google.Maps.Test.Integrations.json_queries." + queryString.ToString() + ".json";

			Stream resourceStream = S_testAssembly.GetManifestResourceStream(this._resourcePath);

			if (resourceStream == null)
			{
				string message = string.Format(
@"Failed to find resource for query '{0}'.
Resource path used: '{1}'
Ensure a file exists at that resource path and the file has its Build Action set to ""Embedded Resource"".", queryString.ToString(), this._resourcePath);
				throw new FileNotFoundException(message);
			}

			return new StreamReader(resourceStream);
		}
	}

	public class HttpGetResponseFromResourceFactory : Google.Maps.Internal.Http.HttpGetResponseFactory
	{
		public override Internal.Http.HttpGetResponse CreateResponse(Uri uri)
		{
			return new HttpGetResponseFromResource(uri);
		}
	}
}

{'fraction_non_alphanumeric': 0.10367577756833177, 'fraction_numerical': 0.001885014137606032, 'mean_word_length': 5.243137254901961, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2369457', 'n_tokens_mistral': 967, 'n_tokens_neox': 884, 'n_words': 208}