public void ReturnsATask() { var context = new Mock<DbContext>(); var job = new UpdateStatisticsJob(TimeSpan.FromSeconds(10), () => context.Object, TimeSpan.MaxValue); var task = job.Execute(); Assert.NotNull(task); }
private static void RunJob(UpdateStatisticsJob job) { var task = job.Execute(); task.Start(); try { task.Wait(); } catch (AggregateException) { } }
public void CreatesNewContextOnEachRun() { int createTimes = 0; var context = new Mock<DbContext>(); var job = new UpdateStatisticsJob(TimeSpan.FromSeconds(10), () => { Interlocked.Increment(ref createTimes); throw new InvalidOperationException(); // Prevent the actual calling of the query. }); RunJob(job); RunJob(job); Assert.Equal(2, createTimes); }