Ejemplo n.º 1
0
        public void PersistenceExecution_ResumeJob_Success()
        {
            var mockDataObject = new Mock <IDSFDataObject>();
            var values         = new Dictionary <string, StringBuilder>
            {
                { "resourceID", new StringBuilder("ab04663e-1e09-4338-8f61-a06a7ae5ebab") },
                { "environment", new StringBuilder("") },
                { "startActivityId", new StringBuilder("4032a11e-4fb3-4208-af48-b92a0602ab4b") },
                { "versionNumber", new StringBuilder("1") }
            };

            const enSuspendOption suspendOption = enSuspendOption.SuspendUntil;
            var          suspendOptionValue     = DateTime.Now.AddDays(1).ToString(CultureInfo.InvariantCulture);
            const string expectedJobId          = "1234";
            const string environment            = "environment";

            Config.Persistence.PersistenceScheduler = nameof(Hangfire);
            var mockPersistenceScheduler = new Mock <IPersistenceScheduler>();

            mockPersistenceScheduler.Setup(o => o.ScheduleJob(suspendOption, suspendOptionValue, values))
            .Returns(expectedJobId).Verifiable();
            mockPersistenceScheduler.Setup(o => o.ResumeJob(mockDataObject.Object, expectedJobId, true, environment))
            .Returns(GlobalConstants.Success).Verifiable();

            var scheduler = new PersistenceExecution(mockPersistenceScheduler.Object);
            var jobId     = scheduler.CreateAndScheduleJob(suspendOption, suspendOptionValue, values);
            var result    = scheduler.ResumeJob(mockDataObject.Object, expectedJobId, true, environment);

            Assert.AreEqual(GlobalConstants.Success, result);
        }
Ejemplo n.º 2
0
        public void PersistenceExecution_CreateAndScheduleJob_PersistenceSettingsNoConfigured()
        {
            var values = new Dictionary <string, StringBuilder>
            {
                { "resourceID", new StringBuilder("ab04663e-1e09-4338-8f61-a06a7ae5ebab") },
                { "environment", new StringBuilder("") },
                { "startActivityId", new StringBuilder("4032a11e-4fb3-4208-af48-b92a0602ab4b") },
                { "versionNumber", new StringBuilder("1") }
            };

            const enSuspendOption suspendOption      = enSuspendOption.SuspendForDays;
            const string          suspendOptionValue = "1";

            Config.Persistence.PersistenceScheduler = "";
            var scheduler = new PersistenceExecution(null);

            scheduler.CreateAndScheduleJob(suspendOption, suspendOptionValue, values);
        }
Ejemplo n.º 3
0
        public void PersistenceExecution_CreateAndScheduleJob_Success()
        {
            var values = new Dictionary <string, StringBuilder>
            {
                { "resourceID", new StringBuilder("ab04663e-1e09-4338-8f61-a06a7ae5ebab") },
                { "environment", new StringBuilder("") },
                { "startActivityId", new StringBuilder("4032a11e-4fb3-4208-af48-b92a0602ab4b") },
                { "versionNumber", new StringBuilder("1") }
            };

            const enSuspendOption suspendOption      = enSuspendOption.SuspendForDays;
            const string          suspendOptionValue = "1";

            Config.Persistence.PersistenceScheduler = nameof(Hangfire);
            var mockPersistenceScheduler = new Mock <IPersistenceScheduler>();

            mockPersistenceScheduler.Setup(o => o.ScheduleJob(suspendOption, suspendOptionValue, values)).Verifiable();

            var scheduler = new PersistenceExecution(mockPersistenceScheduler.Object);

            scheduler.CreateAndScheduleJob(suspendOption, suspendOptionValue, values);

            mockPersistenceScheduler.Verify(o => o.ScheduleJob(suspendOption, suspendOptionValue, values), Times.Once);
        }