コード例 #1
0
ファイル: HydrateReminderTest.cs プロジェクト: AB-GR/Hydrate
        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));
        }
コード例 #2
0
ファイル: HydrateReminderTest.cs プロジェクト: AB-GR/Hydrate
        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);
            }
        }