示例#1
0
        static void Main()
        {
            var    config = new ConfigurationBuilder().AddJsonFile("settings.json").Build();
            string token  = config["TelegramToken"];
            string apiUrl = config["RemindersWebApiUrl"];
            //botID = "1467408776"

            var storage = new ReminderStorageWebApiClient(apiUrl);

            var sender   = new TelegramReminderSender(token);
            var receiver = new TelegramReminderReceiver(token);

            using var domain = new ReminderDomain(storage, receiver, sender, TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(1));

            domain.SendingSucceeded += Domain_SendingSucceeded;
            domain.SendingFailed    += Domain_SendingFailed;
            domain.ParsingFailed    += Domain_ParsingFailed;
            domain.AddingSucceeded  += Domain_AddingSucceeded;
            domain.AddingFailed     += Domain_AddingFailed;

            domain.Run();

            Console.WriteLine("Domain logic running...");
            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Telegram Bot Application!");

            var storage = new InMemoryReminderStorage();

            string token = "633428988:AAHLW_LaS7A47PDO2I8sbLkIIM9L0joPOSQ";

            IWebProxy proxy = new HttpToSocks5Proxy(
                "proxy.golyakov.net", 1080);

            var receiver = new TelegramReminderReceiver(token, proxy);

            var domain = new ReminderDomain(storage, receiver);
            var sender = new TelegramReminderSender(token, proxy);


            domain.SendReminder = (ReminderItem ri) =>
            {
                sender.Send(ri.ContactId, ri.Message);
            };

            domain.MessageReceived          += Domain_MessageReceived;
            domain.MessageParsingSuccedded  += Domain_MessageParsingSuccedded;
            domain.MessageParsingFailed     += Domain_MessageParsingFailed;
            domain.AddingToStorageSuccedded += Domain_AddingToStorageSuccedded;
            domain.AddingToStorageFailed    += Domain_AddingToStorageFailed;

            domain.Run();

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
示例#3
0
        public void Method_Run_Should_Update_Ready_To_Send_Reminders_To_Status_Ready_From_Awiating()
        {
            var storage = new InMemoryReminderStorage();

            storage.Add(DateTimeOffset.Now, null, null, ReminderItemStatus.Awaiting);

            //создает класс содержащий  интерфейс
            var mockReceiver = new Mock <IReminderReceiver>();
            var fakeReceiver = mockReceiver.Object;


            using (var domain = new ReminderDomain(
                       storage,
                       fakeReceiver,
                       TimeSpan.FromMilliseconds(50),
                       TimeSpan.FromSeconds(1)))
            {
                domain.Run();
                System.Threading.Thread.Sleep(200);
            }

            var readyList = storage.Get(ReminderItemStatus.Ready);

            Assert.IsNotNull(readyList);
            Assert.AreEqual(1, readyList.Count);
        }
        public void Check_That_On_SendReminder_Exception_SendingFailed_Event_Raised()
        {
            var reminderStorage = new ReminderStorage();
            var reminderDomain  = new ReminderDomain(reminderStorage);

            reminderDomain.SendReminder += (reminder) =>
            {
                throw new Exception();
            };
            bool eventHandlerCalled = false;

            reminderDomain.SendingFailed += (s, e) =>
            {
                eventHandlerCalled = true;
            };
            reminderDomain.Add(new AddReminderModel
            {
                Date = DateTimeOffset.Now
            });

            reminderDomain.Run();

            Thread.Sleep(2000);

            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);
        }
示例#6
0
        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()
        {
            //preparing

            var storage = new InMemoryReminderStorage();

            var sender   = new TelegramReminderSender("1467408776:AAGSGszyTCYYCTWTKu4PL_it029uC8X8hbs");
            var receiver = new TelegramReminderReceiver("1467408776:AAGSGszyTCYYCTWTKu4PL_it029uC8X8hbs");

            using var domain = new ReminderDomain(storage, receiver, sender, TimeSpan.FromMilliseconds(50), TimeSpan.FromMilliseconds(50));

            var item = new ReminderItem(DateTimeOffset.Now, "Hello World!", "TestContact"); //addReminderModel

            //domain.AddReminder(item); //Model was here

            // run

            domain.Run();

            //Check the result

            System.Threading.Thread.Sleep(50);

            var actualItem = storage.Get(item.Id);

            Assert.IsNotNull(actualItem);
            Assert.AreEqual(ReminderItemStatus.ReadyToSend, actualItem.Status);
        }
