public void Add(IStockProfile stockProfile) { StockProfileRepository repository = new StockProfileRepository(DataFiles.GetStockProfileFile()); repository.AddRange(new IStockProfile[] { stockProfile }); //using (var context = GetContext()) //{ // var repository = new Repository<StockProfile>(context); // repository.Add(stockProfile.ToDataObject()); // repository.UnitOfWork.Commit(); //} }
public void TestMethod_StockProfile() { StockProfile example = ExampleStockProfile(); string filePath = Path.Combine(Environment.CurrentDirectory, "TestStockProfile.sdf"); if (File.Exists(filePath)) { File.Delete(filePath); } StockProfileRepository repository = new StockProfileRepository(filePath); repository.AddRange(new IStockProfile[] { example }); Assert.IsTrue(repository.Exists(example)); IStockProfile get = repository.Get(example.CodeA); StockProfile updateData = example; updateData.ShortNameA = "招商银行_UpdateTest"; repository.UpdateRange(new IStockProfile[] { updateData }); Assert.IsTrue(repository.Exists(updateData)); IList<IStockProfile> result = repository.GetAll().ToList(); Assert.AreEqual(1, result.Count); }