public void AllowNeitherEmailNorSmsShouldNotSendMessageAndSoftDeleteAlerts()
        {
            var savedSearchAlertRepository = new Mock <ISavedSearchAlertRepository>();

            savedSearchAlertRepository.Setup(x => x.GetCandidatesSavedSearchAlerts()).Returns(GetSavedSearchAlerts(2, 2));

            var candidateReadRepository = new Mock <ICandidateReadRepository>();
            var candidate = new CandidateBuilder(Guid.NewGuid())
                            .EnableSavedSearchAlertsViaEmail(false)
                            .EnableSavedSearchAlertsViaText(false)
                            .Build();

            candidateReadRepository.Setup(x => x.Get(It.IsAny <Guid>())).Returns(candidate);

            var userReadRepository = new Mock <IUserReadRepository>();
            var user = new UserBuilder(candidate.EntityId).WithStatus(UserStatuses.Active).Build();

            userReadRepository.Setup(x => x.Get(It.IsAny <Guid>())).Returns(user);

            var sendSavedSearchAlertsStrategy = new SendSavedSearchAlertsStrategyBuilder()
                                                .With(savedSearchAlertRepository)
                                                .With(candidateReadRepository)
                                                .With(userReadRepository)
                                                .Build();

            var communicationProcessor = new CommunicationProcessor(null, sendSavedSearchAlertsStrategy);
            var batchId = Guid.NewGuid();

            communicationProcessor.SendSavedSearchAlerts(batchId);

            savedSearchAlertRepository.Verify(x => x.GetCandidatesSavedSearchAlerts(), Times.Once);
            candidateReadRepository.Verify(x => x.Get(It.IsAny <Guid>()), Times.Exactly(2));
            userReadRepository.Verify(x => x.Get(It.IsAny <Guid>()), Times.Exactly(2));
            savedSearchAlertRepository.Verify(x => x.Save(It.IsAny <SavedSearchAlert>()), Times.Exactly(4));
        }
        public void AllowEmailOrSmsShouldSendMessageAndUpdate(bool allowEmail, bool allowMobile)
        {
            var savedSearchAlertRepository = new Mock <ISavedSearchAlertRepository>();

            savedSearchAlertRepository.Setup(x => x.GetCandidatesSavedSearchAlerts()).Returns(GetSavedSearchAlerts(2, 2));

            var candidateReadRepository = new Mock <ICandidateReadRepository>();
            var candidate = new CandidateBuilder(Guid.NewGuid())
                            .EnableSavedSearchAlertsViaEmail(allowEmail)
                            .EnableSavedSearchAlertsViaText(allowMobile)
                            .VerifiedMobile(allowMobile)
                            .Build();

            candidateReadRepository.Setup(x => x.Get(It.IsAny <Guid>())).Returns(candidate);

            var userReadRepository = new Mock <IUserReadRepository>();
            var user = new UserBuilder(candidate.EntityId).WithStatus(UserStatuses.Active).Build();

            userReadRepository.Setup(x => x.Get(It.IsAny <Guid>())).Returns(user);

            var serviceBus = new Mock <IServiceBus>();

            var sendSavedSearchAlertsStrategy = new SendSavedSearchAlertsStrategyBuilder()
                                                .With(candidateReadRepository)
                                                .With(userReadRepository)
                                                .With(savedSearchAlertRepository)
                                                .With(serviceBus)
                                                .Build();

            var communicationProcessor = new CommunicationProcessor(null, sendSavedSearchAlertsStrategy);
            var batchId = Guid.NewGuid();

            communicationProcessor.SendSavedSearchAlerts(batchId);

            savedSearchAlertRepository.Verify(x => x.GetCandidatesSavedSearchAlerts(), Times.Once);
            candidateReadRepository.Verify(x => x.Get(It.IsAny <Guid>()), Times.Exactly(2));
            userReadRepository.Verify(x => x.Get(It.IsAny <Guid>()), Times.Exactly(2));
            savedSearchAlertRepository.Verify(x => x.Delete(It.IsAny <SavedSearchAlert>()), Times.Never);
            savedSearchAlertRepository.Verify(x => x.Save(It.IsAny <SavedSearchAlert>()), Times.Exactly(4));
            serviceBus.Verify(x => x.PublishMessage(It.IsAny <CommunicationRequest>()), Times.Exactly(2));
        }