public void SelectsConstructorWithParameters()
        {
            var target2 = new MatchingSignatureConstructorSelector(typeof(int), typeof(string));
            var c2      = target2.SelectConstructorBinding(_ctors, Enumerable.Empty <Parameter>());

            Assert.Equal(2, c2.TargetConstructor.GetParameters().Length);
        }
        public void SelectsEmptyConstructor()
        {
            var target0 = new MatchingSignatureConstructorSelector();
            var c0      = target0.SelectConstructorBinding(_ctors, Enumerable.Empty <Parameter>());

            Assert.Empty(c0.TargetConstructor.GetParameters());
        }
Пример #3
0
        public void SelectsConstructorWithParameters()
        {
            var target2 = new MatchingSignatureConstructorSelector(typeof(int), typeof(string));
            var c2      = target2.SelectConstructorBinding(_ctors);

            Assert.IsNotNull(c2);
            Assert.AreEqual(2, c2.TargetConstructor.GetParameters().Length);
        }
Пример #4
0
        public void SelectsEmptyConstructor()
        {
            var target0 = new MatchingSignatureConstructorSelector();
            var c0      = target0.SelectConstructorBinding(_ctors);

            Assert.IsNotNull(c0);
            Assert.AreEqual(0, c0.TargetConstructor.GetParameters().Length);
        }
Пример #5
0
        public void WhenNoMatchingConstructorsAvailable_ExceptionDescribesTargetTypeAndSignature()
        {
            var target = new MatchingSignatureConstructorSelector(typeof(string));

            var dx = Assert.Throws <DependencyResolutionException>(() =>
                                                                   target.SelectConstructorBinding(_ctors, Enumerable.Empty <Parameter>()));

            Assert.True(dx.Message.Contains(typeof(ThreeConstructors).Name));
            Assert.True(dx.Message.Contains(typeof(string).Name));
        }
        public void IgnoresInvalidBindings()
        {
            var target2 = new MatchingSignatureConstructorSelector(typeof(int), typeof(string), typeof(double));

            Assert.Throws <DependencyResolutionException>(() => target2.SelectConstructorBinding(_ctors, Enumerable.Empty <Parameter>()));
        }