<commit_before>﻿using EffectiveCSharp4.Chapter1.Topic5;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EffectiveCSharp4Test
{
	[TestFixture]
	public class Chapter1Test
	{
		[Test]
		public void CustomerToString()
		{
			var customer = new Customer();
			customer.ToString().Is("EffectiveCSharp4.Chapter1.Topic5.Customer");
		}

		[Test]
		public void CustomerOverriddenToString()
		{
			var customer2 = new Customer_2 { Name = "Hidari" };
			customer2.ToString().Is("Hidari");
		}

		[Test]
		public void NamelessFunctionToString()
		{
			int[] list = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
			var test = new { Name = "Me", Numbers = list.Select(x => x) };
			Console.WriteLine(test);
		}

	}

	[TestFixture]
	public class Topic_ToString
	{
		CustomerWithIFoFormattable customer;
		private readonly string _expectedRevenue = '\u00a5' + "10,000,000";

		[SetUp]
		public void Init()
		{
			this.customer = new CustomerWithIFoFormattable{
				Name = "Hidari", 
				Revenue = 10000000, 
				ContactPhone = "09012345678" };
		}

		[TestCase("n", "Hidari")]
		[TestCase(null, "Hidari")]
		[TestCase("p", "    09012345678")]
		[TestCase("pn", "    09012345678,               Hidari")]
		public void ToStringWithFormatString(string format, string expect)
		{
			customer.ToString(format, null).Is(expect);
		}
		
		[Test]
		public void ToStringReturnsRevenue()
		{
			customer.ToString("r", null).Is(_expectedRevenue);
		}

		[Test]
		public void ToStringRevenueAndPhone()
		{
			customer.ToString("rp", null).Is( _expectedRevenue + ",     09012345678");
		}
		
		[Test]
		public void TostringReturnsRevenueAndName()
		{
			customer.ToString("rn", null).Is(_expectedRevenue + ",               Hidari");
		}

		[Test]
		public void Phone_Revenue()
		{
			customer.ToString("pr", null).Is("    09012345678, " + _expectedRevenue);
		}

		[Test]
		public void Name_Revenue()
		{
			customer.ToString("nr", null).Is("              Hidari, " + _expectedRevenue);
		}

		[Test]
		public void Name_phone()
		{
			customer.ToString("np", null).Is("              Hidari,     09012345678");
		}

		[Test]
		public void Revenue_Phone_Name()
		{
			customer.ToString("rpn", null).Is(_expectedRevenue + ",     09012345678,               Hidari");
		}

		[Test]
		public void Revenue_Name_Phone()
		{
			customer.ToString("rnp", null).Is(_expectedRevenue + ",               Hidari,     09012345678");
		}

		[Test]
		public void Phone_Revenue_Name()
		{<commit_msg>テストをリファクタリング。<commit_after>﻿using EffectiveCSharp4.Chapter1.Topic5;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EffectiveCSharp4Test
{
	[TestFixture]
	public class Chapter1Test
	{
		[Test]
		public void CustomerToString()
		{
			var customer = new Customer();
			customer.ToString().Is("EffectiveCSharp4.Chapter1.Topic5.Customer");
		}

		[Test]
		public void CustomerOverriddenToString()
		{
			var customer2 = new Customer_2 { Name = "Hidari" };
			customer2.ToString().Is("Hidari");
		}

		[Test]
		public void NamelessFunctionToString()
		{
			int[] list = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
			var test = new { Name = "Me", Numbers = list.Select(x => x) };
			Console.WriteLine(test);
		}

	}

	[TestFixture]
	public class Topic_ToString
	{
		CustomerWithIFoFormattable customer;
		private readonly string _expectedRevenue = '\u00a5' + "10,000,000";

		[SetUp]
		public void Init()
		{
			this.customer = new CustomerWithIFoFormattable{
				Name = "Hidari", 
				Revenue = 10000000, 
				ContactPhone = "09012345678" };
		}

		[TestCase("n", "Hidari")]
		[TestCase(null, "Hidari")]
		[TestCase("p", "    09012345678")]
		[TestCase("pn", "    09012345678,               Hidari")]
		[TestCase("np", "              Hidari,     09012345678")]
		public void ToStringWithFormatString(string format, string expect)
		{
			customer.ToString(format, null).Is(expect);
		}
		
		[Test]
		public void ToStringReturnsRevenue()
		{
			customer.ToString("r", null).Is(_expectedRevenue);
		}

		[Test]
		public void ToStringRevenueAndPhone()
		{
			customer.ToString("rp", null).Is( _expectedRevenue + ",     09012345678");
		}
		
		[Test]
		public void TostringReturnsRevenueAndName()
		{
			customer.ToString("rn", null).Is(_expectedRevenue + ",               Hidari");
		}

		[Test]
		public void Phone_Revenue()
		{
			customer.ToString("pr", null).Is("    09012345678, " + _expectedRevenue);
		}

		[Test]
		public void Name_Revenue()
		{
			customer.ToString("nr", null).Is("              Hidari, " + _expectedRevenue);
		}

		[Test]
		public void Revenue_Phone_Name()
		{
			customer.ToString("rpn", null).Is(_expectedRevenue + ",     09012345678,               Hidari");
		}

		[Test]
		public void Revenue_Name_Phone()
		{
			customer.ToString("rnp", null).Is(_expectedRevenue + ",               Hidari,     09012345678");
		}

		[Test]
		public void Phone_Revenue_Name()
		{
{'fraction_non_alphanumeric': 0.13886133703630232, 'fraction_numerical': 0.05118032136480857, 'mean_word_length': 3.291063829787234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '4665019', 'n_tokens_mistral': 2160, 'n_tokens_neox': 1714, 'n_words': 343}