public void WatchJobSetting_WithoutBuilder_AddReccuringJob() { _settingsManagerMock.Setup(x => x.GetObjectSettingAsync("enablername", null, null)).ReturnsAsync(new ObjectSettingEntry()); _settingsManagerMock.Setup(x => x.GetObjectSettingAsync("cronname", null, null)).ReturnsAsync(new ObjectSettingEntry()); //Act RecurringJobExtensions.WatchJobSetting <SomeJob>( _recurringJobManagerMock.Object, _settingsManagerMock.Object, new SettingDescriptor { DefaultValue = true, Name = "enablername" }, new SettingDescriptor { DefaultValue = "* * * *", Name = "cronname" }, x => x.Process(), nameof(SomeJob), TimeZoneInfo.Utc, EnqueuedState.DefaultQueue); //Assert _recurringJobManagerMock.Verify(x => x.AddOrUpdate(It.IsAny <string>(), It.IsAny <Job>(), It.IsAny <string>(), It.IsAny <RecurringJobOptions>()) , Times.Once()); }
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { //app.UseCustomErrorPages(); app.UseDeveloperExceptionPage(); } else { app.UseCustomErrorPages(); } app.UseStaticFiles(); app.UseCookiePolicy(); app.UseRouting(); app.UseSession(); app.UseHangfireServer(); app.UseHangfireDashboard(); RecurringJobExtensions.AddRecurringJobs(); app.UseAuthentication(); app.UseAuthorization(); app.UseResponseCompression(); app.UseRequestLocalization( options: app.ApplicationServices .GetService <IOptions <RequestLocalizationOptions> >().Value); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); }
public void WatchJobSetting_WithBuilder_AddReccuringJob() { _settingsManagerMock.Setup(x => x.GetObjectSettingAsync("enablername", null, null)).ReturnsAsync(new ObjectSettingEntry()); _settingsManagerMock.Setup(x => x.GetObjectSettingAsync("cronname", null, null)).ReturnsAsync(new ObjectSettingEntry()); //Act RecurringJobExtensions.WatchJobSettingAsync(_recurringJobManagerMock.Object, _settingsManagerMock.Object, new SettingCronJobBuilder() .SetEnablerSetting(new SettingDescriptor { DefaultValue = true, Name = "enablername" }) .SetCronSetting(new SettingDescriptor { DefaultValue = "* * * *", Name = "cronname" }) .ToJob <SomeJob>(x => x.Process()) .Build()); //Assert _recurringJobManagerMock.Verify(x => x.AddOrUpdate(It.IsAny <string>(), It.IsAny <Job>(), It.IsAny <string>(), It.IsAny <RecurringJobOptions>()) , Times.Once()); }