<commit_before>using Newtonsoft.Json.Linq;
using NSubstitute;
using Xunit;

namespace ecoAPM.NET.Agent.Tests;

public class QueuedAgentTests
{
	[Fact]
	public async Task SendAddsEventToQueue()
	{
		//arrange
		var config = new ServerConfig(new Uri("http://localhost"), Guid.NewGuid());
		var httpClient = Substitute.For<HttpClient>();
		var agent = new QueuedAgent(config, httpClient, null, TimeSpan.Zero);

		//act
		var e = new Event();
		await agent.Send(e);

		//assert
		Assert.Contains(e, agent.GetEventsToSend());
	}

	[Fact]
	public void EventsQueueIsClearedOnDispose()
	{<commit_msg>Fix race condition in QueuedAgentTests<commit_after>using Newtonsoft.Json.Linq;
using NSubstitute;
using Xunit;

namespace ecoAPM.NET.Agent.Tests;

public class QueuedAgentTests
{
	[Fact]
	public async Task SendAddsEventToQueue()
	{
		//arrange
		var config = new ServerConfig(new Uri("http://localhost"), Guid.NewGuid());
		var httpClient = Substitute.For<HttpClient>();
		var agent = new QueuedAgent(config, httpClient, null, TimeSpan.MaxValue);

		//act
		var e = new Event();
		await agent.Send(e);
		await Task.Delay(1);

		//assert
		Assert.Contains(e, agent.GetEventsToSend());
	}

	[Fact]
	public void EventsQueueIsClearedOnDispose()
	{
{'fraction_non_alphanumeric': 0.1262135922330097, 'fraction_numerical': 0.0008090614886731392, 'mean_word_length': 4.726851851851852, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3301619', 'n_tokens_mistral': 447, 'n_tokens_neox': 414, 'n_words': 100}