private object SimulateFailureNTimes(uint timesToFail, bool throwExceptionOnFailure = true) { this.iteration++; if(this.iteration <= timesToFail) { if(throwExceptionOnFailure) throw new Exception("Simulated count failure"); return null; } return DateTime.UtcNow; }