Esempio n. 1
0
        public void GetFactoryAdapter_uses_constructor_selector(ISelectsConstructor ctorSelector,
                                                                ResolutionRequest request)
        {
            // Arrange
            var type = typeof(SampleServiceWithConstructorParameters);
            var sut  = new TypeRegistration(type, ctorSelector);
            var ctor = type.GetConstructor(new [] { typeof(string), typeof(string) });

            Mock.Get(ctorSelector)
            .Setup(x => x.SelectConstructor(type))
            .Returns(ctor);

            // Act
            var result = sut.GetFactoryAdapter(request);

            // Assert
            Assert.That(result, Is.Not.Null);
            Assert.That(result, Is.InstanceOf <ConstructorFactory>());
            var ctorFactory = (ConstructorFactory)result;

            Assert.That(ctorFactory.Constructor, Is.SameAs(ctor));
        }