Пример #1
0
        public void Predicates()
        {
            if (Runtime.Arch == Arch.DEVICE)
            {
                Assert.Inconclusive("defaults are different on devices");
            }

            var store = new EKEventStore(EKEntityMask.Reminder);
            var rem   = EKReminder.Create(store);

            rem.Calendar = store.DefaultCalendarForNewReminders;

            NSError error;

            Assert.IsTrue(store.SaveReminder(rem, true, out error), "SaveReminder");

            var  predicate = store.PredicateForIncompleteReminders(null, null, new [] { rem.Calendar });
            var  mre       = new ManualResetEvent(false);
            bool found     = false;

            store.FetchReminders(predicate, l => {
                found = l.Any(ll => ll.ClassHandle == rem.ClassHandle);
                mre.Set();
            });

            Assert.IsTrue(mre.WaitOne(3000), "#1");
            Assert.IsTrue(found, "#2");

            mre.Reset();
            predicate = store.PredicateForReminders(null);

            store.FetchReminders(predicate, l => mre.Set());
            Assert.IsTrue(mre.WaitOne(3000), "#10");

            mre.Reset();
            predicate = store.PredicateForCompleteReminders(null, null, null);

            store.FetchReminders(predicate, l => mre.Set());
            Assert.IsTrue(mre.WaitOne(3000), "#20");

            Assert.IsTrue(store.RemoveReminder(rem, true, out error), "RemoveReminder");
        }