示例#8
0
        public void Method_Run_Should_Call_Succeedded_Event_When_Sending_Thrown_Exception()
        {
            var storage = new InMemoryReminderStorage();

            storage.Add(DateTimeOffset.Now, null, null, ReminderItemStatus.Awaiting);

            bool succeededEventCalled = false;

            //создает класс содержащий  интерфейс
            var mockReceiver = new Mock <IReminderReceiver>();
            var fakeReceiver = mockReceiver.Object;

            using (var domain = new ReminderDomain(
                       storage,
                       fakeReceiver,
                       TimeSpan.FromMilliseconds(50),
                       TimeSpan.FromSeconds(50)))
            {
                domain.SendReminder += (reminder) => { };

                domain.SendingSucceeded += (s, e) =>
                {
                    succeededEventCalled = true;
                };

                domain.Run();
                System.Threading.Thread.Sleep(1200);
            }

            Assert.IsTrue(succeededEventCalled);
        }
示例#9
0
        static void Main(string[] args)
        {
            Console.WriteLine("Telegram Bot Application!");

            var       storage = new InMemoryReminderStorage();
            var       domain  = new ReminderDomain(storage);
            IWebProxy proxy   = new HttpToSocks5Proxy("proxy.golyakov.net", 1080);
            string    token   = "874002335:AAHCWlQVHGvM6if784HJ0rHTfcUg7SbSR5s";

            var sender   = new TelegramReminderSender(token, proxy);
            var receiver = new TelegramReminderReceiver(token, proxy);


            receiver.MessageReceived += (s, e) =>
            {
                Console.WriteLine($"Message from contact '{e.ContactId}' with text '{e.Message}'");
                //add new reminderitem to the storage
                var parsedMessage = MessageParser.Parse(e.Message);
                var item          = new ReminderItem(parsedMessage.Date, parsedMessage.Message, e.ContactId);

                storage.Add(item);
            };

            receiver.Run();

            domain.SendReminder = (ReminderItem ri) =>
            {
                sender.Send(ri.ContactId, ri.Message);
            };

            domain.Run();

            Console.WriteLine("Press any key to continue");
            Console.ReadKey();
        }
示例#10
0
        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 Method_Run_Should_Call_Succeedded_Event_When_Sending_Thrown_Exception()
        {
            var storage = new InMemoryReminderStorage();

            storage.Add(new ReminderItem(DateTimeOffset.Now, null, null));

            bool succeededEventCalled = false;

            using (var domain = new ReminderDomain(
                       storage,
                       TimeSpan.FromMilliseconds(50),
                       TimeSpan.FromSeconds(50)))
            {
                domain.SendReminder += (reminder) => { };

                domain.SendingSucceeded += (s, e) =>
                {
                    succeededEventCalled = true;
                };

                domain.Run();
                System.Threading.Thread.Sleep(1200);
            }

            Assert.IsTrue(succeededEventCalled);
        }
        public void Method_Run_Should_Call_SendReminder_Method_For_Particular_Item()
        {
            var storage = new InMemoryReminderStorage();

            storage.Add(new ReminderItem(DateTimeOffset.Now, "test message", null));

            bool sendReminderDelegateCalled = false;

            using (var domain = new ReminderDomain(
                       storage,
                       TimeSpan.FromMilliseconds(50),
                       TimeSpan.FromSeconds(50)))
            {
                domain.SendReminder += (ReminderItem r) =>
                {
                    if (r.Message == "test message")
                    {
                        sendReminderDelegateCalled = true;
                    }
                };

                domain.Run();
                System.Threading.Thread.Sleep(1200);
            }

            Assert.IsTrue(sendReminderDelegateCalled);
        }
示例#13
0
        public void Method_Run_Should_Failed_Event_When_Sending_Thrown_Exception()
        {
            var storage = new InMemoryReminderStorage();

            storage.Add(new ReminderItem(DateTimeOffset.Now, null, null));

            bool failedEventCalled = false;

            using (var domain = new ReminderDomain(
                       storage,
                       TimeSpan.FromMilliseconds(50),
                       TimeSpan.FromSeconds(50)))
            {
                //do test
                domain.Run();
                domain.SendReminder += (reminder) =>
                {
                    throw new Exception("test Exception");
                };

                domain.SendingFailed += (s, e) =>
                {
                    if (e.SendingException.Message == "test exception")
                    {
                        failedEventCalled = true;
                    }
                };

                Thread.Sleep(1200);
            }
            //check result
            Assert.IsTrue(failedEventCalled);
        }
