public AddingFailedEventArgs( AddReminderModel reminder, Exception exception) { Reminder = reminder; Exception = exception; }
public void Check_That_SendReadyReminders_Method_Turns_Ready_Status_Into_Failed_If_Sending_Failed() { var reminderStorage = new ReminderStorage(); var reminderDomain = new ReminderDomain(reminderStorage); var reminderModel = new AddReminderModel() { Date = DateTimeOffset.Now }; reminderDomain.SendReminder += r => { throw new Exception(); }; reminderDomain.Add(reminderModel); reminderDomain.CheckAwaitingReminders(null); reminderDomain.SendReadyReminders(null); var status = reminderStorage.Get(1)[0].Status; Assert.AreEqual( Storage.Core.ReminderItemStatus.Failed, status); }
public void Check_That_All_Propeties_Set() { string expectedContactId = "+71234567890"; DateTimeOffset expectedDate = DateTimeOffset.Now; string expectedMessage = "Hello"; var addReminderModel = new AddReminderModel() { ContactId = expectedContactId, Date = expectedDate, Message = expectedMessage }; Assert.AreEqual(expectedContactId, addReminderModel.ContactId); Assert.AreEqual(expectedDate, addReminderModel.Date); Assert.AreEqual(expectedMessage, addReminderModel.Message); }
public void Check_That_Added_ReminderItem_Has_Awaiting_Status() { var reminderStorage = new ReminderStorage(); var reminderDomain = new ReminderDomain(reminderStorage); var reminderModel = new AddReminderModel() { Date = DateTimeOffset.Now + TimeSpan.FromMilliseconds(1000) }; reminderDomain.Add(reminderModel); var status = reminderStorage.Get(1)[0].Status; Assert.AreEqual( Storage.Core.ReminderItemStatus.Awaiting, status); }
public void Check_That_CheckAwaitingReminders_Method_Turns_Awaiting_Status_Into_Ready() { var reminderStorage = new ReminderStorage(); var reminderDomain = new ReminderDomain(reminderStorage); var reminderModel = new AddReminderModel() { Date = DateTimeOffset.Now }; reminderDomain.Add(reminderModel); reminderDomain.CheckAwaitingReminders(null); var status = reminderStorage.Get(1)[0].Status; Assert.AreEqual( Storage.Core.ReminderItemStatus.Ready, status); }
static void Main(string[] args) { const string token = "1467408776:AAGSGszyTCYYCTWTKu4PL_it029uC8X8hbs"; //botID = "1467408776" var storage = new InMemoryReminderStorage(); var sender = new TelegramReminderSender(token); var receiver = new TelegramReminderReceiver(token); using var domain = new ReminderDomain(storage, receiver, sender, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));//Dependency injection var addReminderModel = new AddReminderModel(DateTimeOffset.Now.AddSeconds(2), "Hello World!", "1467408776"); domain.SendingSucceeded += Domain_SendingSucceeded; domain.SendingFailed += Domain_SendingFailed; //receiver.MessageReceived += ; //domain.AddReminderModel(addReminderModel); domain.Run(); Console.WriteLine("Domain logic running..."); Console.ReadKey(); }
public AddingSucceededEventArgs(AddReminderModel reminder) { Reminder = reminder; }