<commit_before>﻿using System.IO;
using Nancy;
using Nancy.Testing;
using Nancy.ViewEngines.Veil.SuperSimple;
using NUnit.Framework;

namespace Veil.NancyViewEngines
{
    [TestFixture]
    public class SuperSimple
    {
        [Test]
        public void Should_render_super_simple_template()
        {
            var browser = new Browser(new ConfigurableBootstrapper(with =>
            {
                with.Module(new TestingModule());
                with.RootPathProvider(new TestingRootPathProvider());
                with.ViewEngine(new VeilSuperSimpleViewEngine());
            }));
            var response = browser.Get("/");

            response.Body["h1"].ShouldExistOnce().And.ShouldContain("Hello Joe");
            response.Body["header"].ShouldExistOnce();
        }

        private class IndexViewModel
        {
            public string Name { get; set; }
        }

        private class TestingModule : NancyModule
        {
            public TestingModule()
            {
                Get["/"] = _ =>
                {
                    return View["Index", new IndexViewModel { Name = "Joe" }];
                };
            }
        }

        private class TestingRootPathProvider : IRootPathProvider
        {
            private static readonly string RootPath;

            static TestingRootPathProvider()
            {
                var directoryName = Path.GetDirectoryName(typeof(SuperSimple).Assembly.CodeBase);

                if (directoryName != null)
                {
                    var assemblyPath = directoryName.Replace(@"file:\", string.Empty);

                    RootPath = Path.GetFullPath(Path.Combine(assemblyPath, "..", "..", "NancyViewEngines"));
                }
            }

            public string GetRootPath()
            {
                return RootPath;
            }
        }
    }
}<commit_msg>Less complex path finder for nancy view engines tests.<commit_after>﻿using System;
using System.IO;
using Nancy;
using Nancy.Testing;
using Nancy.ViewEngines.Veil.SuperSimple;
using NUnit.Framework;

namespace Veil.NancyViewEngines
{
    [TestFixture]
    public class SuperSimple
    {
        [Test]
        public void Should_render_super_simple_template()
        {
            var browser = new Browser(new ConfigurableBootstrapper(with =>
            {
                with.Module(new TestingModule());
                with.RootPathProvider(new TestingRootPathProvider());
                with.ViewEngine(new VeilSuperSimpleViewEngine());
            }));
            var response = browser.Get("/");

            response.Body["h1"].ShouldExistOnce().And.ShouldContain("Hello Joe");
            response.Body["header"].ShouldExistOnce();
        }

        private class IndexViewModel
        {
            public string Name { get; set; }
        }

        private class TestingModule : NancyModule
        {
            public TestingModule()
            {
                Get["/"] = _ =>
                {
                    return View["Index", new IndexViewModel { Name = "Joe" }];
                };
            }
        }

        private class TestingRootPathProvider : IRootPathProvider
        {
            public string GetRootPath()
            {
                return Path.Combine(Environment.CurrentDirectory, "..", "..", "NancyViewEngines");
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.09869976359338062, 'fraction_numerical': 0.000591016548463357, 'mean_word_length': 1.6424668227946917, 'pattern_counts': {'":': 0, '<': 3, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3622663', 'n_tokens_mistral': 869, 'n_tokens_neox': 808, 'n_words': 165}