示例#14
0
        public void Method_Run_Should_Call_Failed_Event_When_Sending_Throw_Exception()
        {
            var storage = new InMemoryReminderStorage();

            storage.Add(new ReminderItem(DateTimeOffset.Now, null, null));
            bool failedEventCalled = false;

            using (var domain = new ReminderDomain(storage, TimeSpan.FromMilliseconds(50), TimeSpan.FromSeconds(50)))
            {
                domain.SendReminder += (reminder) =>
                {
                    throw new Exception("test exception");
                };
                domain.SendingFailed += (s, e) =>
                {
                    if (e.SendingException.Message == "test exception")
                    {
                        failedEventCalled = true;
                    }
                };

                domain.Run();
                System.Threading.Thread.Sleep(200);
            }

            var readyList = storage.Get(ReminderItemStatus.Ready);

            Assert.IsNotNull(readyList);
            Assert.AreEqual(1, storage.Get(ReminderItemStatus.Ready).Count);
        }
示例#15
0
        public void When_SendReminder_OK_SendingSuccedded_Event_Raised()
        {
            var reminderStorage = new InMemoryReminderStorage();

            using (var reminderDomain = new ReminderDomain(
                       reminderStorage,
                       receiverMock.Object,
                       senderMock.Object,
                       TimeSpan.FromMilliseconds(100),
                       TimeSpan.FromMilliseconds(100)))
            {
                bool eventHandlerCalled = false;

                reminderDomain.SendingSucceded += (s, e) =>
                {
                    eventHandlerCalled = true;
                };

                reminderStorage.Add(new Storage.Core.ReminderItem
                {
                    Date = DateTimeOffset.Now
                });

                reminderDomain.Run();

                Thread.Sleep(300);

                Assert.IsTrue(eventHandlerCalled);
            }
        }
示例#16
0
        public void Call_FailedEvent()
        {
            //var item = new ReminderItem();
            var storage = new InMemoryReminderStorage();

            storage.Add(new ReminderItem(DateTimeOffset.Now, null, null));

            bool failedEventCalled = false;

            using (var domain = new ReminderDomain(
                       storage,
                       TimeSpan.FromMilliseconds(50),
                       TimeSpan.FromSeconds(50)))
            {
                //т.к. таймеры в домене отрабатывают раз в секунду, надо подождать пару секунд

                domain.SendReminder += (r) =>
                {
                    throw new Exception("Тестовое исключение");
                };
                domain.SendingFailed += (s, e) =>
                {
                    if (e.SendingException.Message == "Тестовое исключение")
                    {
                        failedEventCalled = true;
                    }
                };

                domain.Run();
                System.Threading.Thread.Sleep(1200);
            }

            //проверки
            Assert.IsTrue(failedEventCalled);
        }
        public void When_Send_OK_SendingSucceeded_Event_Raised()
        {
            var item = new ReminderItem {
                Date = DateTimeOffset.Now
            };
            var storage = new InMemoryReminderStorage();

            storage.Add(item);

            var senderMock   = new Mock <IReminderSender>();
            var receiverMock = new Mock <IReminderReceiver>();

            using var domain = new ReminderDomain(
                      storage,
                      senderMock.Object /* IReminderSender */,
                      receiverMock.Object /* IReminderReceiver */,
                      TimeSpan.FromMilliseconds(50),
                      TimeSpan.FromMilliseconds(50));

            bool eventHandlerCalled = false;

            domain.SendingSucceeded += (s, e) =>
            {
                eventHandlerCalled = true;
            };

            domain.Run();

            Thread.Sleep(150);

            Assert.IsTrue(eventHandlerCalled);
        }
示例#18
0
        public void When_Send_OK_SendingSucceededEvent_Raised()
        {
            var item = new ReminderItem {
                Date = DateTimeOffset.Now
            };
            var storage = new InMemoryReminderStorage();

            storage.Add(item);

            var senderMock = new Mock <IReminderSender>();   //"заглушка", которая зависит от интерфейса, а не класса

            using var domain = new ReminderDomain(
                      storage,
                      /*IReminderSender-объект-пустышка для тестирований*/ senderMock.Object,
                      TimeSpan.FromMilliseconds(10),
                      TimeSpan.FromMilliseconds(10));

            bool eventHandlerCalled = false;

            domain.SendingSucceeded += (s, e) =>
            {
                eventHandlerCalled = true;
            };

            domain.Run();
            Thread.Sleep(150);
            Assert.IsTrue(eventHandlerCalled);
        }
