<commit_before>﻿namespace Tests
{
    using Autofac;
    using Autofac.Builder;
    using Autofac.Core;
    using Autofac.Features.Scanning;
	using Autofac.Core.Lifetime;
	using Moq;
	using Newtonsoft.Json;
	using System.Linq;
	using Newtonsoft.Json.Linq;
	using OctoHook;
	using OctoHook.Controllers;
	using OctoHook.CommonComposition;
	using Octokit;
	using Octokit.Events;
	using Octokit.Internal;
	using System;
	using System.IO;
	using System.Net.Http;
	using System.Threading.Tasks;
	using Xunit;

	public class EndToEnd
	{
		static readonly Credentials credentials = new Credentials(File.ReadAllText(@"..\..\Token").Trim());

		[Fact]
		public async Task when_processing_issues_request_then_succeeds()
		{
			var work = new Mock<IJobQueue>();
			work.Setup(x => x.Queue(It.IsAny<Func<Task>>()))
				.Callback<Func<Task>>(a => a().Wait());

			var container = ContainerConfiguration.Configure(
				typeof(AutoAssign).Assembly, 
				typeof(AutoClose).Assembly, 
				typeof(AutoLabel).Assembly, 
				typeof(AutoLink).Assembly, 
				typeof(OctoIssuerJob).Assembly
			);
			var lifetime = container.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag);

			var github = new GitHubClient(new ProductHeaderValue("kzu-client"), new InMemoryCredentialStore(credentials));
			var repository = await github.Repository.Get("kzu", "sandbox");
			var user = await github.User.Current();
<commit_msg>Added composition tests<commit_after>﻿namespace Tests
{
    using Autofac;
    using Autofac.Builder;
    using Autofac.Core;
    using Autofac.Features.Scanning;
	using Autofac.Core.Lifetime;
	using Moq;
	using Newtonsoft.Json;
	using System.Linq;
	using Newtonsoft.Json.Linq;
	using OctoHook;
	using OctoHook.Controllers;
	using OctoHook.CommonComposition;
	using Octokit;
	using Octokit.Events;
	using Octokit.Internal;
	using System;
	using System.IO;
	using System.Net.Http;
	using System.Threading.Tasks;
	using Xunit;

	public class EndToEnd
	{
		static readonly Credentials credentials = new Credentials(File.ReadAllText(@"..\..\Token").Trim());

		[Fact]
		public void when_retrieving_scoped_instances_then_succeeds()
		{
			var container = ContainerConfiguration.Configure(
				typeof(AutoAssign).Assembly, 
				typeof(AutoClose).Assembly, 
				typeof(AutoLabel).Assembly, 
				typeof(AutoLink).Assembly, 
				typeof(OctoIssuerJob).Assembly
			);

			var lifetime = container.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag);

			var queue1 = container.Resolve<IJobQueue>();
			var queue2 = container.Resolve<IJobQueue>();

			Assert.Same(queue1, queue2);

			Assert.NotNull(lifetime.Resolve<OctoIssuerJob>());

			Assert.NotNull(lifetime.Resolve<GitHubController>());
		}

		[Fact]
		public async Task when_processing_issues_request_then_succeeds()
		{
			var work = new Mock<IJobQueue>();
			work.Setup(x => x.Queue(It.IsAny<Func<Task>>()))
				.Callback<Func<Task>>(a => a().Wait());

			var container = ContainerConfiguration.Configure(
				typeof(AutoAssign).Assembly, 
				typeof(AutoClose).Assembly, 
				typeof(AutoLabel).Assembly, 
				typeof(AutoLink).Assembly, 
				typeof(OctoIssuerJob).Assembly
			);
			var lifetime = container.BeginLifetimeScope(MatchingScopeLifetimeTags.RequestLifetimeScopeTag);

			var github = new GitHubClient(new ProductHeaderValue("kzu-client"), new InMemoryCredentialStore(credentials));
			var repository = await github.Repository.Get("kzu", "sandbox");
			var user = await github.User.Current();

{'fraction_non_alphanumeric': 0.11529614721104083, 'fraction_numerical': 0.0011500862564692352, 'mean_word_length': 4.740924092409241, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 21, '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': '7011412', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1097, 'n_words': 209}