public IReadStream <T> Create(JoinedXsvStreamContext context)
            {
                XsvToObjectStreamFactory <T> x = null;
                var lineReadFactories          = context.FilePaths.Select(i => FactoryChain.Create(FactoryWatcher.Create(new FileLineReadStreamFactory(i), (o) => context.CurrentFilePath = i), x));//.ToList<IFactory<IReadStream<string>>>();

                return(new HeadToTailMultiStream <T>(lineReadFactories.ToList()));
            }
Exemple #2
0
        public void ShouldCreateNullValueWhenNoFactoriesAreRegistered()
        {
            var chain = new FactoryChain <Func <object> >();

            var value = chain.CreateValue <object>(factory => factory());

            Assert.IsNull(value);
        }
Exemple #3
0
        public void ShouldUseRegisteredFactoryWhenCreatingValue()
        {
            var chain = new FactoryChain <Func <int> >();

            chain.RegisterFactory(() => 5);

            var value = chain.CreateValue <int>(factory => factory());

            Assert.AreEqual(5, value);
        }
Exemple #4
0
        public void ShouldPassFactoryToCreatorWhenCreatingValue()
        {
            var chain = new FactoryChain <int>();

            chain.RegisterFactory(5);
            var someFactory = 0;

            chain.CreateValue <object>(factory => { someFactory = factory; return(null); });

            Assert.AreEqual(5, someFactory);
        }
Exemple #5
0
        public void ShouldUseFirstNonNullValueReturnedFromCreator()
        {
            var chain = new FactoryChain <Func <int?> >();

            chain.RegisterFactory(() => null);
            chain.RegisterFactory(() => 2);
            chain.RegisterFactory(() => 3);

            var value = chain.CreateValue <int?>(factory => factory());

            Assert.AreEqual(value, 2);
        }
Exemple #6
0
        public void ShouldThrowIfCreatorIsNullWhenCreatingValue()
        {
            var chain = new FactoryChain <object>();

            chain.CreateValue <object>(null);
        }
Exemple #7
0
        public void ShouldNotRegisterNullFactory()
        {
            var chain = new FactoryChain <object>();

            chain.RegisterFactory(null);
        }