示例#19
0
        static void Main(string[] args)
        {
            const string token = "633428988:AAHLW_LaS7A47PDO2I8sbLkIIM9L0joPOSQ";

            var storage = new InMemoryReminderStorage();
            //var storage = new ReminderStorageWebApiClient("URL");
            var sender   = new TelegramReminderSender(token);
            var receiver = new TelegramReminderReceiver(token);

            using var domain = new ReminderDomain(
                      storage,
                      receiver,
                      sender,
                      TimeSpan.FromSeconds(1),
                      TimeSpan.FromSeconds(1));

            domain.SendingSucceeded += Domain_SendingSucceeded;
            domain.SendingFailed    += DomainOnSendingFailed;
            domain.ParsingFailed    += Domain_ParsingFailed;
            domain.AddingSucceeded  += Domain_AddingSucceeded;
            domain.AddingFailed     += Domain_AddingFailed;

            domain.Run();

            Console.WriteLine("Domain logic running... (press any key to exit)");
            Console.ReadKey();
        }
示例#20
0
        public void When_Send_ThrowException_FailEvent_Raised()
        {
            var item = new ReminderItem {
                Date = DateTimeOffset.Now
            };
            var storage = new InMemoryReminderStorage();

            storage.Add(item);

            var senderMock = new Mock <IReminderSender>();   //"заглушка", которая зависит от интерфейса, а не класса

            senderMock
            .Setup(x => x.Send(It.IsAny <ReminderItem>()))    //It.IsAny -- cоздаст любой объект
            // .Callback(() => {  });
            .Throws(new Exception("Sending Failed Exception"));
            using var domain = new ReminderDomain(
                      storage,
                      /*IReminderSender-объект-пустышка для тестирований*/ senderMock.Object,
                      TimeSpan.FromMilliseconds(10),
                      TimeSpan.FromMilliseconds(10));

            bool eventHandlerCalled = false;

            domain.SendingFailed += (s, e) =>
            {
                eventHandlerCalled = true;
            };

            domain.Run();
            Thread.Sleep(150);
            Assert.IsTrue(eventHandlerCalled);
        }
示例#21
0
        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 ReminderDomain Create(ReminderDomain reminder)
        {
            reminder.Id = Guid.NewGuid().ToString();
            var entity = this._mapper.Map <ReminderEntity>(reminder);

            this._context.Reminder.InsertOne(entity);
            return(reminder);
        }
示例#23
0
        static void Main(string[] args)
        {
            // read configuration

            IConfiguration config = new ConfigurationBuilder()
                                    .AddJsonFile("appsettings.json", true, true)
                                    .Build();

            var storageWebApiUrl         = config["storageWebApiUrl"];
            var telegramBotApiToken      = config["telegramBot.ApiToken"];
            var telegramBotUseProxy      = bool.Parse(config["telegramBot.UseProxy"]);
            var telegramBotProxyHost     = config["telegramBot.Proxy.Host"];
            var telegramBotProxyPort     = int.Parse(config["telegramBot.Proxy.Port"]);
            var telegramBotProxyLogin    = config["telegramBot.Proxy.Login"];
            var telegramBotProxyPassword = config["telegramBot.Proxy.Password"];

            // create objects for DI
            var reminderStorage = new ReminderStorageWebApiClient(storageWebApiUrl);

            IWebProxy telegramProxy = null;

            if (telegramBotUseProxy)
            {
                telegramProxy = new HttpToSocks5Proxy(
                    telegramBotProxyHost,
                    telegramBotProxyPort,
                    telegramBotProxyLogin,
                    telegramBotProxyPassword);
            }

            var reminderReceiver = new TelegramReminderReceiver(telegramBotApiToken, telegramProxy);
            var reminderSender   = new TelegramReminderSender(telegramBotApiToken, telegramProxy);

            // create and setup domain logic object

            var reminderDomain = new ReminderDomain(
                reminderStorage,
                reminderReceiver,
                reminderSender);

            reminderDomain.AddingSuccedded += ReminderDomain_AddingSuccedded;
            reminderDomain.SendingSucceded += ReminderDomain_SendingSucceded;
            reminderDomain.SendingFailed   += ReminderDomain_SendingFailed;

            // run

            reminderDomain.Run();

            string hello = reminderReceiver.GetHelloFromBot();

            Console.WriteLine(
                $"Reminder application is running...\n" +
                $"{hello}\n" +
                "Press [Enter] to shutdown.");

            Console.ReadLine();
        }
