public IEnumerable<IStockBonus> Get(string stockCode) { StockBonusRepository repository = new StockBonusRepository(DataFiles.GetStockBonusFile(stockCode)); return repository.GetAll(); //using (var context = GetContext(stockCode)) //{ // var repository = new Repository<StockBonus>(context); // return repository.GetAll(); //} }
public void TestMethod_StockBonus() { StockBonus example = ExampleStockBonus(new DateTime(2015, 7, 2)); StockBonus noEists = ExampleStockBonus(new DateTime(2015, 8, 2)); string filePath = Path.Combine(Environment.CurrentDirectory, "TestStockBonus.sdf"); if (File.Exists(filePath)) { File.Delete(filePath); } StockBonusRepository repository = new StockBonusRepository(filePath); repository.AddRange(new IStockBonus[] { example }); Assert.IsTrue(repository.Exists(example)); Assert.IsFalse(repository.Exists(noEists)); IStockBonus get = repository.Get(example.DateOfDeclaration.ToString("yyyy-MM-dd HH:mm:ss")); StockBonus updateData = example; updateData.Description = "Update Example"; repository.UpdateRange(new IStockBonus[] { updateData }); Assert.IsTrue(repository.Exists(updateData)); IList<IStockBonus> result = repository.GetAll().ToList(); Assert.AreEqual(1, result.Count); }