private IDataLoader SetupTestData() { var filePath = @"C:\Users\barehami\Documents\visual studio 2013\Projects\Effort.Data\Effort.Tests\Data\TestData"; IDataLoader loader = new Effort.DataLoaders.CsvDataLoader(filePath); return(loader); }
public static TradeSharpConnectionPersistent InitializeTradeSharpConnection() { var path = GetCsvFilesFolder(); var loader = new CsvDataLoader(path); var connection = Effort.EntityConnectionFactory.CreateTransient("name=TradeSharpConnection", loader); var connectionPersistent = new TradeSharpConnectionPersistent(connection); DatabaseContext.InitializeFake(connectionPersistent); return connectionPersistent; }
private static void ConfigureApplication(IUnityContainer container) { //_ambientContainer.RegisterType<IDbRepository, DbRepository>(new PerResolveLifetimeManager()); if (Convert.ToBoolean(ConfigurationManager.AppSettings.Get("UseEffort")) == true) { IDataLoader loader = new Effort.DataLoaders.CsvDataLoader(AppDomain.CurrentDomain.BaseDirectory + "\\Seed"); _ambientContainer.RegisterType <HRContext, HRContext>(new PerResolveLifetimeManager(), new InjectionConstructor(DbConnectionFactory.CreateTransient(loader))); } else { _ambientContainer.RegisterType <HRContext, HRContext>(new PerResolveLifetimeManager(), new InjectionConstructor()); } _ambientContainer.RegisterType <IDbRepository, DbRepository>(new PerResolveLifetimeManager()); _ambientContainer.RegisterType <IActivityManager, ActivityManager>(new PerResolveLifetimeManager()); _ambientContainer.RegisterType <IPersonManager, PersonManager>(new PerResolveLifetimeManager()); _ambientContainer.RegisterType <ISessionManager, SessionManager>(new PerResolveLifetimeManager()); _ambientContainer.RegisterType <IUtilityManager, UtilityManager>(new PerResolveLifetimeManager()); }
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); }
public void CsvDataLoader_EmbeddedResource_NotExistingDirectory() { var loader = new CsvDataLoader("res://Effort.Test/Internal/NonExisting"); Exception expected = null; try { loader.CreateTableDataLoaderFactory(); } catch (Exception ex) { expected = ex; } expected.Should().BeOfType<ArgumentException>(); }
public void CsvDataLoader_EmbeddedResource_NotExisting() { var loader = new CsvDataLoader("res://Effort.Test/Internal/Resources/"); var factory = loader.CreateTableDataLoaderFactory(); var tableLoader = factory.CreateTableDataLoader( new TableDescription( "DoesNotExist", new[] { new ColumnDescription("Id", typeof(int)), })); var data = tableLoader.GetData().ToList(); data.Should().HaveCount(0); }
public void CsvDataLoader_EmbeddedResource() { var loader = new CsvDataLoader("res://Effort.Test/Internal/Resources/"); var factory = loader.CreateTableDataLoaderFactory(); var tableLoader = factory.CreateTableDataLoader( new TableDescription( "Foo", new[] { new ColumnDescription("Id", typeof(int)), new ColumnDescription("Value", typeof(string)) })); var data = tableLoader.GetData().Single(); data[0].Should().Be(1); data[1].Should().Be("Foo"); }
public static DbConnection GetEffortConnection(string relativeDataPath) { var dataPath = Path.GetFullPath(relativeDataPath); var dataLoader = new CsvDataLoader(dataPath); return DbConnectionFactory.CreateTransient(dataLoader); }
protected static DbConnection CreateConnection(string path = null) { var dataLoader = new CsvDataLoader(path ?? DefaultTestDataUri); var cachingLoader = new CachingDataLoader(dataLoader); return DbConnectionFactory.CreateTransient(cachingLoader); }