<commit_before>﻿using NUnit.Framework;
using NuKeeper.RepositoryInspection;

namespace NuKeeper.Tests.RepositoryInspection
{
    [TestFixture]
    public class PackagePathTests
    {
        [Test]
        public void ConstructorShouldProduceExpectedSimplePropsForProjectFile()
        {
            var path = new PackagePath("c:\\temp\\somefolder", "\\checkout1\\src\\myproj.csproj", 
                PackageReferenceType.ProjectFile);

            Assert.That(path.BaseDirectory, Is.EqualTo("c:\\temp\\somefolder"));
            Assert.That(path.RelativePath, Is.EqualTo("checkout1\\src\\myproj.csproj"));
            Assert.That(path.PackageReferenceType, Is.EqualTo(PackageReferenceType.ProjectFile));
        }

        [Test]
        public void ConstructorShouldProduceExpectedSimplePropsForPackagesConfigFile()
        {
            var path = new PackagePath("c:\\temp\\somefolder", "\\checkout1\\src\\packages.config",
                PackageReferenceType.PackagesConfig);

            Assert.That(path.BaseDirectory, Is.EqualTo("c:\\temp\\somefolder"));
            Assert.That(path.RelativePath, Is.EqualTo("checkout1\\src\\packages.config"));
            Assert.That(path.PackageReferenceType, Is.EqualTo(PackageReferenceType.PackagesConfig));
        }

        [Test]
        public void ConstructorShouldProduceExpectedCalculatedProps()
        {
            var path = new PackagePath("c:\\temp\\somefolder", "checkout1\\src\\myproj.csproj",
                PackageReferenceType.ProjectFile);


            Assert.That(path.FullDirectory, Is.EqualTo("c:\\temp\\somefolder\\checkout1\\src"));
            Assert.That(path.FullPath, Is.EqualTo("c:\\temp\\somefolder\\checkout1\\src\\myproj.csproj"));
            Assert.That(path.FileName, Is.EqualTo("myproj.csproj"));
        }

        [Test]
        public void ConstructorShouldProduceExpectedCalculatedPropsWithExtraSlash()
        {
            var path = new PackagePath("c:\\temp\\somefolder", "\\checkout1\\src\\myproj.csproj",
                PackageReferenceType.ProjectFile);


            Assert.That(path.BaseDirectory, Is.EqualTo("c:\\temp\\somefolder"));
            Assert.That(path.RelativePath, Is.EqualTo("checkout1\\src\\myproj.csproj"));
            Assert.That(path.FullDirectory, Is.EqualTo("c:\\temp\\somefolder\\checkout1\\src"));
            Assert.That(path.FullPath, Is.EqualTo("c:\\temp\\somefolder\\checkout1\\src\\myproj.csproj"));<commit_msg>Cross-platform dir tests Works on windows lets see about Linux<commit_after>﻿using System.IO;
using NUnit.Framework;
using NuKeeper.RepositoryInspection;

namespace NuKeeper.Tests.RepositoryInspection
{
    [TestFixture]
    public class PackagePathTests
    {
        [Test]
        public void ConstructorShouldProduceExpectedSimplePropsForProjectFile()
        {
            var sep = Path.DirectorySeparatorChar;

            var path = new PackagePath(
                $"c:{sep}temp{sep}somefolder", 
                $"{sep}checkout1{sep}src{sep}myproj.csproj", 
                PackageReferenceType.ProjectFile);

            Assert.That(path.BaseDirectory, Is.EqualTo($"c:{sep}temp{sep}somefolder"));
            Assert.That(path.RelativePath, Is.EqualTo($"checkout1{sep}src{sep}myproj.csproj"));
            Assert.That(path.PackageReferenceType, Is.EqualTo(PackageReferenceType.ProjectFile));
        }

        [Test]
        public void ConstructorShouldProduceExpectedSimplePropsForPackagesConfigFile()
        {
            var sep = Path.DirectorySeparatorChar;
            var path = new PackagePath(
                $"c:{sep}temp{sep}somefolder", 
                $"{sep}checkout1{sep}src{sep}packages.config",
                PackageReferenceType.PackagesConfig);

            Assert.That(path.BaseDirectory, Is.EqualTo($"c:{sep}temp{sep}somefolder"));
            Assert.That(path.RelativePath, Is.EqualTo($"checkout1{sep}src{sep}packages.config"));
            Assert.That(path.PackageReferenceType, Is.EqualTo(PackageReferenceType.PackagesConfig));
        }

        [Test]
        public void ConstructorShouldProduceExpectedCalculatedProps()
        {
            var sep = Path.DirectorySeparatorChar;
            var path = new PackagePath(
                $"c:{sep}temp{sep}somefolder", 
                $"checkout1{sep}src{sep}myproj.csproj",
                PackageReferenceType.ProjectFile);


            Assert.That(path.FullDirectory, Is.EqualTo($"c:{sep}temp{sep}somefolder{sep}checkout1{sep}src"));
            Assert.That(path.FullPath, Is.EqualTo($"c{sep}temp{sep}somefolder{sep}checkout1{sep}src{sep}myproj.csproj"));
            Assert.That(path.FileName, Is.EqualTo("myproj.csproj"));
        }

        [Test]
        public void ConstructorShouldProduceExpectedCalculatedPropsWithExtraSlash()
        {
            var sep = Path.DirectorySeparatorChar;
            var path = new PackagePath(
                $"c:{sep}temp{sep}somefolder", 
                $"{sep}checkout1{sep}src{sep}myproj.csproj",
                PackageReferenceType.ProjectFile);


            Assert.That(path.BaseDirectory, Is.EqualTo($"c:{sep}temp{sep}somefolder"));
            Assert.That(path.RelativePath, Is.EqualTo($"checkout1{sep}src{sep}myproj.csproj"));
            Assert.That(path.FullDirectory, Is.EqualTo($"c:{sep}temp{sep}somefolder{sep}checkout1{sep}src"));
            Assert.That(path.FullPath, Is.EqualTo($"c:{sep}temp{sep}somefolder{sep}checkout1{sep}src{sep}myproj.csproj"));
{'fraction_non_alphanumeric': 0.1308890925756187, 'fraction_numerical': 0.004032997250229147, 'mean_word_length': 2.807397069085834, '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': '6716366', 'n_tokens_mistral': 1600, 'n_tokens_neox': 1553, 'n_words': 178}