public ScreenManager(Game game) : base(game) { screens = new List <BaseScreen>(); Jobs = new BackgroundJobs(); Jobs.SpinUp(); }
public ActionResult QueueServerBJob2(Default1Model model) { var jobClient = new BackgroundJobClient(); var jobId = jobClient.Enqueue(() => BackgroundJobs.QueueServerBJob2()); model.ServerBJob2Id = jobId; return(View("Index", model)); }
private void TestDataSetUp() { BackgroundJobs bgJob = new BackgroundJobs { JobID = 1, JobDuration = 10, JobTimeStramp = DateTime.Now, Status = JobConstants.Status_Inprogress }; List <BackgroundJobs> backgroundJobsList = new List <BackgroundJobs>(); backgroundJobsList.Add(bgJob); }
public async Task GetById_Test() { BackgroundJobs bgJob = new BackgroundJobs { JobID = 1, JobDuration = 10, JobTimeStramp = DateTime.Now, Status = JobConstants.Status_Inprogress }; List <BackgroundJobs> backgroundJobsList = new List <BackgroundJobs>(); backgroundJobsList.Add(bgJob); _mockbghsDbContext.Setup(a => a.GetCurrentBackgroundJobs()).ReturnsAsync(backgroundJobsList); var res = (await backgroundJobController.GetById(1)) as OkObjectResult; Assert.Equal(bgJob, res.Value); }
public async Task GetById_NegativeTest() { BackgroundJobs bgJob = new BackgroundJobs { JobID = 1, JobDuration = 10, JobTimeStramp = DateTime.Now, Status = JobConstants.Status_Inprogress }; List <BackgroundJobs> backgroundJobsList = new List <BackgroundJobs>(); backgroundJobsList.Add(bgJob); _mockbghsDbContext.Setup(a => a.GetCurrentBackgroundJobs()).Throws(new Exception("Internal Server Exception!!")); try { var res = await backgroundJobController.GetById(1); } catch (Exception ex) { Assert.NotNull(ex); } }
public async Task ExecuteSortArray(int[] inputArr) { _iLogger.LogInformation("New Array is added for sorting!!", inputArr); using (var scope = serviceScopeFactory.CreateScope()) { BackgroundJobs backgroundJob = new BackgroundJobs(); var dbContext = scope.ServiceProvider.GetService <BGHSDbContext>(); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); //sort the array from backgroundJob reference GetArraySorted(inputArr); stopWatch.Stop(); long duration = stopWatch.ElapsedMilliseconds; backgroundJob.JobDuration = duration; backgroundJob.Status = JobConstants.Status_Completed; dbContext.BackgroundJobData.Add(backgroundJob); await dbContext.SaveChangesAsync(); _iLogger.LogInformation("Added Array Sorting id completed", backgroundJob); } }