<commit_before>﻿using MatterHackers.MatterControl;
using NUnit.Framework;
using System;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Globalization;
using MatterHackers.MatterControl.SettingsManagement;
using MatterHackers.Agg.PlatformAbstract;
using MatterHackers.MatterControl.Tests.Automation;

namespace MatterControl.Tests.MatterControl
{
	class PrinterChooserUnitTests
	{
		[Test]
		public void PrinterChooserHonorsWhitelist()
		{
			StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));

			MatterControlUtilities.OverrideAppDataLocation();

			// Whitelist on non-OEM builds should contain all printers
			var printChooser = new PrinterChooser();
			
			Assert.IsTrue(printChooser.CountOfMakes > 15);

			// Set private member to override settings.json values for this test
			SetPrivatePrinterWhiteListMember(new List<string>() { "3D Stuffmaker" });
			printChooser = new PrinterChooser();
			Assert.IsTrue(printChooser.CountOfMakes == 1);

			SetPrivatePrinterWhiteListMember(new List<string>() { "Airwolf 3D", "3D Stuffmaker" });
			printChooser = new PrinterChooser();
			Assert.IsTrue(printChooser.CountOfMakes == 2);

			SetPrivatePrinterWhiteListMember(new List<string>() { "Esagono" });
			var manufacturerNameMapping = new ManufacturerNameMapping();
			manufacturerNameMapping.NameOnDisk = "Esagono";
			manufacturerNameMapping.NameToDisplay = "Esagonò";
			printChooser = new PrinterChooser();

			string expectedItem = null;
			foreach (var menuItem in printChooser.ManufacturerDropList.MenuItems)
			{
				if(menuItem.Text.StartsWith("Esa"))
				{
					expectedItem = menuItem.Text;
				}
			}
			Assert.IsTrue(!string.IsNullOrEmpty(expectedItem) && expectedItem == "Esagonò");
		}

		private static void SetPrivatePrinterWhiteListMember(List<string> newValue)
		{
			var fieldInfo = typeof(OemSettings).GetField("printerWhiteList", BindingFlags.Instance | BindingFlags.NonPublic);
			fieldInfo.SetValue(OemSettings.Instance, newValue);
		}
	}
}<commit_msg>Disable Esagono droplist label tests<commit_after>﻿using MatterHackers.MatterControl;
using NUnit.Framework;
using System;
using System.IO;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Globalization;
using MatterHackers.MatterControl.SettingsManagement;
using MatterHackers.Agg.PlatformAbstract;
using MatterHackers.MatterControl.Tests.Automation;

namespace MatterControl.Tests.MatterControl
{
	class PrinterChooserUnitTests
	{
		[Test]
		public void PrinterChooserHonorsWhitelist()
		{
			StaticData.Instance = new MatterHackers.Agg.FileSystemStaticData(Path.Combine("..", "..", "..", "..", "StaticData"));

			MatterControlUtilities.OverrideAppDataLocation();

			// Whitelist on non-OEM builds should contain all printers
			var printChooser = new PrinterChooser();
			
			Assert.IsTrue(printChooser.CountOfMakes > 15);

			// Set private member to override settings.json values for this test
			SetPrivatePrinterWhiteListMember(new List<string>() { "3D Stuffmaker" });
			printChooser = new PrinterChooser();
			Assert.IsTrue(printChooser.CountOfMakes == 1);

			SetPrivatePrinterWhiteListMember(new List<string>() { "Airwolf 3D", "3D Stuffmaker" });
			printChooser = new PrinterChooser();
			Assert.IsTrue(printChooser.CountOfMakes == 2);

			/* 
			 * Disable Esagono tests
			 * 
			SetPrivatePrinterWhiteListMember(new List<string>() { "Esagono" });
			var manufacturerNameMapping = new ManufacturerNameMapping();
			manufacturerNameMapping.NameOnDisk = "Esagono";
			manufacturerNameMapping.NameToDisplay = "Esagonò";
			printChooser = new PrinterChooser();

			string expectedItem = null;
			foreach (var menuItem in printChooser.ManufacturerDropList.MenuItems)
			{
				if(menuItem.Text.StartsWith("Esa"))
				{
					expectedItem = menuItem.Text;
				}
			}
			Assert.IsTrue(!string.IsNullOrEmpty(expectedItem) && expectedItem == "Esagonò");
			*/
		}

		private static void SetPrivatePrinterWhiteListMember(List<string> newValue)
		{
			var fieldInfo = typeof(OemSettings).GetField("printerWhiteList", BindingFlags.Instance | BindingFlags.NonPublic);
			fieldInfo.SetValue(OemSettings.Instance, newValue);
		}
	}
}
{'fraction_non_alphanumeric': 0.10854133272269292, 'fraction_numerical': 0.003205862147927639, 'mean_word_length': 5.186968838526912, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '5451657', 'n_tokens_mistral': 1551, 'n_tokens_neox': 1306, 'n_words': 253}