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.");
     }
 }
Exemple #2
0
        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.");
            }
        }
Exemple #4
0
 public WorkUnit()
 {
     _context = new FoodContext();
 }