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()));
            }
Exemplo n.º 2
0
        public void ShouldCreateNullValueWhenNoFactoriesAreRegistered()
        {
            var chain = new FactoryChain <Func <object> >();

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

            Assert.IsNull(value);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
        public void ShouldThrowIfCreatorIsNullWhenCreatingValue()
        {
            var chain = new FactoryChain <object>();

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

            chain.RegisterFactory(null);
        }