<commit_before>using System;
using NUnit.Framework;
using Subtext.Framework;
using Subtext.Framework.Configuration;
using Subtext.Framework.Exceptions;

namespace UnitTests.Subtext.Installation
{
	/// <summary>
	/// Tests of the InstallationManager class.
	/// </summary>
	[TestFixture]
	public class InstallationManagerTests
	{
		/// <summary>
		/// Makes sure that a <see cref="BlogDoesNotExistException"/> indicates that 
		/// an installation action is required.
		/// </summary>
		[Test]
		[Rollback]
		public void IsInstallationActionRequiredReturnsTrueForBlogDoesNotExistException()
		{
			Assert.IsTrue(InstallationManager.GetIsInstallationActionRequired(new BlogDoesNotExistException("host", "app", false), VersionInfo.FrameworkVersion));
		}

		/// <summary>
		/// Determines whether [is in install directory reports correct result].
		/// </summary>
		[Test]
		[Rollback]
		public void IsInInstallDirectoryReportsTrueCorrectly()
		{
			AssertIsInInstallDirectory(System.Guid.NewGuid().ToString().Replace("-", ""), "VirtDir");
			AssertIsInInstallDirectory(System.Guid.NewGuid().ToString().Replace("-", ""), "");
			AssertIsInInstallDirectory("", "");
		}

		/// <summary>
		/// Determines whether [is in install directory reports correct result].
		/// </summary>
		[Test]
		[Rollback]
		public void IsInInstallDirectoryReportsFalseCorrectly()
		{
			AssertNotInInstallDirectory(System.Guid.NewGuid().ToString().Replace("-", ""), "");
			AssertNotInInstallDirectory(System.Guid.NewGuid().ToString().Replace("-", ""), "VirtDir");
			AssertNotInInstallDirectory("", "");
		}

		void AssertIsInInstallDirectory(string virtualDirectory, string blogName)
		{
			string host = System.Guid.NewGuid().ToString().Replace("-", "");
			Config.CreateBlog("Title", "username", "<PASSWORD>", host, blogName);

			UnitTestHelper.SetHttpContextWithBlogRequest(host, blogName, virtualDirectory, "Install/InstallationComplete.aspx");
			Assert.IsTrue(InstallationManager.IsInInstallDirectory, "This request should be within the installation directory.");	
		}

		void AssertNotInInstallDirectory(string virtualDirectory, string blogName)<commit_msg>Loosened up some URL checking methods. Need to tighten later.<commit_after>using System;
using NUnit.Framework;
using Subtext.Framework;
using Subtext.Framework.Configuration;
using Subtext.Framework.Exceptions;

namespace UnitTests.Subtext.Installation
{
	/// <summary>
	/// Tests of the InstallationManager class.
	/// </summary>
	[TestFixture]
	public class InstallationManagerTests
	{
		/// <summary>
		/// Determines whether [is in host admin directory returns true result].
		/// </summary>
		[Test]
		[Rollback]
		public void IsInHostAdminDirectoryReturnsTrueResult()
		{
			string host = System.Guid.NewGuid().ToString().Replace("-", "");
			UnitTestHelper.SetHttpContextWithBlogRequest(host, "", "Subtext.Web", "HostAdmin/Import/BlahBlah.aspx");
			Assert.IsTrue(InstallationManager.IsInHostAdminDirectory, "This request should be within the hostadmin/import directory.");	
		}

		/// <summary>
		/// Makes sure that a <see cref="BlogDoesNotExistException"/> indicates that 
		/// an installation action is required.
		/// </summary>
		[Test]
		[Rollback]
		public void IsInstallationActionRequiredReturnsTrueForBlogDoesNotExistException()
		{
			Assert.IsTrue(InstallationManager.GetIsInstallationActionRequired(new BlogDoesNotExistException("host", "app", false), VersionInfo.FrameworkVersion));
		}

		/// <summary>
		/// Determines whether [is in install directory reports correct result].
		/// </summary>
		[Test]
		[Rollback]
		public void IsInInstallDirectoryReportsTrueCorrectly()
		{
			AssertIsInInstallDirectory("VirtDir", System.Guid.NewGuid().ToString().Replace("-", ""));
			AssertIsInInstallDirectory("", System.Guid.NewGuid().ToString().Replace("-", ""));
			AssertIsInInstallDirectory("", "");
		}

		/// <summary>
		/// Determines whether [is in install directory reports correct result].
		/// </summary>
		[Test]
		[Rollback]
		public void IsInInstallDirectoryReportsFalseCorrectly()
		{
			AssertNotInInstallDirectory(System.Guid.NewGuid().ToString().Replace("-", ""), "");
			AssertNotInInstallDirectory(System.Guid.NewGuid().ToString().Replace("-", ""), "VirtDir");
			AssertNotInInstallDirectory("", "");
		}

		void AssertIsInInstallDirectory(string virtualDirectory, string blogName)
		{
			string host = System.Guid.NewGuid().ToString().Replace("-", "");
			Config.CreateBlog("Title", "username", "<PASSWORD>", host, blogName);
			UnitTestHelper.SetHttpContextWithBlogRequest(host, blogName, virtualDirectory, "Install/InstallationComplete.aspx");
			Assert.IsTrue(InstallationManager.IsInInstallDirectory, "This request should be within the installation directory.");	
		}

		void AssertNotInInstallDirectory(string virtualDirectory, string blogName)
{'fraction_non_alphanumeric': 0.1391304347826087, 'fraction_numerical': 0.0, 'mean_word_length': 5.061480552070264, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, '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': '7063808', 'n_tokens_mistral': 1478, 'n_tokens_neox': 1346, 'n_words': 279}