public void Check_That_Reminder_Calls_Internal_Delegate() { var reminderStorage = new ReminderStorage(); using (var reminderDomain = new ReminderDomain( reminderStorage, TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(100))) { bool delegateWasCalled = false; reminderDomain.SendReminder += (reminder) => { delegateWasCalled = true; }; reminderDomain.AddReminder( new AddReminderModel { Date = DateTimeOffset.Now }); reminderDomain.Run(); Thread.Sleep(300); Assert.IsTrue(delegateWasCalled); } }
public void Check_That_On_SendReminder_OK_SendingSuccedded_Event_Raised() { var reminderStorage = new ReminderStorage(); using (var reminderDomain = new ReminderDomain( reminderStorage, TimeSpan.FromMilliseconds(100), TimeSpan.FromMilliseconds(100))) { bool eventHandlerCalled = false; reminderDomain.SendingSucceded += (s, e) => { eventHandlerCalled = true; }; reminderDomain.AddReminder( new AddReminderModel { Date = DateTimeOffset.Now }); reminderDomain.Run(); Thread.Sleep(300); Assert.IsTrue(eventHandlerCalled); } }
public void Awaiting_Item_Changes_Status_to_ReadyToSend_After_Checking_Period() { var storage = new InMemoryReminderStorage(); using var domain = new ReminderDomain( storage, TimeSpan.FromMilliseconds(50)); var item = new ReminderItem( DateTimeOffset.Now, "Hello world", "testContact007"); domain.AddReminder(item); // run domain.Run(); // check the results System.Threading.Thread.Sleep(50); var actualItem = storage.Get(item.Id); Assert.IsNotNull(actualItem); Assert.AreEqual(ReminderItemStatus.ReadyToSend, actualItem.Status); }
static void Main(string[] args) { var storage = new InMemoryReminderStorage(); var domain = new ReminderDomain(storage); var item = new ReminderItem( DateTimeOffset.Now, "Hello world", "testContact007"); //storage.Add(item); //var itemFromStorage = storage.Get(item.Id); domain.AddReminder(item); domain.Run(); //Console.WriteLine(itemFromStorage.Message); }