Is there anyway I can load the data to the in-memory instead of using.csv files in effort for unit-testing?
Scenario: I want to load the data to the in-memory to use the Effort framework which creates the fake dbcontext and performs the operation. Instead of using Dataloader and .csv files I need to load the data programatically.
Sample code which works fine with .csv files:
IDataLoader loader = new Effort.DataLoaders.CsvDataLoader("D:\\csv");
var dataLoader = new CachingDataLoader(loader, false);
DbConnection connection = Effort.DbConnectionFactory.CreateTransient(dataLoader);
DbContext mockedDbContext = new NopObjectContext(connection);
EfRepository<Shelf> _shelEfRepository = new EfRepository<Shelf>(mockedDbContext);
EfRepository<ProductVariant> _productVariantEfRepository = new EfRepository<ProductVariant>(mockedDbContext);
EfRepository<Product> _productEfRepository = new EfRepository<Product>(mockedDbContext);
_shelfService = new ShelfService(_shelEfRepository, _productVariantEfRepository, _productEfRepository);
I am just looking for something replacement to load the data instead of loading the data using .csv files
You could create a Transient/Persistent DbConnection
without a DataLoader, use it in your DbContext
, then programmatically push your generated data into the context.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.