Beispiel #1
0
        public void RemoveAllTest()
        {
            var storage = new InMemoryStorage();
            var item    = new ReminderItem(Guid.NewGuid(), DateTimeOffset.Now, "Test ALO", 0);

            storage.Add(item.Id, item);
            var item1 = new ReminderItem(Guid.NewGuid(), DateTimeOffset.Now, "Test ALO", 0);

            storage.Add(item1.Id, item1);
            var item2 = new ReminderItem(Guid.NewGuid(), DateTimeOffset.Now, "Test ALO", 0);

            storage.Add(item2.Id, item2);
            storage.RemoveAll();
            var count = storage.GetList().Count;

            Assert.AreEqual(count, 0);
        }
        public void ClearTest()
        {
            var memoryStorage = new InMemoryStorage();
            var item          = new ReminderItem();
            var id            = Guid.NewGuid();

            memoryStorage.Add(id, item);
            var id2   = Guid.NewGuid();
            var item2 = new ReminderItem();

            memoryStorage.Add(id2, item2);

            Assert.AreEqual(memoryStorage.Count(), 2);

            memoryStorage.Clear();

            Assert.AreEqual(memoryStorage.Count(), 0);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            InMemoryStorage _storage    = new InMemoryStorage();
            Guid            _item1_guid = Guid.NewGuid();

            Thread.Sleep(1000);
            Guid         _item2_guid = Guid.NewGuid();
            ReminderItem item1       = new ReminderItem(_item1_guid, DateTime.Now + TimeSpan.FromSeconds(6), "Do job", 0);

            Console.WriteLine(DateTime.Now.ToString("yyyy-MMMM-ddThh:mm:sss.ffff"));
            Thread.Sleep(8000);
            Console.WriteLine(DateTime.Now.ToString("yyyy-MMMM-ddThh:mm:sss.ffff"));
            ReminderItem item2 = new ReminderItem(_item2_guid, DateTime.Now + TimeSpan.FromMinutes(58.9), "123", 546234);

            _storage.Add(item1.Id, item1);
            _storage.Add(item2.Id, item2);
            Console.ReadLine();
        }
Beispiel #4
0
        public void GetTest()
        {
            var storage = new InMemoryStorage();
            var item    = new ReminderItem(Guid.NewGuid(), DateTimeOffset.Now, "Test ALO", 0);

            storage.Add(item.Id, item);
            var getItem = storage.Get(item.Id);

            Assert.AreEqual(item, getItem);
        }
        public void AddTest()
        {
            var memoryStorage = new InMemoryStorage();
            var item          = new ReminderItem();
            var id            = Guid.NewGuid();

            memoryStorage.Add(id, item);

            Assert.AreEqual(memoryStorage.Count(), 1);
        }
        public void GetReminderItemException()
        {
            var memoryStorage = new InMemoryStorage();
            var item          = new ReminderItem();
            var id            = Guid.NewGuid();

            memoryStorage.Add(id, item);

            var getItem = memoryStorage.Get(Guid.NewGuid());
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            InMemoryStorage   storage  = new InMemoryStorage();
            TelegramSender    sender   = new TelegramSender("1028662742:AAFo3RAhaGwvh2zlxVEXGTFrOeufbnOZ9z4");
            TelegrammReciever reciever = new TelegrammReciever("1028662742:AAFo3RAhaGwvh2zlxVEXGTFrOeufbnOZ9z4");
            Domain            d        = new Domain(storage, sender, reciever, 50);

            d.OnSuccesAdd  += D_OnSuccesAdd;
            d.OnFailedSend += D_OnFailedSend;
            d.OnSuccesSend += D_OnSuccesSend;
            reciever.OnFailedMessageRecieved += Reciever_OnFailedMessageRecieved;

            d.Start();

            while (true)
            {
                string msg = Console.ReadLine();
                if (msg == "/stop")
                {
                    d.Stop();
                    Console.WriteLine("Прослушивание завершено");
                    break;
                }
                else
                {
                    switch (msg)
                    {
                    case "/awaiting":
                        var awaitingItems = storage.Get(ReminderStatus.Awaiting);
                        foreach (ReminderItem item in awaitingItems)
                        {
                            Console.WriteLine($"{item.Id};\ntimeToAlarm:\t{item.date.ToString("dd MMMM yyyy HH:mm:ss")};\nmessage:\t{item.Message}");
                        }
                        break;

                    default:
                        var id      = Guid.NewGuid();
                        var newItem = new ReminderItem {
                            Message = msg, date = DateTimeOffset.Now.AddSeconds(1), Id = id, _status = ReminderStatus.Awaiting, contactId = 778740583
                        };
                        storage.Add(id, newItem);
                        break;
                    }
                }
            }

            Console.ReadLine();
        }
        static async Task Main(string[] args)
        {
            var store = new InMemoryStorage();

            store.Add("123", new User {
                Name = "ABC", Email = "*****@*****.**", Id = "123"
            });
            Console.WriteLine(store.Get <User>("123"));

            var aggregationContext = new AggregationContext(Assembly.GetExecutingAssembly(), store);

            await aggregationContext.SendAsync <User, NameUpdate>(new NameUpdate { Name = "ABCD", Id = "123" });

            Console.WriteLine(store.Get <User>("123"));

            Console.ReadLine();
        }