public void Notification_Timer_1()
{
TestRoot.Security.SetPermission(Subscriber1, true, PermissionType.OpenMinor, ContentRepository.Storage.Security.PermissionValue.Allow);
TestRoot.Security.SetPermission(Subscriber2, true, PermissionType.Open, ContentRepository.Storage.Security.PermissionValue.Allow);
var folder1 = Content.CreateNew("Folder", TestRoot, "Folder_timer1");
folder1.Save();
var folder2 = Content.CreateNew("Folder", folder1.ContentHandler, "Folder_timer2");
folder2.Save();
var folder3 = Content.CreateNew("Folder", folder2.ContentHandler, "Folder_timer3");
folder3.Save();
Subscription.Subscribe(Subscriber1, TestRoot, NotificationFrequency.Immediately, "en", TESTSITEPATH, TESTSITEURL);
Subscription.Subscribe(Subscriber2, TestRoot, NotificationFrequency.Immediately, "en", TESTSITEPATH, TESTSITEURL);
Subscription.Subscribe(Subscriber1, folder1.ContentHandler, NotificationFrequency.Daily, "en", TESTSITEPATH, TESTSITEURL);
Subscription.Subscribe(Subscriber2, folder1.ContentHandler, NotificationFrequency.Daily, "en", TESTSITEPATH, TESTSITEURL);
Subscription.Subscribe(Subscriber1, folder2.ContentHandler, NotificationFrequency.Weekly, "en", TESTSITEPATH, TESTSITEURL);
Subscription.Subscribe(Subscriber2, folder2.ContentHandler, NotificationFrequency.Weekly, "en", TESTSITEPATH, TESTSITEURL);
Subscription.Subscribe(Subscriber1, folder3.ContentHandler, NotificationFrequency.Monthly, "en", TESTSITEPATH, TESTSITEURL);
Subscription.Subscribe(Subscriber2, folder3.ContentHandler, NotificationFrequency.Monthly, "en", TESTSITEPATH, TESTSITEURL);
var content1 = Content.CreateNew("Car", folder3.ContentHandler, "car_timer1");
var content2 = Content.CreateNew("Car", folder3.ContentHandler, "car_timer2");
((GenericContent)content1.ContentHandler).VersioningMode = ContentRepository.Versioning.VersioningType.MajorAndMinor;
((GenericContent)content2.ContentHandler).VersioningMode = ContentRepository.Versioning.VersioningType.MajorAndMinor;
content1.Save();
content2.Save();
var content1path = content1.Path;
var content2path = content2.Path;
Event.CreateAndSave(content1path, 1, 1, NotificationType.Created, "\\Administrator", DateTime.Parse("2011-03-22 08:00:01"));
Event.CreateAndSave(content1path, 1, 1, NotificationType.MinorVersionModified, "\\Administrator", DateTime.Parse("2011-03-22 08:05:02"));
Event.CreateAndSave(content2path, 1, 1, NotificationType.MinorVersionModified, "\\Administrator", DateTime.Parse("2011-03-22 08:10:03"));
Event.CreateAndSave(content1path, 1, 1, NotificationType.MinorVersionModified, "\\Administrator", DateTime.Parse("2011-03-22 08:15:04"));
Event.CreateAndSave(content2path, 1, 1, NotificationType.MinorVersionModified, "\\Administrator", DateTime.Parse("2011-03-22 08:20:05"));
Event.CreateAndSave(content1path, 1, 1, NotificationType.MinorVersionModified, "\\Administrator", DateTime.Parse("2011-03-22 08:25:06"));
Event.CreateAndSave(content1path, 1, 1, NotificationType.MajorVersionModified, "\\Administrator", DateTime.Parse("2011-03-22 08:30:07"));
Event.CreateAndSave(content1path, 1, 1, NotificationType.MinorVersionModified, "\\Administrator", DateTime.Parse("2011-03-22 08:35:08"));
Event.CreateAndSave(content1path, 1, 1, NotificationType.MajorVersionModified, "\\Administrator", DateTime.Parse("2011-03-22 08:40:09"));
Event.CreateAndSave(content2path, 1, 1, NotificationType.MajorVersionModified, "\\Administrator", DateTime.Parse("2011-03-22 08:45:10"));
config.ImmediatelyEnabled = true;
config.DailyEnabled = true;
config.WeeklyEnabled = true;
config.MonthlyEnabled = true;
config.DailyHour = 1;
config.DailyMinute = 0;
config.WeeklyHour = 1;
config.WeeklyMinute = 0;
config.WeeklyWeekDay = DayOfWeek.Tuesday;
config.MonthlyEvery = true;
config.MonthlyHour = 1;
config.MonthlyMinute = 0;
config.MonthlyLast = false;
config.MonthlyDay = 22;
int count = 0;
////---- immediately
//Message.DeleteAllMessages();
//NotificationHandler.TimerTick(DateTime.Parse("2011-03-22 08:05:59"));
//Assert.IsTrue((count = Message.GetAllMessages().Count()) == 2, String.Format("#1: count is {0}, expected {1}", count, 2));
//Message.DeleteAllMessages();
//NotificationHandler.TimerTick(DateTime.Parse("2011-03-22 08:15:59"));
//Assert.IsTrue((count = Message.GetAllMessages().Count()) == 1, String.Format("#2: count is {0}, expected {1}", count, 1));
//Message.DeleteAllMessages();
//NotificationHandler.TimerTick(DateTime.Parse("2011-03-22 08:25:59"));
//Assert.IsTrue((count = Message.GetAllMessages().Count()) == 1, String.Format("#3: count is {0}, expected {1}", count, 1));
//Message.DeleteAllMessages();
//NotificationHandler.TimerTick(DateTime.Parse("2011-03-22 08:35:59"));
//Assert.IsTrue((count = Message.GetAllMessages().Count()) == 2, String.Format("#4: count is {0}, expected {1}", count, 2));
//Message.DeleteAllMessages();
//NotificationHandler.TimerTick(DateTime.Parse("2011-03-22 08:45:59"));
//Assert.IsTrue((count = Message.GetAllMessages().Count()) == 2, String.Format("#5: count is {0}, expected {1}", count, 2));
////---- daily
//Message.DeleteAllMessages(); LastProcessTime.Reset();
//NotificationHandler.TimerTick(DateTime.Parse("2011-03-23 00:59:59"));
//Assert.IsTrue((count = Message.GetAllMessages().Count()) == 2, String.Format("#6: count is {0}, expected {1}", count, 2));
//Message.DeleteAllMessages(); LastProcessTime.Reset();
//NotificationHandler.TimerTick(DateTime.Parse("2011-03-23 01:00:00"));
//Assert.IsTrue((count = Message.GetAllMessages().Count()) == 4, String.Format("#7: count is {0}, expected {1}", count, 4));
//---- weekly
Message.DeleteAllMessages(); LastProcessTime.Reset();
Debug.WriteLine("@#$Test> **** weekly 1");
NotificationHandler.TimerTick(DateTime.Parse("2011-03-29 00:59:59"));
Assert.IsTrue((count = Message.GetAllMessages().Count()) == 2, String.Format("#8: count is {0}, expected {1}", count, 2));
Message.DeleteAllMessages(); LastProcessTime.Reset();
Debug.WriteLine("@#$Test> **** weekly 2");
NotificationHandler.TimerTick(DateTime.Parse("2011-03-29 01:00:00"));
Assert.IsTrue((count = Message.GetAllMessages().Count()) == 6, String.Format("#9: count is {0}, expected {1}", count, 6));
//---- monthly
Message.DeleteAllMessages(); LastProcessTime.Reset();
Debug.WriteLine("@#$Test> **** monthly 1");
NotificationHandler.TimerTick(DateTime.Parse("2011-04-22 00:59:59"));
Assert.IsTrue((count = Message.GetAllMessages().Count()) == 2, String.Format("#10: count is {0}, expected {1}", count, 2));
Message.DeleteAllMessages(); LastProcessTime.Reset();
Debug.WriteLine("@#$Test> **** monthly 2");
NotificationHandler.TimerTick(DateTime.Parse("2011-04-22 01:00:00"));
Assert.IsTrue((count = Message.GetAllMessages().Count()) == 6, String.Format("#11: count is {0}, expected {1}", count, 6));
}