public void InjectionArgsSource_creates_argument_list_with_values_returned_by_factory()
        {
            var dep1 = new Dependency1();
            var dep2 = new Dependency2();

            object Factory(Type t)
            {
                if (typeof(IDependency1) == t)
                {
                    return(dep1);
                }

                if (typeof(IDependency2) == t)
                {
                    return(dep2);
                }

                throw new Exception($"Requested unsupported dependency type {t.FullName}");
            }

            var source = new InjectionArgsSource <DependencyInjectingTestClass>(Factory);

            var contents = source.GetInjectionParameters();

            Assert.That(contents.Length, Is.EqualTo(2));
            Assert.That(contents[0], Is.InstanceOf <IDependency1>());
            Assert.That(contents[0], Is.InstanceOf <Dependency1>());
            Assert.That(contents[0], Is.SameAs(dep1));
            Assert.That(contents[1], Is.InstanceOf <IDependency2>());
            Assert.That(contents[1], Is.InstanceOf <Dependency2>());
            Assert.That(contents[1], Is.SameAs(dep2));
        }
        public void GetInjectionParameters_throws_a_DependencyResolutionException_if_the_type_cannot_be_resolved()
        {
            object Factory(Type t) => throw new Exception($"Requested unsupported dependency type {t.FullName}");

            var source = new InjectionArgsSource <DependencyInjectingTestClass>(Factory);

            var thrown = Assert.Throws <DependencyResolutionException>(() => source.GetInjectionParameters());

            Assert.That(thrown.InjectionClassType, Is.EqualTo(typeof(DependencyInjectingTestClass)));
            Assert.That(thrown.InjectionParameterType, Is.EqualTo(typeof(IDependency1)));
        }