<commit_before>using System;
using System.Collections.Generic;
using NUnit.Framework;

namespace weblog
{
	class MockFinishedMetricsFlusher : BaseFinishedMetricsFlusher {

		override public void Flush (Object stateInfo){
			Console.WriteLine ("Flushed with " + stateInfo.ToString());
		}

	}

	[TestFixture()]
	public class LoggerTest
	{

		Logger MakeLogger(){
			return new Logger (new MockFinishedMetricsFlusher());
		}


		[Test()]
		public void should_be_configured_via_constructor_params ()
		{
			FinishedMetricsFlusher expectedFlusher = new MockFinishedMetricsFlusher ();

			Logger logger = new Logger (expectedFlusher);

			Assert.AreSame (expectedFlusher, logger.FinishedMetricsFlusher);
		}

		[Test()]
		public void should_throw_exception_if_flusher_not_provided ()
		{
			try {
				new Logger (null);
				Assert.Fail("expected an exception due null flusher");
			}
			catch(System.ArgumentException ex) {
				Assert.IsNotNull (ex);
			}
		}
			

		[Test()]
		public void it_should_sanitize_invalid_names() 
		{
			string[] chars = {@".", @"!", @"," , @";", @":", @"?", @"/", @"\", @"@", @"#", @"$", @"%", @"^", @"&", @"*", @"(", @")"};
			   
			foreach(String forbiddenChar in chars) {
				String actualMetricName = LoggerAPIConnectionWS.sanitizeMetricName(String.Format ("metric-name_1{0}2", forbiddenChar));
				Assert.AreEqual( @"metric-name_1_2", actualMetricName);
			}
		}
		
		
		[Test()]
		public void createTimer_should_return_new_running_timer() 
		{
			Logger logger = MakeLogger();
			Timer timer = logger.CreateTimer("some_metric");
			Assert.IsNotNull(timer);
			Assert.IsTrue (timer.IsRunning());
		}
		
		[Test()] 
		public void timer_should_have_metric_name() {
			Logger logger = MakeLogger();
			
			Timer timer = logger.CreateTimer("operation_to_measure_timing");
			
			Assert.AreEqual("operation_to_measure_timing", timer.MetricName);
		}
		
		<commit_msg>Give test a more-precise name.<commit_after>using System;
using System.Collections.Generic;
using NUnit.Framework;

namespace weblog
{
	class MockFinishedMetricsFlusher : BaseFinishedMetricsFlusher {

		override public void Flush (Object stateInfo){
			Console.WriteLine ("Flushed with " + stateInfo.ToString());
		}

	}

	[TestFixture()]
	public class LoggerTest
	{

		Logger MakeLogger(){
			return new Logger (new MockFinishedMetricsFlusher());
		}


		[Test()]
		public void should_be_configured_via_constructor_params ()
		{
			FinishedMetricsFlusher expectedFlusher = new MockFinishedMetricsFlusher ();

			Logger logger = new Logger (expectedFlusher);

			Assert.AreSame (expectedFlusher, logger.FinishedMetricsFlusher);
		}

		[Test()]
		public void should_throw_exception_if_flusher_not_provided ()
		{
			try {
				new Logger (null);
				Assert.Fail("expected an exception due null flusher");
			}
			catch(System.ArgumentException ex) {
				Assert.IsNotNull (ex);
			}
		}
			

		[Test()]
		public void it_should_sanitize_invalid_names() 
		{
			string[] chars = {@".", @"!", @"," , @";", @":", @"?", @"/", @"\", @"@", @"#", @"$", @"%", @"^", @"&", @"*", @"(", @")"};
			   
			foreach(String forbiddenChar in chars) {
				String actualMetricName = LoggerAPIConnectionWS.sanitizeMetricName(String.Format ("metric-name_1{0}2", forbiddenChar));
				Assert.AreEqual( @"metric-name_1_2", actualMetricName);
			}
		}
		
		
		[Test()]
		public void createTimer_should_return_new_running_timer() 
		{
			Logger logger = MakeLogger();
			Timer timer = logger.CreateTimer("some_metric");
			Assert.IsNotNull(timer);
			Assert.IsTrue (timer.IsRunning());
		}
		
		[Test()] 
		public void createTimer_should_return_timer_with_provided_metric_name()
		{
			Logger logger = MakeLogger();
			
			Timer timer = logger.CreateTimer("operation_to_measure_timing");
			
			Assert.AreEqual("operation_to_measure_timing", timer.MetricName);
		}
		
		
{'fraction_non_alphanumeric': 0.14296895382207148, 'fraction_numerical': 0.0026089225150013043, 'mean_word_length': 4.216326530612245, 'pattern_counts': {'":': 2, '<': 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': '4292929', 'n_tokens_mistral': 1442, 'n_tokens_neox': 1216, 'n_words': 222}