public void GivenContextWhenFoodDescriptionsFetchedThenShouldReturnList() { using (var ctx = new FoodContext()) { var list = ctx.FoodDescriptions.ToList(); Assert.IsNotNull(list, "Test failed: list should exist."); Assert.IsTrue(list.Count > 0, "Test failed: at least one item should exist."); } }
protected virtual void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_context != null) { _context.Dispose(); _context = null; } } _disposed = true; }
public void GivenWorkUnitWhenNotCommittedThenDatabaseShouldRemainTheSame() { var id = string.Empty; var date = DateTime.Now; using (var unit = new WorkUnit(Thread.CurrentPrincipal)) { var firstItem = unit.Collection<FoodDescription>().FirstOrDefault(); firstItem.SomeDate = date; id = firstItem.Id; } using (var ctx = new FoodContext()) { var actual = ctx.FoodDescriptions.Find(id); if (actual == null) { Assert.Fail("Item was not found."); } Assert.IsFalse(actual.SomeDate == date, "Test failed: date should not have been updated."); } }
public WorkUnit() { _context = new FoodContext(); }