<commit_before>﻿// Copyright (c) 2015 SIL International
// This software is licensed under the MIT license (http://opensource.org/licenses/MIT)
using System;
using NUnit.Framework;
using LfMerge.Actions;
using System.IO;

namespace LfMerge.Tests.Actions
{
	[TestFixture]
	public class ReceiveActionTests
	{
		private TestEnvironment _env;

		[SetUp]
		public void Setup()
		{
			_env = new TestEnvironment();
		}

		[TearDown]
		public void TearDown()
		{
			_env.Dispose();
		}

		[Test]
		public void DoRun_ProjectDoesntExistSetsStateOnHold()
		{
			// Setup
			var nonExistingProject = Path.GetRandomFileName();

			// for this test we don't want the test double for InternetCloneSettingsModel
			_env.Dispose();
			_env = new TestEnvironment(false);

			var lfProj = LanguageForgeProject.Create(_env.Settings, nonExistingProject);
			var sut = LfMerge.Actions.Action.GetAction(ActionNames.Receive);

			// Execute/Verify
			Assert.That(() => sut.Run(lfProj), Throws.InstanceOf<UnauthorizedAccessException>());

			// Verify
			Assert.That(lfProj.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.HOLD));
		}

		[Test]
		public void DoRun_DirDoesntExistClonesProject()
		{
			// Setup
			var projCode = TestContext.CurrentContext.Test.Name;
			var lfProj = LanguageForgeProject.Create(_env.Settings, projCode);
			var sut = LfMerge.Actions.Action.GetAction(ActionNames.Receive);

			// Execute
			sut.Run(lfProj);

			// Verify
			var projDir = Path.Combine(_env.Settings.WebWorkDirectory, projCode);
			Assert.That(Directory.Exists(projDir), Is.True,
				"Didn't create webwork directory");
			Assert.That(Directory.Exists(Path.Combine(projDir, ".hg")), Is.True,
				"Didn't clone project");
		}

		[Test]
		public void DoRun_HgDoesntExistClonesProject()
		{
			// Setup
			var projCode = TestContext.CurrentContext.Test.Name;
			var projDir = Path.Combine(_env.Settings.WebWorkDirectory, projCode);
			Directory.CreateDirectory(projDir);
			var lfProj = LanguageForgeProject.Create(_env.Settings, projCode);
			var sut = LfMerge.Actions.Action.GetAction(ActionNames.Receive);

			// Execute
			sut.Run(lfProj);

			// Verify
			Assert.That(Directory.Exists(Path.Combine(projDir, ".hg")), Is.True,
				"Didn't clone project");
		}

	}
}
<commit_msg>Fix two failing tests<commit_after>﻿// Copyright (c) 2015 SIL International
// This software is licensed under the MIT license (http://opensource.org/licenses/MIT)
using System;
using NUnit.Framework;
using LfMerge.Actions;
using System.IO;

namespace LfMerge.Tests.Actions
{
	[TestFixture]
	public class ReceiveActionTests
	{
		private TestEnvironment _env;

		[SetUp]
		public void Setup()
		{
			_env = new TestEnvironment();
		}

		[TearDown]
		public void TearDown()
		{
			_env.Dispose();
		}

		[Test]
		public void DoRun_ProjectDoesntExistSetsStateOnHold()
		{
			// Setup
			var nonExistingProject = Path.GetRandomFileName();

			// for this test we don't want the test double for InternetCloneSettingsModel
			_env.Dispose();
			_env = new TestEnvironment(false);

			var lfProj = LanguageForgeProject.Create(_env.Settings, nonExistingProject);
			var sut = LfMerge.Actions.Action.GetAction(ActionNames.Receive);

			// Execute/Verify
			Assert.That(() => sut.Run(lfProj), Throws.InstanceOf<UnauthorizedAccessException>());

			// Verify
			Assert.That(lfProj.State.SRState, Is.EqualTo(ProcessingState.SendReceiveStates.HOLD));
		}

		[Test]
		public void DoRun_DirDoesntExistClonesProject()
		{
			// Setup
			var projCode = TestContext.CurrentContext.Test.Name;
			var lfProj = LanguageForgeProject.Create(_env.Settings, projCode);
			var sut = LfMerge.Actions.Action.GetAction(ActionNames.Receive);

			// Execute
			sut.Run(lfProj);

			// Verify
			var projDir = Path.Combine(_env.Settings.WebWorkDirectory, projCode.ToLowerInvariant());
			Assert.That(Directory.Exists(projDir), Is.True,
				"Didn't create webwork directory");
			Assert.That(Directory.Exists(Path.Combine(projDir, ".hg")), Is.True,
				"Didn't clone project");
		}

		[Test]
		public void DoRun_HgDoesntExistClonesProject()
		{
			// Setup
			var projCode = TestContext.CurrentContext.Test.Name;
			var projDir = Path.Combine(_env.Settings.WebWorkDirectory, projCode.ToLowerInvariant());
			Directory.CreateDirectory(projDir);
			var lfProj = LanguageForgeProject.Create(_env.Settings, projCode);
			var sut = LfMerge.Actions.Action.GetAction(ActionNames.Receive);

			// Execute
			sut.Run(lfProj);

			// Verify
			Assert.That(Directory.Exists(Path.Combine(projDir, ".hg")), Is.True,
				"Didn't clone project");
		}

	}
}

{'fraction_non_alphanumeric': 0.12029746281714786, 'fraction_numerical': 0.0017497812773403325, 'mean_word_length': 4.069844789356985, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '4324975', 'n_tokens_mistral': 1770, 'n_tokens_neox': 1499, 'n_words': 291}