<commit_before>﻿using System.IO;
using Fake;
using Machine.Specifications;

namespace Test.FAKECore.NugetFeed
{
    public class when_getting_the_nuget_feed_url
    {
        It should_return_the_package_url = () => NuGetHelper.getRepoUrl().ShouldEqual(NugetData.RepositoryUrl);
    }

    public class when_discorvering_the_lastest_FAKE_package
    {
        static NuGetHelper.NugetFeedPackage _package;
        Because of = () => _package = NuGetHelper.getLatestPackage(NuGetHelper.getRepoUrl(), "FAKE");

        It should_be_the_latest_version = () => _package.IsLatestVersion.ShouldBeTrue();
        It should_contain_steffen_as_author = () => _package.Authors.ShouldContain("<NAME>");
        It should_contain_the_creation_date = () => _package.Created.Year.ShouldBeGreaterThanOrEqualTo(2012);
        It should_contain_the_id = () => _package.Id.ShouldEqual("FAKE");
        It should_contain_the_packet_hash = () => _package.PackageHash.ShouldNotBeNull();
        It should_contain_the_packet_hash_algorithm = () => _package.PackageHashAlgorithm.ShouldEqual("SHA512");
        It should_contain_the_project_url = () => _package.ProjectUrl.ShouldEqual("https://github.com/forki/Fake");
        It should_contain_the_publishing_date = () => _package.Published.Year.ShouldBeGreaterThanOrEqualTo(2012);
        It should_contain_the_title = () => _package.Title.ShouldEqual("FAKE");
        It should_contain_the_version = () => _package.Version.ShouldContain(".");

        It should_containt_the_package_url =
            () => _package.Url.ShouldEqual("http://packages.nuget.org/api/v1/package/FAKE/" + _package.Version);
    }

    public class when_discorvering_a_specific_outdated_FAKE_package
    {
        static NuGetHelper.NugetFeedPackage _package;
        Because of = () => _package = NuGetHelper.getPackage(NuGetHelper.getRepoUrl(), "FAKE", "1.56.10");

        It should_be_the_latest_version = () => _package.IsLatestVersion.ShouldBeFalse();
        It should_contain_the_id = () => _package.Id.ShouldEqual("FAKE");
        It should_contain_the_version = () => _package.Version.ShouldEqual("1.56.10");
    }

    public class when_downloading_the_lastest_FAKE_package
    {
        static NuGetHelper.NugetFeedPackage _package;
        static string _fileName;
        Establish context = () => _package = NuGetHelper.getLatestPackage(NuGetHelper.getRepoUrl(), "FAKE");
        Because of = () => _fileName = NuGetHelper.downloadPackage(NugetData.OutputDir, _package);

        It should_have_downloaded_the_file = () => File.Exists(_fileName).ShouldBeTrue();<commit_msg>Download the latest nuget package - Delete file after download<commit_after>﻿using System.IO;
using Fake;
using Machine.Specifications;

namespace Test.FAKECore.NugetFeed
{
    public class when_getting_the_nuget_feed_url
    {
        It should_return_the_package_url = () => NuGetHelper.getRepoUrl().ShouldEqual(NugetData.RepositoryUrl);
    }

    public class when_discorvering_the_lastest_FAKE_package
    {
        static NuGetHelper.NugetFeedPackage _package;
        Because of = () => _package = NuGetHelper.getLatestPackage(NuGetHelper.getRepoUrl(), "FAKE");

        It should_be_the_latest_version = () => _package.IsLatestVersion.ShouldBeTrue();
        It should_contain_steffen_as_author = () => _package.Authors.ShouldContain("<NAME>");
        It should_contain_the_creation_date = () => _package.Created.Year.ShouldBeGreaterThanOrEqualTo(2012);
        It should_contain_the_id = () => _package.Id.ShouldEqual("FAKE");
        It should_contain_the_packet_hash = () => _package.PackageHash.ShouldNotBeNull();
        It should_contain_the_packet_hash_algorithm = () => _package.PackageHashAlgorithm.ShouldEqual("SHA512");
        It should_contain_the_project_url = () => _package.ProjectUrl.ShouldEqual("https://github.com/forki/Fake");
        It should_contain_the_publishing_date = () => _package.Published.Year.ShouldBeGreaterThanOrEqualTo(2012);
        It should_contain_the_title = () => _package.Title.ShouldEqual("FAKE");
        It should_contain_the_version = () => _package.Version.ShouldContain(".");

        It should_containt_the_package_url =
            () => _package.Url.ShouldEqual("http://packages.nuget.org/api/v1/package/FAKE/" + _package.Version);
    }

    public class when_discorvering_a_specific_outdated_FAKE_package
    {
        static NuGetHelper.NugetFeedPackage _package;
        Because of = () => _package = NuGetHelper.getPackage(NuGetHelper.getRepoUrl(), "FAKE", "1.56.10");

        It should_be_the_latest_version = () => _package.IsLatestVersion.ShouldBeFalse();
        It should_contain_the_id = () => _package.Id.ShouldEqual("FAKE");
        It should_contain_the_version = () => _package.Version.ShouldEqual("1.56.10");
    }

    public class when_downloading_the_lastest_FAKE_package
    {
        static NuGetHelper.NugetFeedPackage _package;
        static string _fileName;
        Establish context = () => _package = NuGetHelper.getLatestPackage(NuGetHelper.getRepoUrl(), "FAKE");
        Because of = () => _fileName = NuGetHelper.downloadPackage(NugetData.OutputDir, _package);

        It should_have_downloaded_the_file = () =>
        {
            File.Exists(_fileName).ShouldBeTrue();
            File.Delete(_fileName);
        };        
{'fraction_non_alphanumeric': 0.11403838916070756, 'fraction_numerical': 0.008280015054572827, 'mean_word_length': 4.0, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 45, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3304870', 'n_tokens_mistral': 1676, 'n_tokens_neox': 1632, 'n_words': 212}