Пример #1
0
        public void Update_Updates_All_Properties_Of_ReminderItem_With_Given_Id_If_It_Exists()
        {
            var original = new ReminderItem
            {
                Id        = Guid.Parse("00000000-0000-0000-0000-111111111111"),
                Date      = DateTimeOffset.Parse("2001-01-01 01:01:01+0000"),
                Message   = "Awaiting",
                ContactId = "1",
                Status    = ReminderItemStatus.Awaiting
            };
            var storage = new InMemoryReminderStorage();

            storage._reminders.Add(original.Id, original.ToReminderItemRestricted());

            var updated = new ReminderItem
            {
                Id        = Guid.Parse("00000000-0000-0000-0000-111111111111"),
                Date      = DateTimeOffset.Parse("2002-02-02 02:02:02+0000"),
                Message   = "ReadyToSend",
                ContactId = "2",
                Status    = ReminderItemStatus.ReadyToSend
            };

            storage.Update(updated);

            var actual = storage.Get(Guid.Parse("00000000-0000-0000-0000-111111111111"));

            Assert.IsNotNull(actual);
            Assert.AreEqual(updated.Id, actual.Id);
            Assert.AreEqual(updated.Date, actual.Date);
            Assert.AreEqual(updated.Message, actual.Message);
            Assert.AreEqual(updated.ContactId, actual.ContactId);
            Assert.AreEqual(updated.Status, actual.Status);
        }
        public void Update(ReminderItem reminderItem)
        {
            if (!_reminders.ContainsKey(reminderItem.Id))
            {
                throw new InvalidOperationException("Could not find ReminderItem with the ID specified.");
            }

            _reminders[reminderItem.Id] = reminderItem.ToReminderItemRestricted();
        }