public void TestDataFetch() { using (var context = new InsuranceDataContext()) { var repository = new InsuranceRepository(context); var records = repository.GetItems<t031_geo_code>(); Assert.True(records.Any()); var item = records.Take(1).FirstOrDefault(); Assert.IsNotNull(item); var id = item.t031_id; var fetchedSingleItem = repository.GetItem<t031_geo_code>(id); Assert.IsNotNull(fetchedSingleItem); Assert.AreEqual(id, fetchedSingleItem.t031_id); } }
public void TestDataDelete() { using (var context = new InsuranceDataContext()) { var repository = new InsuranceRepository(context); var originalCount = repository.GetItems<t00002_event_loss_footprint>().Count(); var record = repository.GetItems<t00002_event_loss_footprint>().FirstOrDefault(); Assert.IsNotNull(record); repository.DeleteItem<t00002_event_loss_footprint>(record.id); repository.Save(); var newCount = repository.GetItems<t00002_event_loss_footprint>().Count(); Assert.AreEqual(originalCount - 1, newCount); } }
public void TestDataBulkDelete() { using (var context = new InsuranceDataContext()) { var repository = new InsuranceRepository(context); var originalCount = repository.GetItems<t00001_event_loss_footprint>().Count(); var records = repository.GetItems<t00001_event_loss_footprint>().Take(11); Assert.True(records.Any() && records.Count() == 11); var recordList = records.ToList(); repository.DeleteItems(recordList); repository.Save(); var newCount = repository.GetItems<t00001_event_loss_footprint>().Count(); Assert.AreEqual(originalCount - 11, newCount); } }
public void TestDataInsert() { using (var context = new InsuranceDataContext()) { var repository = new InsuranceRepository(context); var originalCount = repository.GetItems<t00001_event_set>().Count(); repository.InsertItem(new t00001_event_set { event_day = 1, event_simulation = 2, t010_id = 11 }); repository.Save(); var newCount = repository.GetItems<t00001_event_set>().Count(); Assert.AreEqual(originalCount + 1, newCount); } }
public void TestDataUpdate() { using (var context = new InsuranceDataContext()) { const string originalName = "OriginalName"; const string originalCode = "OC"; const string updatedName = "UpdatedName"; const string updatedCode = "UC"; var repository = new InsuranceRepository(context); var originalCount = repository.GetItems<t030_geo_region>().Count(); var parent = repository.GetItems<t030_geo_region>().FirstOrDefault(); Assert.IsNotNull(parent); var region = new t030_geo_region { t030_name = originalName, t030_code = originalCode, t030_parent_id = parent.t030_id, t030_level_no = parent.t030_level_no + 1 }; repository.InsertItem(region); repository.Save(); var newCount = repository.GetItems<t030_geo_region>().Count(); Assert.AreEqual(originalCount + 1, newCount); var item = repository.GetItems<t030_geo_region>().FirstOrDefault(g => g.t030_name == originalName && g.t030_code == originalCode); Assert.IsNotNull(item); item.t030_name = updatedName; item.t030_code = updatedCode; repository.UpdateItem(item, item.t030_id); repository.Save(); newCount = repository.GetItems<t030_geo_region>().Count(); Assert.AreEqual(originalCount + 1, newCount); item = repository.GetItems<t030_geo_region>().FirstOrDefault(g => g.t030_name == originalName && g.t030_code == originalCode); Assert.IsNull(item); item = repository.GetItems<t030_geo_region>().FirstOrDefault(g => g.t030_name == updatedName && g.t030_code == updatedCode); Assert.IsNotNull(item); repository.DeleteItem<t030_geo_region>(item.t030_id); repository.Save(); newCount = repository.GetItems<t030_geo_region>().Count(); Assert.AreEqual(originalCount, newCount); item = repository.GetItems<t030_geo_region>().FirstOrDefault(g => g.t030_name == originalName && g.t030_code == originalCode); Assert.IsNull(item); item = repository.GetItems<t030_geo_region>().FirstOrDefault(g => g.t030_name == updatedName && g.t030_code == updatedCode); Assert.IsNull(item); } }