public void SetUp()
        {
            _configurationServiceMock = new Mock <IConfigurationService>();

            _configurationServiceMock.Setup(x => x.Get <ProcessConfiguration>())
            .Returns(new ProcessConfiguration {
                EnableVacancyStatusPropagation = true
            });

            _cacheServiceMock           = new Mock <ICacheService>();
            _applicationStatusProcessor = new Mock <IApplicationStatusProcessor>();

            _subscriber = new VacancyStatusSummarySubscriber(
                _configurationServiceMock.Object,
                _cacheServiceMock.Object,
                _applicationStatusProcessor.Object);
        }
        public void ShouldPutInCacheWhenNotInCache()
        {
            // Arrange.
            var vacancyStatusSummary = new VacancyStatusSummary
            {
                LegacyVacancyId = 123,
                ClosingDate     = DateTime.UtcNow.AddMonths(-3),
                VacancyStatus   = VacancyStatuses.Expired
            };

            _applicationStatusProcessor.Setup(x => x.ProcessApplicationStatuses(It.IsAny <VacancyStatusSummary>()));
            _cacheServiceMock.Setup(x => x.PutObject(It.IsAny <string>(), It.IsAny <object>(), It.IsAny <CacheDuration>()));

            _configurationServiceMock.Setup(x => x.Get <ProcessConfiguration>())
            .Returns(new ProcessConfiguration
            {
                EnableVacancyStatusPropagation = true
            });

            _subscriber = new VacancyStatusSummarySubscriber(
                _configurationServiceMock.Object,
                _cacheServiceMock.Object,
                _applicationStatusProcessor.Object);

            // Act.
            var state = _subscriber.Consume(vacancyStatusSummary);

            // Assert.
            state.Should().NotBeNull();
            state.Should().Be(ServiceBusMessageStates.Complete);

            _cacheServiceMock.Verify(
                x =>
                x.PutObject(
                    It.Is <string>(c => c == vacancyStatusSummary.CacheKey()),
                    It.Is <object>(vss => vss == vacancyStatusSummary),
                    It.Is <CacheDuration>(c => c == vacancyStatusSummary.CacheDuration())), Times.Once);

            _applicationStatusProcessor.Verify(
                x =>
                x.ProcessApplicationStatuses(
                    It.Is <VacancyStatusSummary>(i => i == vacancyStatusSummary)), Times.Once);
        }