public void DontCreateUserEmailTaskForInActiveClient()
        {
            var generationDate    = new DateTime(2013, 1, 17);
            var contactRepository = new LocalRepository <Contact>();
            var taskCreator       = new Mock <ITaskManager>();
            var client            = ModelHelper.TestClient1AllDataNoReferences;

            client.IsActive       = false;
            client.Labels         = new Collection <Label>();
            client.InsideUserSets = new List <InsideUser>();
            var lableForClient = new Label()
            {
                Id   = 1,
                Name = "Helloypaket"
            };
            var contactForUser = new Contact()
            {
                Id = 1
            };

            client.InsideUserSets.Add(new InsideUser
            {
                Id = "UserId1"
            });


            client.Labels.Add(lableForClient);
            contactForUser.Client = client;
            contactRepository.Add(contactForUser);

            var serverTime          = new Mock <IServerTime>();
            var taskRepository      = new Mock <IRepository <InsideModel.Models.Task> >();
            var taskQueueStorage    = new Mock <ITaskQueueStorage>();
            var newContactSmsSender = new SmsNotificationTaskPerformer(
                contactRepository,
                taskCreator.Object,
                serverTime.Object, taskRepository.Object,
                taskQueueStorage.Object);

            var taskMessage = JsonConvert.SerializeObject(new SmsNotificationTaskMessage()
            {
                ContactId = contactForUser.Id
            });

            newContactSmsSender.PerformTask(new InsideModel.Models.Task()
            {
                Message = taskMessage, EarliestExecution = generationDate
            });

            taskRepository.Verify(es => es.Add(It.IsAny <InsideModel.Models.Task>()), Times.Never);

            taskQueueStorage.Verify(es => es.Add(It.IsAny <InsideModel.Models.Task>()), Times.Never);
        }
        public void CreateUserSmsTaskForEveryUser()
        {
            var generationDate    = new DateTime(2013, 1, 17);
            var contactRepository = new LocalRepository <Contact>();

            var taskCreator = new Mock <ITaskManager>();
            var client      = ModelHelper.TestClient1AllDataNoReferences;

            var lableForClient = new Label()
            {
                Id   = 1,
                Name = "Helloypaket"
            };
            var contactForUser = new Contact()
            {
                Id = 1
            };

            client.Labels = new Collection <Label>();

            client.Labels.Add(lableForClient);
            contactForUser.Client = client;
            var insideUser = new InsideUser
            {
                Id         = "UserId1",
                ReceiveSms = true,
                Phone      = "0123456"
            };
            var insideUser2 = new InsideUser
            {
                Id         = "UserId2",
                ReceiveSms = true,
                Phone      = "0123456"
            };

            client.InsideUserSets = new List <InsideUser>
            {
                insideUser, insideUser2
            };
            contactRepository.Add(contactForUser);

            var serverTime          = new Mock <IServerTime>();
            var taskRepository      = new LocalRepository <InsideModel.Models.Task>();
            var taskQueueStorage    = new Mock <ITaskQueueStorage>();
            var newContactSmsSender = new SmsNotificationTaskPerformer(
                contactRepository,
                taskCreator.Object,
                serverTime.Object, taskRepository,
                taskQueueStorage.Object);

            var now = new DateTime(2013, 01, 01);

            serverTime.Setup(st => st.RequestStarted).Returns(now);
            var taskMessage = JsonConvert.SerializeObject(new SmsNotificationTaskMessage()
            {
                ContactId = contactForUser.Id
            });

            newContactSmsSender.PerformTask(new InsideModel.Models.Task()
            {
                Message = taskMessage, EarliestExecution = generationDate
            });

            taskQueueStorage.Verify(es => es.Add(It.Is <InsideModel.Models.Task>(t => t.Message == "{\"ContactId\":1,\"UserId\":\"UserId1\"}" && t.Type == "SendNewContactSmsNotificationToUser")), Times.Exactly(1));
            taskQueueStorage.Verify(es => es.Add(It.Is <InsideModel.Models.Task>(t => t.Message == "{\"ContactId\":1,\"UserId\":\"UserId2\"}" && t.Type == "SendNewContactSmsNotificationToUser")), Times.Exactly(1));
        }