<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NUnit.Framework;
using SquishIt.Framework.Resolvers;

namespace SquishIt.Tests
{
    [TestFixture]
    public class FileSystemResolverTests
    {
        [Test, Platform(Exclude = "Unix, Linux, Mono")]
        public void CanResolveFile()
        {
            //dealing with working directory on a non-C location
            var currentDirectory = Environment.CurrentDirectory;
            var driveLetter = currentDirectory.Substring(0, currentDirectory.IndexOf("\\"));//ignoring UNC paths

            //resharper doesn't support the TestCase attribute
            var values = new Dictionary<string, string>
                             {
                                 {@"C:\testfile.js", @"C:\testfile.js"},
                                 {@"C:\test\testfile.js", @"C:\test\testfile.js"},
                                 {@"D:\testfile.js", @"D:\testfile.js"},
                                 {@"\testfile.js", driveLetter + @"\testfile.js"},
                                 {@"\test\testfile.js", driveLetter + @"\test\testfile.js"},
                                 {@"\test\test3\testfile.js", driveLetter + @"\test\test3\testfile.js"},
                                 {@"testfile.js", Environment.CurrentDirectory + @"\testfile.js"},
                                 {@"..\testfile.js", Path.GetFullPath(Environment.CurrentDirectory + @"\..\testfile.js")},
                                 {@"..\..\testfile.js", Path.GetFullPath(Environment.CurrentDirectory + @"\..\..\testfile.js")}
                             };

            var fileResolver = new FileSystemResolver();
            foreach (string key in values.Keys)
            {
                var resolvedFile = fileResolver.TryResolve(key).ToList();
                Assert.AreEqual(values[key], resolvedFile[0], key);
            }
        }

        [Test, Platform(Include = "Unix, Linux, Mono")]
        public void CanResolveFile_Unix()
        {
            var currentDirectory = Environment.CurrentDirectory;

            var values = new Dictionary<string, string>
                             {
                                 {@"testfile.js", Path.Combine(currentDirectory, "testfile.js")},
                                 {@"/testfile.js", @"/testfile.js"},
								 {@"../testfile.js", Path.Combine(currentDirectory.Substring(0, currentDirectory.LastIndexOf("/")), "testfile.js")}
                             };

            var fileResolver = new FileSystemResolver();
            foreach (string key in values.Keys)
            {
                var resolvedFile = fileResolver.TryResolve(key).ToList();
                Assert.AreEqual(values[key], resolvedFile[0], key);
            }
        }
    }
}<commit_msg>Adding a test to confirm FileSystemResolver's ability to resolve directory<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using NUnit.Framework;
using SquishIt.Framework.Resolvers;

namespace SquishIt.Tests
{
    [TestFixture]
    public class FileSystemResolverTests
    {
        [Test, Platform(Exclude = "Unix, Linux, Mono")]
        public void CanResolveFile()
        {
            //dealing with working directory on a non-C location
            var currentDirectory = Environment.CurrentDirectory;
            var driveLetter = currentDirectory.Substring(0, currentDirectory.IndexOf("\\"));//ignoring UNC paths

            //resharper doesn't support the TestCase attribute
            var values = new Dictionary<string, string>
                             {
                                 {@"C:\testfile.js", @"C:\testfile.js"},
                                 {@"C:\test\testfile.js", @"C:\test\testfile.js"},
                                 {@"D:\testfile.js", @"D:\testfile.js"},
                                 {@"\testfile.js", driveLetter + @"\testfile.js"},
                                 {@"\test\testfile.js", driveLetter + @"\test\testfile.js"},
                                 {@"\test\test3\testfile.js", driveLetter + @"\test\test3\testfile.js"},
                                 {@"testfile.js", Environment.CurrentDirectory + @"\testfile.js"},
                                 {@"..\testfile.js", Path.GetFullPath(Environment.CurrentDirectory + @"\..\testfile.js")},
                                 {@"..\..\testfile.js", Path.GetFullPath(Environment.CurrentDirectory + @"\..\..\testfile.js")}
                             };

            var fileResolver = new FileSystemResolver();
            foreach (string key in values.Keys)
            {
                var resolvedFile = fileResolver.TryResolve(key).ToList();
                Assert.AreEqual(values[key], resolvedFile[0], key);
            }
        }

        [Test, Platform(Include = "Unix, Linux, Mono")]
        public void CanResolveFile_Unix()
        {
            var currentDirectory = Environment.CurrentDirectory;

            var values = new Dictionary<string, string>
                             {
                                 {@"testfile.js", Path.Combine(currentDirectory, "testfile.js")},
                                 {@"/testfile.js", @"/testfile.js"},
								 {@"../testfile.js", Path.Combine(currentDirectory.Substring(0, currentDirectory.LastIndexOf("/")), "testfile.js")}
                             };

            var fileResolver = new FileSystemResolver();
            foreach (string key in values.Keys)
            {
                var resolvedFile = fileResolver.TryResolve(key).ToList();
                Assert.AreEqual(values[key], resolvedFile[0], key);
            }
        }

		[Test]
		public void CanResolveDirectory()
		{
			string path = Guid.NewGuid().ToString();
			var directory = Directory.CreateDirectory(path);
			File.Create(Path.Combine(directory.FullName, "file1")).Close();
			File.Create(Path.Combine(directory.FullName, "file2")).Close();

			var result = new FileSystemResolver().TryResolve(path).ToList();
			Assert.AreEqual (2, result.Count);
			Assert.Contains (path + Path.DirectorySeparatorChar + "file1", result);
			Assert.Contains (path + Path.DirectorySeparatorChar + "file2", result);
			
			Directory.Delete(path, true);
		}
    }
}
{'fraction_non_alphanumeric': 0.13279132791327913, 'fraction_numerical': 0.0027100271002710027, 'mean_word_length': 1.7313887679582063, 'pattern_counts': {'":': 0, '<': 7, '<?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': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5988727', 'n_tokens_mistral': 1679, 'n_tokens_neox': 1594, 'n_words': 308}