Beispiel #1
0
        public void RiseExcetionWhenInsertTwoJobsWithSameID()
        {
            safeManager.Add(EnforceRecurringJob.Create(idJob, methodCall, hourly));

            Assert.Throws <Exception>(() =>
                                      safeManager.Add(EnforceRecurringJob.Create(idJob, methodCall, hourly)));
        }
Beispiel #2
0
        public void AddTwoJobsAndRemoveOne()
        {
            // Mock:
            var recurringJobManager        = Substitute.For <IRecurringJobManager>();
            var jobStorage                 = Substitute.For <JobStorage>();
            var recurringJobRepositoryMock = Substitute.For <RecurringJobRepository>(jobStorage);
            var recurringJobs              = new List <RecurringJobDto>();
            var recurringJobDto            = new RecurringJobDto
            {
                Id = "jobToRemove"
            };

            recurringJobs.Add(recurringJobDto);
            recurringJobRepositoryMock.GetRecurringJobs().Returns(recurringJobs);

            // Arrange
            var hourly = Cron.Hourly();
            Expression <Action <string> > methodCall = text => text.ToString();
            var recurringJobCleanUpManager           =
                new RecurringJobCleanUpManager(recurringJobManager, recurringJobRepositoryMock)
            {
                EnforceRecurringJob.Create("jobrecurrent", methodCall, hourly),
                EnforceRecurringJob.Create("jobrecurrent2", methodCall, hourly)
            };

            // Act
            recurringJobCleanUpManager.AddUpdateDeleteJobs();

            // Assert
            recurringJobManager.Received()
            .AddOrUpdate("jobrecurrent", Arg.Any <Job>(), hourly, Arg.Any <RecurringJobOptions>());
            recurringJobManager.Received()
            .AddOrUpdate("jobrecurrent2", Arg.Any <Job>(), hourly, Arg.Any <RecurringJobOptions>());
            recurringJobManager.Received().RemoveIfExists("jobToRemove");
        }
Beispiel #3
0
        public void AddMultipleJobs()
        {
            safeManager.Add(EnforceRecurringJob.Create(idJob, methodCall, hourly));
            safeManager.Add(EnforceRecurringJob.Create("jobrecurrent2", methodCall, hourly));
            safeManager.Add(EnforceRecurringJob.Create("jobrecurrent3", methodCall, hourly));

            Assert.Equal(3, safeManager.Count);
        }
        public void BeCreatedWithFactoryWithOtherMethod()
        {
            var expected = new EnforceRecurringJob(id, jobExpected, hourly, new RecurringJobOptions());

            var actual = EnforceRecurringJob.Create <string>(id, text => text.Insert(0, "test"), hourly);

            Assert.NotEqual(expected, actual);
        }
        public void BeCreatedWithFactory()
        {
            var expected = new EnforceRecurringJob(id, jobExpected, hourly, new RecurringJobOptions());

            var actual = EnforceRecurringJob.Create <string>(id, text => text.ToString(), hourly);

            Assert.Equal(expected, actual);
        }
Beispiel #6
0
        public void AddJob()
        {
            var job          = EnforceRecurringJob.Create(idJob, methodCall, hourly);
            var expectedList = new List <EnforceRecurringJob> {
                job
            };

            safeManager.Add(job);

            Assert.Equal(expectedList, safeManager.RecurringJobs);
        }
        public void BeCreatedWithFactoryAndQueueAndTimeZone()
        {
            var queue        = "critical";
            var timeZoneInfo = TimeZoneInfo.Utc;
            var expected     = new EnforceRecurringJob(id, jobExpected, hourly,
                                                       new RecurringJobOptions {
                QueueName = queue, TimeZone = timeZoneInfo
            });

            var actual = EnforceRecurringJob.Create <string>(id, text => text.ToString(), hourly, queue, timeZoneInfo);

            Assert.Equal(expected, actual);
        }