<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Metrics;
using System.Net.NetworkInformation;
using System.Collections;
using System.Net;

namespace Metrics.Tests.MetricsConfigTests
{
    public class HttpEndpointTests
    {

        [Fact]
        public void HttpEndpointCanBeDisposed()
        {
            var config = Metric.Config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/HttpEndpointCanBeDisposed/");
            config.Dispose();
        }

        [Fact]
        public void HttpEndpointDoesNotThrowIfPortIsOccupied()
        {
            using (var listener = new HttpListener())
            {
                listener.Prefixes.Add("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                listener.Start();

                Metric.Config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
            }
        }

        [Fact]
        public void HttpEndportLogsAnErrorIfPortIsOccupied()
        {
            using (var listener = new HttpListener())
            {
                listener.Prefixes.Add("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                listener.Start();

                var loggedAnError = false;
                var config = Metric.Config;
                config.WithErrorHandler((exception, s) => { loggedAnError = true; }, true);
                config.WithErrorHandler((exception) => { loggedAnError = true; }, true);

                config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                Assert.True(loggedAnError);
            }
        }

        [Fact]
        public void SecondCallToWithHttpEndportDoesNotThrow()
        {
            var config = Metric.Config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/sameendpoint/");
            config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/sameendpoint/");
        }

        [Fact]
        public void HttpEndpointDoesNotThrowOnDispose()
        {
            using (var listener = new HttpListener())
            {
                listener.Prefixes.Add("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                listener.Start();

                var config = Metric.Config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                config.Dispose();
            }
        }

    }
}
<commit_msg>second attempt to run tests on mono<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xunit;
using Metrics;
using System.Net.NetworkInformation;
using System.Collections;
using System.Net;

namespace Metrics.Tests.MetricsConfigTests
{
    public class HttpEndpointTests
    {

        [Fact]
        public void HttpEndpointCanBeDisposed()
        {
            var config = Metric.Config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/HttpEndpointCanBeDisposed/");
            config.Dispose();
        }

        [Fact]
        public void HttpEndpointDoesNotThrowIfPortIsOccupied()
        {
            using (var listener = new HttpListener())
            {
                listener.Prefixes.Add("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                listener.Start();
                
                Metric.Config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                listener.Close();
            }
        }

        [Fact]
        public void HttpEndportLogsAnErrorIfPortIsOccupied()
        {
            using (var listener = new HttpListener())
            {
                listener.Prefixes.Add("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                listener.Start();

                var loggedAnError = false;
                var config = Metric.Config;
                config.WithErrorHandler((exception, s) => { loggedAnError = true; }, true);
                config.WithErrorHandler((exception) => { loggedAnError = true; }, true);

                config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                Assert.True(loggedAnError);
                listener.Close();
            }
        }

        [Fact]
        public void SecondCallToWithHttpEndportDoesNotThrow()
        {
            var config = Metric.Config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/sameendpoint/");
            config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/sameendpoint/");
        }

        [Fact]
        public void HttpEndpointDoesNotThrowOnDispose()
        {
            using (var listener = new HttpListener())
            {
                listener.Prefixes.Add("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                listener.Start();

                var config = Metric.Config.WithHttpEndpoint("http://localhost/metricstest/HttpListenerTests/OccupiedPort/");
                config.Dispose();
                listener.Close();
            }
        }

    }
}

{'fraction_non_alphanumeric': 0.10289634146341463, 'fraction_numerical': 0.0, 'mean_word_length': 2.1225461035098157, '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': '2139199', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1310, 'n_words': 201}