Exemplo n.º 1
0
        private static void DoesNotForceLoad(ObservableCollection <Contact> contacts, Func <SimpleIterator <Contact>, object> action)
        {
            var sourceCollection = new SourceCollection(contacts);

            Assert.AreEqual(0, sourceCollection.GetEnumeratorCalls);

            var contactIterator = new SimpleIterator <Contact>(sourceCollection.AsBindable());

            Assert.AreEqual(0, sourceCollection.GetEnumeratorCalls);

            action(contactIterator);
            Assert.AreEqual(0, sourceCollection.GetEnumeratorCalls);

            contactIterator.Dispose();
            Assert.AreEqual(0, sourceCollection.GetEnumeratorCalls);
        }
Exemplo n.º 2
0
        public void IteratorWithDepenedenciesDoesNotEnumerateSourceUntilResultIsEnumerated()
        {
            var sourceCollection = new SourceCollection(With.Inputs(Tom, Tim, Jack));

            Assert.AreEqual(0, sourceCollection.GetEnumeratorCalls);

            var contactIterator = new SimpleIterator <Contact>(sourceCollection.AsBindable());

            Assert.AreEqual(0, sourceCollection.GetEnumeratorCalls);

            contactIterator.AcceptDependency(new ItemDependencyDefinition("Name"));
            Assert.AreEqual(0, sourceCollection.GetEnumeratorCalls);

            foreach (var c in contactIterator)
            {
            }
            Assert.AreEqual(1, sourceCollection.GetEnumeratorCalls);

            contactIterator.Dispose();
            Assert.AreEqual(1, sourceCollection.GetEnumeratorCalls);
        }