public void Provide_WithNoConfigurationItems_ShouldBeEmpty()
        {
            var source = new Mock<IObjectFactoryConfigurationSource>();

            source.Setup(x => x.Source()).Returns(new ObjectFactoryConfiguration());

            var sut = new ObjectFactoryConfigurationProvider(new[] { source.Object });

            sut.Provide<Customer, IDoSomething>(new Customer(), string.Empty).ShouldBeEmpty();
        }
        public void Provide_WithNullInstance_ShouldThrowException()
        {
            var source = new Mock<IObjectFactoryConfigurationSource>();

            source.Setup(x => x.Source()).Returns(new ObjectFactoryConfiguration());

            var sut = new ObjectFactoryConfigurationProvider(new[] { source.Object });

            Should.Throw<ArgumentException>(() => sut.Provide<Customer, IDoSomething>(null, string.Empty));
        }
        public void New_WithNullResultType_ShouldThrowException()
        {
            var source = new Mock<IObjectFactoryConfigurationSource>();

            source.Setup(x => x.Source()).Returns(new ObjectFactoryConfiguration()
            {
                Items = new List<ObjectFactoryConfigurationItem>()
                    {
                        new ObjectFactoryConfigurationItem(typeof(Person), null, string.Empty)
                    }
            }
            );

            Should.Throw<ArgumentException>(() => { var sut = new ObjectFactoryConfigurationProvider(new[] { source.Object }); });
        }
        public void Provide_WithInvalidType_ShouldBeEmpty()
        {
            var source = new Mock<IObjectFactoryConfigurationSource>();

            source.Setup(x => x.Source()).Returns(new ObjectFactoryConfiguration()
            {
                Items = new List<ObjectFactoryConfigurationItem>()
                    {
                        new ObjectFactoryConfigurationItem(typeof(Person), typeof(DoSomething))
                    }
            }
            );

            var sut = new ObjectFactoryConfigurationProvider(new[] { source.Object });

            sut.Provide<Customer, IDoSomething>(new Customer(), string.Empty).ShouldBeEmpty();
        }
 public void New_WithNullSources_ShouldThrowException()
 {
     Should.Throw<ArgumentNullException>(() => { var sut = new ObjectFactoryConfigurationProvider(null); });
 }
        public void Provide_WithValidTypeAndValidNameAndValidTrueSelectorAndValidResultType_ShouldNotBeEmpty()
        {
            var source = new Mock<IObjectFactoryConfigurationSource>();

            source.Setup(x => x.Source()).Returns(new ObjectFactoryConfiguration()
            {
                Items = new List<ObjectFactoryConfigurationItem>
                    {
                        new ObjectFactoryConfigurationItem(typeof(Customer), typeof(DoSomething), (Func<Customer, bool>)(t => true))
                    }
            });

            var sut = new ObjectFactoryConfigurationProvider(new[] { source.Object });

            var configuration = sut.Provide<Customer, IDoSomething>(new Customer(), ObjectFactorySettings.BuildDefaultName(typeof (Customer)));

            configuration.ShouldNotBeEmpty();
        }