<commit_before>﻿using kafka_tests.Fakes;
using kafka_tests.Helpers;
using KafkaNet;
using KafkaNet.Common;
using KafkaNet.Model;
using KafkaNet.Protocol;
using NSubstitute;
using NUnit.Framework;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace kafka_tests.Unit
{
    /// <summary>
    /// Note these integration tests require an actively running kafka server defined in the app.config file.
    /// </summary>
    [TestFixture]
    [Category("unit")]
    public class KafkaTcpSocketTests
    {
        private const int FakeServerPort = 8999;
        private readonly KafkaEndpoint _fakeServerUrl;
        private readonly KafkaEndpoint _badServerUrl;
        private IKafkaLog _log = new DefaultTraceLog(LogLevel.Info);
        private int _maxRetry = 5;

        public KafkaTcpSocketTests()
        {
            _fakeServerUrl = new DefaultKafkaConnectionFactory().Resolve(new Uri("http://localhost:8999"), _log);
            _badServerUrl = new DefaultKafkaConnectionFactory().Resolve(new Uri("http://localhost:1"), _log);
        }

        [Test, Repeat(IntegrationConfig.NumberOfRepeat)]
        public void KafkaTcpSocketShouldConstruct()
        {
            using (var test = new KafkaTcpSocket(_log, _fakeServerUrl, 5))
            {
                Assert.That(test, Is.Not.Null);
                Assert.That(test.Endpoint, Is.EqualTo(_fakeServerUrl));
            }
        }

        #region Connection Tests...

        [Test, Repeat(IntegrationConfig.NumberOfRepeat)]
        public async Task ConnectionShouldStartDedicatedThreadOnConstruction()
        {
            var count = 0;

            using (var test = new KafkaTcpSocket(_log, _fakeServerUrl, _maxRetry))<commit_msg>code review comment<commit_after>﻿using kafka_tests.Fakes;
using kafka_tests.Helpers;
using KafkaNet;
using KafkaNet.Common;
using KafkaNet.Model;
using KafkaNet.Protocol;
using NSubstitute;
using NUnit.Framework;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace kafka_tests.Unit
{
    /// <summary>
    /// Note these integration tests require an actively running kafka server defined in the app.config file.
    /// </summary>
    [TestFixture]
    [Category("unit")]
    public class KafkaTcpSocketTests
    {
        private const int FakeServerPort = 8999;
        private readonly KafkaEndpoint _fakeServerUrl;
        private readonly KafkaEndpoint _badServerUrl;
        private IKafkaLog _log = new DefaultTraceLog(LogLevel.Info);
        private int _maxRetry = 5;

        public KafkaTcpSocketTests()
        {
            _fakeServerUrl = new DefaultKafkaConnectionFactory().Resolve(new Uri("http://localhost:8999"), _log);
            _badServerUrl = new DefaultKafkaConnectionFactory().Resolve(new Uri("http://localhost:1"), _log);
        }

        [Test, Repeat(IntegrationConfig.NumberOfRepeat)]
        public void KafkaTcpSocketShouldConstruct()
        {
            using (var test = new KafkaTcpSocket(_log, _fakeServerUrl, _maxRetry))
            {
                Assert.That(test, Is.Not.Null);
                Assert.That(test.Endpoint, Is.EqualTo(_fakeServerUrl));
            }
        }

        #region Connection Tests...

        [Test, Repeat(IntegrationConfig.NumberOfRepeat)]
        public async Task ConnectionShouldStartDedicatedThreadOnConstruction()
        {
            var count = 0;

            using (var test = new KafkaTcpSocket(_log, _fakeServerUrl, _maxRetry))
{'fraction_non_alphanumeric': 0.09004237288135593, 'fraction_numerical': 0.0060911016949152545, 'mean_word_length': 2.9799789251844047, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6976582', 'n_tokens_mistral': 1070, 'n_tokens_neox': 1047, 'n_words': 255}