Beispiel #1
0
        public void Delete_SetsEntityState_ToDeleted()
        {
            using (var dbContext = new EntityDbContext())
            {
                var entity = new User
                {
                    Name = Guid.NewGuid().ToString()
                };
                dbContext.Create(entity);
                var affectedRows = dbContext.SaveChangesAsync().Result;

                affectedRows.ShouldEqual(1);
                dbContext.Entry(entity).State.ShouldEqual(EntityState.Unchanged);
                dbContext.Delete(entity);
                dbContext.Entry(entity).State.ShouldEqual(EntityState.Deleted);
            }
        }