public void RegisterFactoryFunction_ShouldThrowWhenFactoryFunctionAlreadyExistsForType()
        {
            var col = new EntityFactoryFunctionCollection();
            col.RegisterFactoryFunction(() => new SimpleTestEntity());

            Assert.Throws<ArgumentException>(() =>
                col.RegisterFactoryFunction(() => new SimpleTestEntity()));
        }
        public void RegisterFactoryFunction_ShouldAddMethodThatTakesNoParameters()
        {
            var expected = new SimpleTestEntity();
            var col = new EntityFactoryFunctionCollection();
            col.RegisterFactoryFunction(() => expected);

            var factoryFunction = col.GetFactoryFunction<SimpleTestEntity>();

            Assert.Same(expected, factoryFunction(null));
        }
        public void RegisterFactoryFunction_ShouldAddMethodThatTakesFactory()
        {
            var expectedFactory = new Factory();
            var col = new EntityFactoryFunctionCollection();
            Factory passed = null;
            col.RegisterFactoryFunction(f =>
                                            {
                                                passed = f;
                                                return new SimpleTestEntity();
                                            });

            var factoryFunction = col.GetFactoryFunction<SimpleTestEntity>();
            factoryFunction(expectedFactory);

            Assert.Same(expectedFactory, passed);
        }