<commit_before>﻿using System;
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
using HangFire.MEF;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace Hangfire.MEF.Tests
{
    [TestClass]
    public class MEFJobActivatorTests
    {
        private CompositionContainer _container;

        [TestInitialize]
        public void Setup()
        {
            AggregateCatalog catalog = new AggregateCatalog();
            catalog.Catalogs.Add(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
            _container = new CompositionContainer(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Ctor_ThrowsAnException_WhenContainerIsNull()
        {
            var activator = new MEFJobActivator(null);

        }

        [TestMethod]
        public void Class_IsBasedOnJobActivator()
        {
            var activator = new MEFJobActivator(_container);
            Assert.IsInstanceOfType(activator, typeof(JobActivator));
        }

        [TestMethod]
        public void ActivateJob_CallsMEF()
        {
            var activator = new MEFJobActivator(_container);

            var result = activator.ActivateJob(typeof (IMEFTestClass)) as IMEFTestClass;
            Assert.AreEqual(100,result.TestValue);
        }

        [TestMethod]
        public void ActivateJob_CallsMEF_PropertyImports()
        {
            var activator = new MEFJobActivator(_container);

            var result = activator.ActivateJob(typeof(MEFTestClassWrapper)) as MEFTestClassWrapper;
            Assert.AreEqual(100, result.MEFTestClass.TestValue);
        }

        [TestMethod]
        public void UseNinjectActivator_PassesCorrectActivator()
        {
            var configuration = new Mock<IBootstrapperConfiguration>();
            
            configuration.Object.UseMEFActivator(_container);

            configuration.Verify(x => x.UseActivator(It.IsAny<MEFJobActivator>()));<commit_msg>Fixed incorrect naming in unit tests<commit_after>﻿using System;
using System.ComponentModel.Composition.Hosting;
using System.Reflection;
using HangFire.MEF;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

namespace Hangfire.MEF.Tests
{
    [TestClass]
    public class MEFJobActivatorTests
    {
        private CompositionContainer _container;

        [TestInitialize]
        public void Setup()
        {
            _container = new CompositionContainer(new AssemblyCatalog(Assembly.GetExecutingAssembly()));
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void Ctor_ThrowsAnException_WhenContainerIsNull()
        {
            var activator = new MEFJobActivator(null);

        }

        [TestMethod]
        public void Class_IsBasedOnJobActivator()
        {
            var activator = new MEFJobActivator(_container);
            Assert.IsInstanceOfType(activator, typeof(JobActivator));
        }

        [TestMethod]
        public void ActivateJob_CallsMEF()
        {
            var activator = new MEFJobActivator(_container);

            var result = activator.ActivateJob(typeof (IMEFTestClass)) as IMEFTestClass;
            Assert.AreEqual(100,result.TestValue);
        }

        [TestMethod]
        public void ActivateJob_CallsMEF_PropertyImports()
        {
            var activator = new MEFJobActivator(_container);

            var result = activator.ActivateJob(typeof(MEFTestClassWrapper)) as MEFTestClassWrapper;
            Assert.AreEqual(100, result.MEFTestClass.TestValue);
        }

        [TestMethod]
        public void UseMEFActivator_PassesCorrectActivator()
        {
            var configuration = new Mock<IBootstrapperConfiguration>();
            
            configuration.Object.UseMEFActivator(_container);

            configuration.Verify(x => x.UseActivator(It.IsAny<MEFJobActivator>()));
{'fraction_non_alphanumeric': 0.0788152610441767, 'fraction_numerical': 0.0030120481927710845, 'mean_word_length': 2.649267399267399, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5551841', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1043, 'n_words': 188}