コード例 #1
0
        public void CachingDataLoader_Recreate()
        {
            CsvDataLoader wrapped = new CsvDataLoader("C:\\path");

            // Create a caching data loader
            CachingDataLoader original = new CachingDataLoader(wrapped);

            // Clone the caching data loader
            CachingDataLoader recreated = new CachingDataLoader();
            ((IDataLoader)recreated).Argument = ((IDataLoader)original).Argument;

            // It should be exactly the same as the original
            Assert.AreEqual(
                original.WrappedDataLoader.GetType(),
                recreated.WrappedDataLoader.GetType());

            recreated.WrappedDataLoader.Should().BeOfType<CsvDataLoader>();

            // The wrapped data loader should be restored completely too
            CsvDataLoader recreatedWrapped = recreated.WrappedDataLoader as CsvDataLoader;

            Assert.IsNotNull(recreatedWrapped);
            Assert.AreEqual(wrapped.ContainerFolderPath, recreatedWrapped.ContainerFolderPath);
        }
コード例 #2
0
 protected static DbConnection CreateConnection(string path = null)
 {
     var dataLoader = new CsvDataLoader(path ?? DefaultTestDataUri);
     var cachingLoader = new CachingDataLoader(dataLoader);
     return DbConnectionFactory.CreateTransient(cachingLoader);
 }