Пример #1
0
        public void PersistenceExecution_GetSuspendedEnvironment_Success()
        {
            var resourceId = Guid.Parse("ab04663e-1e09-4338-8f61-a06a7ae5ebab");
            var values     = new Dictionary <string, StringBuilder>
            {
                { "resourceID", new StringBuilder(resourceId.ToString()) },
                { "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";

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

            mockPersistenceScheduler.Setup(o => o.ScheduleJob(suspendOption, suspendOptionValue, values))
            .Returns(expectedJobId).Verifiable();
            var mockPersistedValues = new Mock <IPersistedValues>();

            mockPersistedValues.Setup(o => o.ResourceId).Returns(resourceId);
            mockPersistenceScheduler.Setup(o => o.GetPersistedValues(expectedJobId))
            .Returns(mockPersistedValues.Object).Verifiable();

            var scheduler = new PersistenceExecution(mockPersistenceScheduler.Object);
            var result    = scheduler.GetPersistedValues(expectedJobId);

            Assert.AreEqual(resourceId, result.ResourceId);
        }
Пример #2
0
        public void PersistenceExecution_GetPersistedValues_PersistenceSettingsNoConfigured()
        {
            const string expectedJobId = "1234";

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

            scheduler.GetPersistedValues(expectedJobId);
        }