<commit_before>﻿using System;
using System.Threading;
using RabbitMQ.Client;
using Shouldly;
using Xunit;

namespace RabbitHarness.Tests
{
	public class InMemoryConnectorTests : TestBase
	{
		private InMemoryConnector _connector;
		private AutoResetEvent _reset;
		private readonly ExchangeDefinition _exchangeDefinition;
		private readonly QueueDefinition _queueDefinition;

		public InMemoryConnectorTests()
		{
			_reset = new AutoResetEvent(false);
			_connector = new InMemoryConnector();

			_exchangeDefinition = new ExchangeDefinition(ExchangeName, ExchangeType.Direct)
			{
				AutoDelete = true
			};

			_queueDefinition = new QueueDefinition
			{
				Name = QueueName,
				AutoDelete = true,
				RoutingKeys = new[] { "some.key" }
			};
		}

		[Fact]
		public void When_using_a_routing_key_which_matches_exactly()
		{
			int recieved = 0;

			_connector.ListenTo<int>(
				_exchangeDefinition,
				_queueDefinition,
				(props, json) =>
				{
					recieved = json;
					_reset.Set();
					return true;
				});

			_connector.SendTo(_exchangeDefinition, "some.key", props => { }, 123);
			_reset.WaitOne(TimeSpan.FromSeconds(5));

			recieved.ShouldBe(123);
		}
<commit_msg>inMemoryConnectorTests: dont inherit testbase, no need for rabbitmq connections<commit_after>﻿using System;
using System.Threading;
using RabbitMQ.Client;
using Shouldly;
using Xunit;

namespace RabbitHarness.Tests
{
	public class InMemoryConnectorTests
	{
		private InMemoryConnector _connector;
		private AutoResetEvent _reset;
		private readonly ExchangeDefinition _exchangeDefinition;
		private readonly QueueDefinition _queueDefinition;

		public InMemoryConnectorTests()
		{
			_reset = new AutoResetEvent(false);
			_connector = new InMemoryConnector();

			_exchangeDefinition = new ExchangeDefinition("Exchange" + Guid.NewGuid().ToString(), ExchangeType.Direct)
			{
				AutoDelete = true
			};

			_queueDefinition = new QueueDefinition
			{
				Name = "Queue" + Guid.NewGuid().ToString(),
				AutoDelete = true,
				RoutingKeys = new[] { "some.key" }
			};
		}

		[Fact]
		public void When_using_a_routing_key_which_matches_exactly()
		{
			int recieved = 0;

			_connector.ListenTo<int>(
				_exchangeDefinition,
				_queueDefinition,
				(props, json) =>
				{
					recieved = json;
					_reset.Set();
					return true;
				});

			_connector.SendTo(_exchangeDefinition, "some.key", props => { }, 123);
			_reset.WaitOne(TimeSpan.FromSeconds(5));

			recieved.ShouldBe(123);
		}

{'fraction_non_alphanumeric': 0.09729511505853855, 'fraction_numerical': 0.006459426725878078, 'mean_word_length': 4.006060606060606, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '5441699', 'n_tokens_mistral': 936, 'n_tokens_neox': 753, 'n_words': 163}