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.");
            }
        }
Beispiel #2
0
        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.");
            }
        }