I have a method that uses an OpenAccess model. I want to mock out an OptimisticVerificationException in the first (and only first) call to SaveChanges(). How can this be achieved?
public void ThrowTest(Guid id, string stringToUpdate) { var user = _model.Users.SingleOrDefault(p => p.Guid == id); if (user != null) { user.StringToUpdate = stringToUpdate; try { _model.SaveChanges(); } catch (OptimisticVerificationException optimisticVerificationException) { _model.Refresh(RefreshMode.OverwriteChangesFromStore, user); user.StringToUpdate = stringToUpdate; _model.SaveChanges(); } } }