コード例 #1
0
            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);
            }
コード例 #2
0
 private static void RunJob(UpdateStatisticsJob job)
 {
     var task = job.Execute();
     task.Start();
     try
     {
         task.Wait();
     }
     catch (AggregateException)
     {
     }
 }
コード例 #3
0
            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);
            }