예제 #1
0
        public void IgnoreDisabledDataItems()
        {
            AddressBookEntry entry = new AddressBookEntry();

            entry.FirstName = "John";
            entry.LastName  = "Doe";
            entry.Data.Add(new EntryDataItem()
            {
                Identifier = LoopEntryObject.TypeId, IsEnabled = true, Data = new LoopEntryObject()
                {
                    Loop = "123"
                }
            });
            // This item shall be ignored when retrieving all data items.
            entry.Data.Add(new EntryDataItem()
            {
                Identifier = LoopEntryObject.TypeId, IsEnabled = false, Data = new LoopEntryObject()
                {
                    Loop = "i'm being ignored"
                }
            });

            var result = entry.GetDataItems <LoopEntryObject>(LoopEntryObject.TypeId).ToList();

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("123", result[0].Loop);
        }
예제 #2
0
        bool IAddressFilter.QueryAcceptEntry(Operation operation, AddressBookEntry entry)
        {
            if (operation.Loops.Count == 0)
            {
                return true;
            }

            IEnumerable<LoopEntryObject> leo = entry.GetDataItems<LoopEntryObject>(LoopEntryObject.TypeId);
            IEnumerable<string> loops = leo.Select(eo => eo.Loop);

            return loops.Intersect(operation.Loops).Any();
        }
        public void IgnoreDisabledDataItems()
        {
            AddressBookEntry entry = new AddressBookEntry();
            entry.FirstName = "John";
            entry.LastName = "Doe";
            entry.Data.Add(new EntryDataItem() { Identifier = LoopEntryObject.TypeId, IsEnabled = true, Data = new LoopEntryObject() { Loop = "123" } });
            // This item shall be ignored when retrieving all data items.
            entry.Data.Add(new EntryDataItem() { Identifier = LoopEntryObject.TypeId, IsEnabled = false, Data = new LoopEntryObject() { Loop = "i'm being ignored" } });

            var result = entry.GetDataItems<LoopEntryObject>(LoopEntryObject.TypeId).ToList();
            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("123", result[0].Loop);
        }