示例#24
0
        public void Check_That_Add_Method_Adds_AddReminderModel_Into_Storage()
        {
            var reminderStorage = new ReminderStorage();
            var reminderDomain  = new ReminderDomain(reminderStorage);

            reminderDomain.Add(
                new AddReminderModel()
            {
                Date = DateTimeOffset.Now
            });

            Assert.AreEqual(1, reminderStorage.Count);
        }
示例#25
0
        public void Method_Run_Should_Update_to_send_reminders_to_send_reminders_to()
        {
            var storage = new InMemoryReminderStorage();

            storage.Add(new ReminderItem(DateTimeOffset.Now, null, null));
            using (var domain = new ReminderDomain(storage, TimeSpan.FromMilliseconds(50), TimeSpan.FromSeconds(1)))
            {
                domain.Run();
                System.Threading.Thread.Sleep(200);
            }

            var readyList = storage.Get(ReminderItemStatus.Ready);

            Assert.IsNotNull(readyList);
            Assert.AreEqual(1, storage.Get(ReminderItemStatus.Ready).Count);
        }
示例#26
0
        static void Main(string[] args)
        {
            Console.WriteLine("Telegram Bot Aplication!");

            var storage = new InMemoryReminderStorage();
            var domain  = new ReminderDomain(storage);

            string    token = "961862676:AAGPTkcJqLhOkgX7KOTOaEUe3Y3bjvIWJ24";
            IWebProxy proxy = new HttpToSocks5Proxy(
                "proxy.golyakov.net", 1080);

            var sender   = new TelegramReminderSender(token, proxy);
            var receiver = new TelegramReminderReceiver(token, proxy);

            receiver.MessageReceived += (s, e) =>
            {
                Console.WriteLine($"Message received from contact id '{e.ContactId}' with text '{e.Message}'");

                //add new ReminderItem to the storage
                try
                {
                    var parsedMessage = MessageParser.Parse(e.Message);

                    var item = new ReminderItem(
                        parsedMessage.Date,
                        parsedMessage.Message,
                        e.ContactId);
                    storage.Add(item);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Полученное не соответствует формату! \n {ex.Message}");
                }
            };

            receiver.Run();

            domain.SendReminder = (ReminderItem ri) =>
            {
                sender.Send(ri.ContactId, ri.Message);
            };

            domain.Run();

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
示例#27
0
        static void Main(string[] args)
        {
            Console.WriteLine("Telegram Bot Application!");

            var storage = new InMemoryReminderStorage();
            var domain  = new ReminderDomain(storage);

            string    token = "633428988:AAHLW_LaS7A47PDO2I8sbLkIIM9L0joPOSQ";
            IWebProxy proxy = new HttpToSocks5Proxy(
                "proxy.golyakov.net", 1080);

            var sender   = new TelegramReminderSender(token, proxy);
            var receiver = new TelegramReminderReceiver(token, proxy);

            receiver.MessageReceived += (s, e) =>
            {
                Console.WriteLine($"Message received from contact ID {e.ContactId} with text '{e.Message}'");

                try
                {
                    var parsedMessage = MessageParser.Parse(e.Message);

                    var item = new ReminderItem(
                        parsedMessage.Date,
                        parsedMessage.Message,
                        e.ContactId);

                    storage.Add(item);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"The format of the message is wrong!\n{ex.Message}");
                }
            };

            receiver.Run();

            domain.SendReminder = (ReminderItem ri) =>
            {
                sender.Send(ri.ContactId, ri.Message);
            };

            domain.Run();

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
        public void Check_That_Remider_Sending_Succeded()
        {
            var remiderStorage = new RemiderDomainTests();

            ReminderDomain = new ReminderDomain(remiderStorage);

            bool delegateWasCalled = true;

            RemiderDomain.SendReminder += (s, e) =>
            {
                delegateWasCalled = true;
            }



            remiderDomain.Run();
        }
示例#29
0
        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);
        }
示例#30
0
        static void Main(string[] args)
        {
            const string token = "889472492: AAEbc0JJ3euv6nCSdLrjTZn4E4Z6tXN0JXQ";

            var receiver = new TelegramReminderReceiver(token);
            var sender   = new TelegramReminderSender(token);
            var storage  = new InMemoryReminderStorage();

            var domain = new ReminderDomain(storage, receiver, sender);

            domain.AddingSucceded  += Domain_AddingSucceded;
            domain.SendingSucceded += Domain_SendingSucceded;
            domain.SendingFailed   += Domain_SendingFailed;

            domain.Run();

            Console.ReadKey();
        }