<commit_before>﻿/*----------------------------------------------------------
This Source Code Form is subject to the terms of the 
Mozilla Public License, v.2.0. If a copy of the MPL 
was not distributed with this file, You can obtain one 
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/

using System;
using System.IO;

using NUnit.Framework;
using ScriptEngine.Machine;

namespace NUnitTests
{
	[TestFixture]
	public class UnitTestWrapper
	{
		private const int TEST_STATE_FAILED = 3;

		private EngineWrapperNUnit host;

		private string solutionRoot;

		[OneTimeSetUp]
		public void Initialize()
		{
			host = new EngineWrapperNUnit();
			host.StartEngine();
			solutionRoot = Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "..", "..");
			host.Engine.InitExternalLibraries(Path.Combine(solutionRoot, "oscript-library", "src"), null);
		}

		private void RunSpecificTest(string testName)
		{
			var testRunnerPath = Path.Combine(solutionRoot, "tests", "testrunner.os");

			Assert.IsTrue(File.Exists(testRunnerPath),
				"Запускатель тестов отсутствует по пути " + testRunnerPath);

			var specificTestPath = Path.Combine(solutionRoot, "tests", testName);
			var result = host.RunTestScriptFromPath(testRunnerPath, $"-run {specificTestPath}");

			if (result == TEST_STATE_FAILED)
			{
				Assert.Fail("Есть непройденные тесты!");
			}
		}

		[Test]
		public void Test_Reflector()
		{
			RunSpecificTest(@"reflector.os");
		}

		[Test]
		[Ignore("Внутри валится очень много тестов, надо чинить механизм.")]
		public void RunEngineTests()
		{
			var testRunnerPath = Path.Combine(solutionRoot, "tests", "testrunner.os");

			Assert.IsTrue(File.Exists(testRunnerPath),
						"Запускатель тестов отсутствует по пути " + testRunnerPath);

			var result = host.RunTestScriptFromPath(testRunnerPath, "-runall " + new FileInfo(testRunnerPath).Directory.FullName);

			if (result == TEST_STATE_FAILED)
				Assert.Fail("Есть непройденные тесты!");
		}<commit_msg>Добавил юнит-тест NUnit для проверки zip #627<commit_after>﻿/*----------------------------------------------------------
This Source Code Form is subject to the terms of the 
Mozilla Public License, v.2.0. If a copy of the MPL 
was not distributed with this file, You can obtain one 
at http://mozilla.org/MPL/2.0/.
----------------------------------------------------------*/

using System;
using System.IO;

using NUnit.Framework;
using ScriptEngine.Machine;

namespace NUnitTests
{
	[TestFixture]
	public class UnitTestWrapper
	{
		private const int TEST_STATE_FAILED = 3;

		private EngineWrapperNUnit host;

		private string solutionRoot;

		[OneTimeSetUp]
		public void Initialize()
		{
			host = new EngineWrapperNUnit();
			host.StartEngine();
			solutionRoot = Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "..", "..", "..");
			host.Engine.InitExternalLibraries(Path.Combine(solutionRoot, "oscript-library", "src"), null);
		}

		private void RunSpecificTest(string testName)
		{
			var testRunnerPath = Path.Combine(solutionRoot, "tests", "testrunner.os");

			Assert.IsTrue(File.Exists(testRunnerPath),
				"Запускатель тестов отсутствует по пути " + testRunnerPath);

			var specificTestPath = Path.Combine(solutionRoot, "tests", testName);
			var result = host.RunTestScriptFromPath(testRunnerPath, $"-run {specificTestPath}");

			if (result == TEST_STATE_FAILED)
			{
				Assert.Fail("Есть непройденные тесты!");
			}
		}

		[Test]
		public void Test_Reflector()
		{
			RunSpecificTest(@"reflector.os");
        }
        [Test]
        public void Test_Zip()
        {
            RunSpecificTest(@"zip.os");
        }

		[Test]
		[Ignore("Внутри валится очень много тестов, надо чинить механизм.")]
		public void RunEngineTests()
		{
			var testRunnerPath = Path.Combine(solutionRoot, "tests", "testrunner.os");

			Assert.IsTrue(File.Exists(testRunnerPath),
						"Запускатель тестов отсутствует по пути " + testRunnerPath);

			var result = host.RunTestScriptFromPath(testRunnerPath, "-runall " + new FileInfo(testRunnerPath).Directory.FullName);

			if (result == TEST_STATE_FAILED)
				Assert.Fail("Есть непройденные тесты!");
		}
{'fraction_non_alphanumeric': 0.16873508353221958, 'fraction_numerical': 0.0031026252983293555, 'mean_word_length': 3.1660039761431413, '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': '4604499', 'n_tokens_mistral': 1469, 'n_tokens_neox': 1330, 'n_words': 303}