Пример #1
0
        public void Execute(IJobExecutionContext context)
        {
            var reminders = Reminders.GetRemindersForDate(DateTime.SpecifyKind(DateTime.Now.Date, DateTimeKind.Utc));

            var textService = new TextService();

            foreach (var reminder in reminders)
            {
                textService.SendMessage(reminder);
            }
        }
Пример #2
0
        public void message_longer_than_160_chars_fails()
        {
            var target = new TextService();

            var longMessage = @"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";

            var testerOneReminder = new Reminder(testNumberOne, longMessage, DateTime.Now, "daily", null,
                                        DateTime.Now.AddDays(1), "appointment");

            target.SendMessage(testerOneReminder);
        }
Пример #3
0
        public void simple_message_sends_and_reminder_logged()
        {
            var target = new TextService();

            var reminder = new Reminder(testNumberOne, "Simple Message Test", DateTime.Now, "daily", null,
                                        DateTime.Now.AddDays(1), "appointment");

            var splits = Guid.NewGuid().ToString().Split('-');
            reminder._id = new ObjectId(string.Join("", splits).Substring(0, 24));

            target.SendMessage(reminder);
            var cursor = MongoAccess.GetReminderLogCollection().Find(Query.EQ("_originalId", reminder._id));
            Assert.AreEqual(1, cursor.Count());
        }
Пример #4
0
        public void send_multiple_messages_successfully()
        {
            var textService = new TextService();

            var testerOneReminder = new Reminder(testNumberOne, "testerOne Multiple Message Test", DateTime.Now, "daily", null,
                                        DateTime.Now.AddDays(1), "appointment");

            var testerTwoReminder = new Reminder(testNumberTwo, "testerTwo Multiple Message Test", DateTime.Now, "daily", null,
                                        DateTime.Now.AddDays(1), "appointment");

            var patients = new[] {testerOneReminder, testerTwoReminder};

            foreach (var reminder in patients)
            {
                textService.SendMessage(reminder);
            }
        }
Пример #5
0
        public JsonResult SendTextMessage(SendTextMessageRequest request)
        {
            var response = new Response{ Success = true };

            var textService = new TextService();

            try
            {
                textService.SendMessage(request.SendTo, request.TextMessage);
            }
            catch (Exception e)
            {
                response.Success = false;
            }

            return Json(response, JsonRequestBehavior.AllowGet);
        }