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())); }
public void ShouldCreateNullValueWhenNoFactoriesAreRegistered() { var chain = new FactoryChain <Func <object> >(); var value = chain.CreateValue <object>(factory => factory()); Assert.IsNull(value); }
public void ShouldUseRegisteredFactoryWhenCreatingValue() { var chain = new FactoryChain <Func <int> >(); chain.RegisterFactory(() => 5); var value = chain.CreateValue <int>(factory => factory()); Assert.AreEqual(5, value); }
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); }
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); }
public void ShouldThrowIfCreatorIsNullWhenCreatingValue() { var chain = new FactoryChain <object>(); chain.CreateValue <object>(null); }
public void ShouldNotRegisterNullFactory() { var chain = new FactoryChain <object>(); chain.RegisterFactory(null); }