public BaseRS Add(ScheduleMessage messageToBeSchedule)
 {
     BaseRS result = new BaseRS();
     _scheduleMessageList.Add(messageToBeSchedule);
     result.Success = true;
     return result;
 }
Ejemplo n.º 2
0
        public void DeveEnviarMensagensAgendadas()
        {
            //Arrange
            DeveAgendarEnvio();
            MessengerService service = new MessengerService(_memoryRepository);

            for (int i = 0; i < 10; i++)
            {
                ScheduleMessage messageToBeScheduled = new ScheduleMessage(
                    type: MessageType.CrossSellingHotel,
                    emailTo: "*****@*****.**",
                    dateToSend: DateTime.Now,
                    externalId: i,
                    companyId: 52
                );

                //Act
                service.DoSchedule(messageToBeScheduled);
            }

            //Act
            BaseRS result = service.Process().Result;

            //Assert
            Assert.IsTrue(result.Success);
            Assert.AreEqual(0, result.Errors.Count);

            //Assert
        }
Ejemplo n.º 3
0
 static Task<string> PrepareTask(ScheduleMessage message)
 {
     Task<string> thread = Task.Run<string>(() =>
     {
         return CallSendGridHere(message);
     }, _token);
     return thread;
 }
Ejemplo n.º 4
0
        public void DeveAgendarEnvio()
        {
            //Arrange
            MessengerService service = new MessengerService(_memoryRepository);

            ScheduleMessage messageToBeScheduled = new ScheduleMessage(
                    type: MessageType.CrossSellingHotel,
                    emailTo: "*****@*****.**",
                    dateToSend: DateTime.Now,
                    externalId: 12345678,
                    companyId: 52
                );

            //Act
            BaseRS result = service.DoSchedule(messageToBeScheduled);

            //Assert
            Assert.IsTrue(result.Success);
            Assert.AreEqual(0, result.Errors.Count);
        }
Ejemplo n.º 5
0
 static string CallSendGridHere(ScheduleMessage message)
 {
     Thread.Sleep(1000);
     System.Diagnostics.Trace.WriteLine(message.ExternalId.ToString());
     return message.ExternalId.ToString();
 }
Ejemplo n.º 6
0
 public BaseRS DoSchedule(ScheduleMessage messageToBeScheduled)
 {
     return _repository.Add(messageToBeScheduled);
 }