using System;
using LeafWeb.Core.Utility;
using NUnit.Framework;

namespace LeafWeb.Core.Tests.Utility
{
	[TestFixture]
	public class StringExtensionsTests
	{
		[Test]
		public void FilterAlphaNumeric_AllGood()
		{
			var str = "thisIsFine123_";
			var result = str.FilterAlphaNumeric();
			Assert.That(result, Is.EqualTo(str));
		}

		[Test]
		public void FilterAlphaNumeric_NotAllowed()
		{
			var str = "notAllowed%";
			var result = str.FilterAlphaNumeric();
			Assert.That(result, Is.EqualTo("notAllowed"));
		}

		[Test]
		public void FilterAlphaNumeric_Space()
		{
			var str = "s p a c e s";
			var result = str.FilterAlphaNumeric();
			Assert.That(result, Is.EqualTo("spaces"));
		}

		[Test]
		public void FilterAlphaNumeric_NewLine()
		{
			var str = "new" + Environment.NewLine + "line";
			var result = str.FilterAlphaNumeric();
			Assert.That(result, Is.EqualTo("newline"));
		}

		[Test]
		public void FilenameFromPath()
		{
			var str = "/full/path/to/file.ext";
			var result = str.FilenameFromPath();
			Assert.That(result, Is.EqualTo("file.ext"));
		}
	}
}
