<commit_before>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Stashbox.Entity;
using Stashbox.Infrastructure;
using System;
using System.Linq.Expressions;

namespace Stashbox.Tests
{
    [TestClass]
    public class ContainerTests
    {
        [TestMethod]
        public void ContainerTests_ChildContainer()
        {
            var container = new StashboxContainer();
            container.RegisterType<ITest1, Test1>();
            container.RegisterType<ITest2, Test2>();

            var child = container.CreateChildContainer();
            child.RegisterType<ITest3, Test3>();

            var test3 = child.Resolve<ITest3>();

            Assert.IsNotNull(test3);
            Assert.IsInstanceOfType(test3, typeof(Test3));
            Assert.AreEqual(container, child.ParentContainer);
        }

        [TestMethod]
        public void ContainerTests_IsRegistered()
        {
            var container = new StashboxContainer();
            container.RegisterType<ITest1, Test1>();
            container.RegisterType<ITest2, Test2>();

            Assert.IsTrue(container.IsRegistered<ITest1>());
            Assert.IsTrue(container.IsRegistered(typeof(ITest2)));
            Assert.IsFalse(container.IsRegistered<ITest3>());
            Assert.IsFalse(container.IsRegistered<ITest1>("test"));
            Assert.IsFalse(container.IsRegistered(typeof(ITest1), "test"));
        }

        [TestMethod]
        public void ContainerTests_ResolverTest()
        {
            var container = new StashboxContainer();
            container.RegisterResolver((context, typeInfo) => typeInfo.Type == typeof(ITest1), new TestResolverFactory());
            var inst = container.Resolve<ITest1>();

            Assert.IsInstanceOfType(inst, typeof(Test1));
        }

        public interface ITest1 { }

        public interface ITest2 { }

        public interface ITest3 { }

        public class Test1 : ITest1
        {
        }

        public class Test2 : ITest2
        {
        }

        public class Test3 : ITest3
        {
        }

        public class TestResolver : Resolver
        {
            public TestResolver(IContainerContext containerContext, TypeInformation typeInfo)
            : base(containerContext, typeInfo)
            {
            }
<commit_msg>Improved coverage<commit_after>﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Stashbox.Entity;
using Stashbox.Infrastructure;
using System;
using System.Linq.Expressions;

namespace Stashbox.Tests
{
    [TestClass]
    public class ContainerTests
    {
        [TestMethod]
        public void ContainerTests_ChildContainer()
        {
            var container = new StashboxContainer();
            container.RegisterType<ITest1, Test1>();
            container.RegisterType<ITest2, Test2>();

            var child = container.CreateChildContainer();
            child.RegisterType<ITest3, Test3>();

            var test3 = child.Resolve<ITest3>();

            Assert.IsNotNull(test3);
            Assert.IsInstanceOfType(test3, typeof(Test3));
            Assert.AreEqual(container, child.ParentContainer);
        }

        [TestMethod]
        public void ContainerTests_IsRegistered()
        {
            var container = new StashboxContainer();
            container.RegisterType<ITest1, Test1>();
            container.RegisterType<ITest2, Test2>();

            Assert.IsTrue(container.IsRegistered<ITest1>());
            Assert.IsTrue(container.IsRegistered(typeof(ITest2)));
            Assert.IsFalse(container.IsRegistered<ITest3>());
            Assert.IsFalse(container.IsRegistered<ITest1>("test"));
            Assert.IsFalse(container.IsRegistered(typeof(ITest1), "test"));
        }

        [TestMethod]
        public void ContainerTests_ResolverTest()
        {
            var container = new StashboxContainer();
            container.RegisterResolver((context, typeInfo) => typeInfo.Type == typeof(ITest1), new TestResolverFactory());
            var inst = container.Resolve<ITest1>();

            Assert.IsInstanceOfType(inst, typeof(Test1));
        }

        public interface ITest1 { }

        public interface ITest2 { }

        public interface ITest3 { }

        public class Test1 : ITest1
        {
        }

        public class Test2 : ITest2
        {
            public Test2(ITest1 test1)
            {
            }
        }

        public class Test3 : ITest3
        {
            public Test3(ITest1 test1, ITest2 test2)
            {
            }
        }

        public class TestResolver : Resolver
        {
            public TestResolver(IContainerContext containerContext, TypeInformation typeInfo)
            : base(containerContext, typeInfo)
            {
            }

{'fraction_non_alphanumeric': 0.09520807061790669, 'fraction_numerical': 0.015132408575031526, 'mean_word_length': 2.14332892998679, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 25, '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': '3088278', 'n_tokens_mistral': 1252, 'n_tokens_neox': 1230, 'n_words': 229}