<commit_before>﻿//#define MOCK_SENDER

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using CoreTest.Utils.MessageSender;
using Gateway;
using Gateway.DataIntake;
using Gateway.Models;
using Gateway.Utils.Loader;
using Gateway.Utils.MessageSender;
using Gateway.Utils.Queue;
using CoreTest.Utils.Logger;
using CoreTest.Utils.Loader;
using SharedInterfaces;
using System.Text;

namespace CoreTest
{
    public class CoreTest : ITest
    {
        public const int TEST_ITERATIONS = 5;
        public const int MAX_TEST_MESSAGES = 1000;

        private readonly ILogger _testLogger = new TestLogger();
        private readonly AutoResetEvent _completed = new AutoResetEvent(false);
        private readonly GatewayQueue<QueuedItem> _GatewayQueue;
        private readonly IMessageSender<SensorDataContract> _Sender;
        private readonly BatchSenderThread<QueuedItem, SensorDataContract> _BatchSenderThread;
        private readonly Random _rand;
        private int _totalMessagesSent;
        private int _totalMessagesToSend;

        private const int STOP_TIMEOUT_MS = 5000; // ms

        public CoreTest()
        {
            _rand = new Random( );
            _totalMessagesSent = 0;
            _totalMessagesToSend = 0;
            _GatewayQueue = new GatewayQueue<QueuedItem>( );
#if MOCK_SENDER
            _Sender = new MockSender<SensorDataContract>(this);
#else

            AMQPConfig amqpConfig = Loader.GetAMQPConfig( );
                
            _Sender = new AMQPSender<SensorDataContract>(
                                                amqpConfig.AMQPSAddress,
                                                amqpConfig.EventHubName,
                                                amqpConfig.EventHubMessageSubject,
                                                amqpConfig.EventHubDeviceId,
                                                amqpConfig.EventHubDeviceDisplayName,
                                                new TestLogger()
                                                );
#endif<commit_msg>Change logger used for actual amqp testing.<commit_after>﻿//#define MOCK_SENDER

using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using CoreTest.Utils.MessageSender;
using Gateway;
using Gateway.DataIntake;
using Gateway.Models;
using Gateway.Utils.Loader;
using Gateway.Utils.MessageSender;
using Gateway.Utils.Queue;
using CoreTest.Utils.Logger;
using CoreTest.Utils.Loader;
using SharedInterfaces;
using System.Text;

namespace CoreTest
{
    public class CoreTest : ITest
    {
        public const int TEST_ITERATIONS = 5;
        public const int MAX_TEST_MESSAGES = 1000;

        private readonly ILogger _testLogger = new TestLogger();
        private readonly AutoResetEvent _completed = new AutoResetEvent(false);
        private readonly GatewayQueue<QueuedItem> _GatewayQueue;
        private readonly IMessageSender<SensorDataContract> _Sender;
        private readonly BatchSenderThread<QueuedItem, SensorDataContract> _BatchSenderThread;
        private readonly Random _rand;
        private int _totalMessagesSent;
        private int _totalMessagesToSend;

        private const int STOP_TIMEOUT_MS = 5000; // ms

        public CoreTest()
        {
            _rand = new Random( );
            _totalMessagesSent = 0;
            _totalMessagesToSend = 0;
            _GatewayQueue = new GatewayQueue<QueuedItem>( );
#if MOCK_SENDER
            _Sender = new MockSender<SensorDataContract>(this);
#else

            AMQPConfig amqpConfig = Loader.GetAMQPConfig( );
                
            _Sender = new AMQPSender<SensorDataContract>(
                                                amqpConfig.AMQPSAddress,
                                                amqpConfig.EventHubName,
                                                amqpConfig.EventHubMessageSubject,
                                                amqpConfig.EventHubDeviceId,
                                                amqpConfig.EventHubDeviceDisplayName,
                                                _testLogger
                                                );
#endif
{'fraction_non_alphanumeric': 0.05824561403508772, 'fraction_numerical': 0.005146198830409357, 'mean_word_length': 1.9187713310580206, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 28, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4765271', 'n_tokens_mistral': 1025, 'n_tokens_neox': 986, 'n_words': 250}