Esempio n. 1
0
        public void AddReminderTest()
        {
            var reminder = new HydrateReminder { StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), FrequencyInHours = 2, LastUpdatedTime = DateTime.Now, LastRunTime = DateTime.Now, Message = "Please drink water", IsPaused = false };
            var repository = new FakeHydrateRepository();
            repository.CreateOrUpdateReminder(reminder);

            var reminderRetrieved = repository.GetReminder();
            Assert.IsTrue(reminder.Equals(reminderRetrieved));
        }
Esempio n. 2
0
        public void CreateReminderInstancesTest()
        {
            var frequencyInHours = 1;
            var reminder = new HydrateReminder { StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), FrequencyInHours = frequencyInHours, LastUpdatedTime = DateTime.Now, Message = "Please drink water", IsPaused = false };
            var repository = new FakeHydrateRepository();
            repository.CreateOrUpdateReminder(reminder);

            var reminderInstanceScheduler = new ReminderInstanceScheduler(repository);
            reminderInstanceScheduler.CreateReminderInstances();

            var currentInstances = reminderInstanceScheduler.ScheduledNotifications;
            Assert.IsTrue(currentInstances.Count == (reminder.EndDate.Subtract(reminder.StartDate).TotalHours / reminder.FrequencyInHours));

            var currentTime = DateTime.Now.AddHours(frequencyInHours);
            //Evaluate Instances
            foreach (var currentInstance in currentInstances)
            {
                Assert.IsTrue(currentInstance.DeliveryTime.Subtract(currentTime) < TimeSpan.FromMilliseconds(2));
                currentTime = currentTime.AddHours(frequencyInHours);
            }
        }
Esempio n. 3
0
 public void CreateOrUpdateReminder(HydrateReminder reminder)
 {
 }
Esempio n. 4
0
 public void CreateOrUpdateReminder(HydrateReminder reminder)
 {
     this._reminder = reminder;
 }