<commit_before>﻿namespace Ocelot.UnitTests.Consul
{
    using global::Consul;
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.AspNetCore.Http;
    using Moq;
    using Newtonsoft.Json;
    using Ocelot.Logging;
    using Provider.Consul;
    using Shouldly;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using TestStack.BDDfy;
    using Values;
    using Xunit;

    public class ConsulServiceDiscoveryProviderTests : IDisposable
    {
        private IWebHost _fakeConsulBuilder;
        private readonly List<ServiceEntry> _serviceEntries;
        private Consul _provider;
        private readonly string _serviceName;
        private readonly int _port;
        private readonly string _consulHost;
        private readonly string _consulScheme;
        private readonly string _fakeConsulServiceDiscoveryUrl;
        private List<Service> _services;
        private readonly Mock<IOcelotLoggerFactory> _factory;
        private readonly Mock<IOcelotLogger> _logger;
        private string _receivedToken;
        private readonly IConsulClientFactory _clientFactory;

        public ConsulServiceDiscoveryProviderTests()
        {
            _serviceName = "test";
            _port = 8500;
            _consulHost = "localhost";
            _consulScheme = "https";
            _fakeConsulServiceDiscoveryUrl = $"http://{_consulHost}:{_port}";
            _serviceEntries = new List<ServiceEntry>();
            _factory = new Mock<IOcelotLoggerFactory>();
            _clientFactory = new ConsulClientFactory();
            _logger = new Mock<IOcelotLogger>();
            _factory.Setup(x => x.CreateLogger<Consul>()).Returns(_logger.Object);
            _factory.Setup(x => x.CreateLogger<PollConsul>()).Returns(_logger.Object);
            var config = new ConsulRegistryConfiguration(_consulScheme, _consulHost, _port, _serviceName, null);
            _provider = new Consul(config, _factory.Object, _clientFactory);
        }

        [Fact]
        public void should_return_service_from_consul()
        {
            var serviceEntryOne = new ServiceEntry()
            {
                Service = new AgentService()
                {
                    Service = _serviceName,
                    Address = "localhost",
                    Port = 50881,<commit_msg>Fix tests that are failing on AppVeyor.<commit_after>﻿namespace Ocelot.UnitTests.Consul
{
    using global::Consul;
    using Microsoft.AspNetCore.Builder;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.AspNetCore.Http;
    using Moq;
    using Newtonsoft.Json;
    using Ocelot.Logging;
    using Provider.Consul;
    using Shouldly;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using TestStack.BDDfy;
    using Values;
    using Xunit;

    public class ConsulServiceDiscoveryProviderTests : IDisposable
    {
        private IWebHost _fakeConsulBuilder;
        private readonly List<ServiceEntry> _serviceEntries;
        private Consul _provider;
        private readonly string _serviceName;
        private readonly int _port;
        private readonly string _consulHost;
        private readonly string _consulScheme;
        private readonly string _fakeConsulServiceDiscoveryUrl;
        private List<Service> _services;
        private readonly Mock<IOcelotLoggerFactory> _factory;
        private readonly Mock<IOcelotLogger> _logger;
        private string _receivedToken;
        private readonly IConsulClientFactory _clientFactory;

        public ConsulServiceDiscoveryProviderTests()
        {
            _serviceName = "test";
            _port = 8500;
            _consulHost = "localhost";
            _consulScheme = "http";
            _fakeConsulServiceDiscoveryUrl = $"{_consulScheme}://{_consulHost}:{_port}";
            _serviceEntries = new List<ServiceEntry>();
            _factory = new Mock<IOcelotLoggerFactory>();
            _clientFactory = new ConsulClientFactory();
            _logger = new Mock<IOcelotLogger>();
            _factory.Setup(x => x.CreateLogger<Consul>()).Returns(_logger.Object);
            _factory.Setup(x => x.CreateLogger<PollConsul>()).Returns(_logger.Object);
            var config = new ConsulRegistryConfiguration(_consulScheme, _consulHost, _port, _serviceName, null);
            _provider = new Consul(config, _factory.Object, _clientFactory);
        }

        [Fact]
        public void should_return_service_from_consul()
        {
            var serviceEntryOne = new ServiceEntry()
            {
                Service = new AgentService()
                {
                    Service = _serviceName,
                    Address = "localhost",
                    Port = 50881,
{'fraction_non_alphanumeric': 0.07569473247615098, 'fraction_numerical': 0.0037328909166321027, 'mean_word_length': 2.4499284692417738, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 25, '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': '7321554', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1240, 'n_words': 293}