<commit_before>﻿using System;
using System.Data;
using System.CodeDom.Compiler;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Spss.Testing
{
	/// <summary>
	///This is a test class for Spss.SpssConvert and is intended
	///to contain all Spss.SpssConvert Unit Tests
	///</summary>
	[TestClass()]
    [DeploymentItem("x86", "x86")]
    [DeploymentItem("x64", "x64")]
	public class SpssConvertTest
	{


		private TestContext testContextInstance;

		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}

		/// <summary>
		///Initialize() is called once during test execution before
		///test methods in this test class are executed.
		///</summary>
		[TestInitialize()]
		public void Initialize()
		{
			tblTest = new DataTable();
			DataColumn cID = tblTest.Columns.Add("ID", typeof(int));
			DataColumn cStr = tblTest.Columns.Add("str", typeof(string));
			DataColumn cDate = tblTest.Columns.Add("date", typeof(DateTime));
			DataColumn cFloat = tblTest.Columns.Add("float", typeof(float));

			const int cIDv = 3;
			const string cStrv = "hello";
			DateTime cDatev = DateTime.Now;
			const float cFloatv = 3.553F;
			object[] values = { cIDv, cStrv, cDatev, cFloatv };
			tblTest.Rows.Add(values);
		}

		/// <summary>
		///Cleanup() is called once during test execution after
		///test methods in this class have executed unless
		///this test class' Initialize() method throws an exception.
		///</summary>
		[TestCleanup()]
		public void Cleanup()
		{
		}

		DataTable tblTest;

		[TestMethod]
		[ExpectedException(typeof(ArgumentNullException))]
		public void toDdiNull()
		{
			SpssConvert.ToDdi((string)null);
		}

		[Ignore]
		[TestMethod]
		public void testT1()
		{
			SpssConvert.ToDdi(@"C:\Program Files\SPSS\T1.sav");
		}

		[Ignore]
		[TestMethod]
		public void testlistSurveys()
		{
			SpssConvert.ToDdi(@"C:\Program Files\SPSS\listsurveys.sav");
		}

		[TestMethod]
		public void smoking()
		{
			SpssConvert.ToDdi(@"C:\Program Files\SPSS\smoking.sav");
		}

		[TestMethod]
		public void anorectic()
		{
			SpssConvert.ToDdi(@"C:\Program Files\SPSS\anorectic.sav");
		}

		[TestMethod]
		public void MetaData()
		{
			string SAVfilename;
			using (System.CodeDom.Compiler.TempFileCollection tfc = new System.CodeDom.Compiler.TempFileCollection())
			{
				SAVfilename = tfc.AddExtension("sav", true);
				SpssConvert.ToFile(tblTest, tblTest.Select(), SAVfilename, FillInMetaData);
				Console.WriteLine("The file with metadata is stored at: " + SAVfilename);
			}
		}

		protected void FillInMetaData(SpssVariable var)
		{
			switch (var.Name)
			{
				case "ID":
					var numericVar = (SpssNumericVariable)var;
					var.Label = "Some ID label";
					numericVar.ValueLabels[1] = "one";
					numericVar.ValueLabels[2] = "two";
					numericVar.ValueLabels[3] = "three";
					numericVar.ValueLabels[4] = "four";
					break;<commit_msg>Ignore tests that cannot pass without SPSS installed<commit_after>﻿using System;
using System.Data;
using System.CodeDom.Compiler;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Spss.Testing
{
	/// <summary>
	///This is a test class for Spss.SpssConvert and is intended
	///to contain all Spss.SpssConvert Unit Tests
	///</summary>
	[TestClass()]
    [DeploymentItem("x86", "x86")]
    [DeploymentItem("x64", "x64")]
	public class SpssConvertTest
	{


		private TestContext testContextInstance;

		/// <summary>
		///Gets or sets the test context which provides
		///information about and functionality for the current test run.
		///</summary>
		public TestContext TestContext
		{
			get
			{
				return testContextInstance;
			}
			set
			{
				testContextInstance = value;
			}
		}

		/// <summary>
		///Initialize() is called once during test execution before
		///test methods in this test class are executed.
		///</summary>
		[TestInitialize()]
		public void Initialize()
		{
			tblTest = new DataTable();
			DataColumn cID = tblTest.Columns.Add("ID", typeof(int));
			DataColumn cStr = tblTest.Columns.Add("str", typeof(string));
			DataColumn cDate = tblTest.Columns.Add("date", typeof(DateTime));
			DataColumn cFloat = tblTest.Columns.Add("float", typeof(float));

			const int cIDv = 3;
			const string cStrv = "hello";
			DateTime cDatev = DateTime.Now;
			const float cFloatv = 3.553F;
			object[] values = { cIDv, cStrv, cDatev, cFloatv };
			tblTest.Rows.Add(values);
		}

		/// <summary>
		///Cleanup() is called once during test execution after
		///test methods in this class have executed unless
		///this test class' Initialize() method throws an exception.
		///</summary>
		[TestCleanup()]
		public void Cleanup()
		{
		}

		DataTable tblTest;

		[TestMethod]
		[ExpectedException(typeof(ArgumentNullException))]
		public void toDdiNull()
		{
			SpssConvert.ToDdi((string)null);
		}

		[Ignore]
		[TestMethod]
		public void testT1()
		{
			SpssConvert.ToDdi(@"C:\Program Files\SPSS\T1.sav");
		}

		[Ignore]
		[TestMethod]
		public void testlistSurveys()
		{
			SpssConvert.ToDdi(@"C:\Program Files\SPSS\listsurveys.sav");
		}

		[Ignore]
		[TestMethod]
		public void smoking()
		{
			SpssConvert.ToDdi(@"C:\Program Files\SPSS\smoking.sav");
		}

		[Ignore]
		[TestMethod]
		public void anorectic()
		{
			SpssConvert.ToDdi(@"C:\Program Files\SPSS\anorectic.sav");
		}

		[TestMethod]
		public void MetaData()
		{
			string SAVfilename;
			using (System.CodeDom.Compiler.TempFileCollection tfc = new System.CodeDom.Compiler.TempFileCollection())
			{
				SAVfilename = tfc.AddExtension("sav", true);
				SpssConvert.ToFile(tblTest, tblTest.Select(), SAVfilename, FillInMetaData);
				Console.WriteLine("The file with metadata is stored at: " + SAVfilename);
			}
		}

		protected void FillInMetaData(SpssVariable var)
		{
			switch (var.Name)
			{
				case "ID":
					var numericVar = (SpssNumericVariable)var;
					var.Label = "Some ID label";
					numericVar.ValueLabels[1] = "one";
					numericVar.ValueLabels[2] = "two";
					numericVar.ValueLabels[3] = "three";
					numericVar.ValueLabels[4] = "four";
					break;
{'fraction_non_alphanumeric': 0.13205435651478817, 'fraction_numerical': 0.006075139888089528, 'mean_word_length': 3.4431818181818183, 'pattern_counts': {'":': 2, '<': 19, '<?xml version=': 0, '>': 19, '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': '1653555', 'n_tokens_mistral': 2447, 'n_tokens_neox': 2066, 'n_words': 497}