Esempio n. 1
0
        public void DefaultFindByBehaviorIsAskParent()
        {
            object            o            = new object();
            IReadWriteLocator rootLocator  = new Locator();
            IReadWriteLocator childLocator = new Locator(rootLocator);

            rootLocator.Add("foo", o);

            IReadableLocator results;

            results = childLocator.FindBy(delegate
            {
                return(true);
            });

            Assert.AreEqual(1, results.Count);
        }
Esempio n. 2
0
        public void FindingByPredicateCanClimbTheTree()
        {
            object            o            = new object();
            IReadWriteLocator rootLocator  = new Locator();
            IReadWriteLocator childLocator = new Locator(rootLocator);

            rootLocator.Add("bar", o);

            IReadableLocator results;

            results = childLocator.FindBy(delegate
            {
                return(true);
            });

            Assert.AreEqual(1, results.Count);
            Assert.AreSame(o, results.Get("bar"));
        }
Esempio n. 3
0
        public void FindingByPredicateReturnsClosestResultsOnDuplicateKey()
        {
            object            o1           = new object();
            object            o2           = new object();
            IReadWriteLocator rootLocator  = new Locator();
            IReadWriteLocator childLocator = new Locator(rootLocator);

            rootLocator.Add("foo", o1);
            childLocator.Add("foo", o2);

            IReadableLocator results;

            results = childLocator.FindBy(delegate
            {
                return(true);
            });

            Assert.AreEqual(1, results.Count);
            Assert.AreSame(o2, results.Get("foo"));
        }
Esempio n. 4
0
        public void FindingByPredicateCanFindsResultsFromBothParentAndChild()
        {
            object            o            = new object();
            string            s            = "Hello world";
            IReadWriteLocator rootLocator  = new Locator();
            IReadWriteLocator childLocator = new Locator(rootLocator);

            rootLocator.Add("foo", o);
            childLocator.Add("bar", s);

            IReadableLocator results;

            results = childLocator.FindBy(delegate
            {
                return(true);
            });

            Assert.AreEqual(2, results.Count);
            Assert.AreSame(o, results.Get("foo"));
            Assert.AreSame(s, results.Get("bar"));
        }
Esempio n. 5
0
        public void CanFindByPredicate()
        {
            bool              wasCalled = false;
            object            o1        = new object();
            object            o2        = new object();
            IReadWriteLocator locator   = new Locator();

            locator.Add("foo1", o1);
            locator.Add("foo2", o2);

            IReadableLocator results;

            results = locator.FindBy(
                delegate(KeyValuePair <object, object> kvp)
            {
                wasCalled = true;
                return(kvp.Key.Equals("foo1"));
            });

            Assert.IsNotNull(results);
            Assert.IsTrue(wasCalled);
            Assert.AreEqual(1, results.Count);
            Assert.AreSame(o1, results.Get("foo1"));
        }
Esempio n. 6
0
        public void NullPredicateOnFindByThrows()
        {
            IReadWriteLocator locator = new Locator();

            locator.FindBy(null);
        }
Esempio n. 7
0
        public void BadSearchModeOnFindByThrows()
        {
            IReadWriteLocator locator = new Locator();

            locator.FindBy((SearchMode)254, delegate { return true; });
        }
Esempio n. 8
0
        public void FindingByPredicateReturnsClosestResultsOnDuplicateKey()
        {
            object o1 = new object();
            object o2 = new object();
            IReadWriteLocator rootLocator = new Locator();
            IReadWriteLocator childLocator = new Locator(rootLocator);

            rootLocator.Add("foo", o1);
            childLocator.Add("foo", o2);

            IReadableLocator results;

            results = childLocator.FindBy(
                SearchMode.Up,
                delegate(KeyValuePair<object, object> kvp)
                {
                    return true;
                });

            Assert.AreEqual(1, results.Count);
            Assert.AreSame(o2, results.Get("foo"));
        }
Esempio n. 9
0
        public void NullPredicateOnFindByThrows()
        {
            IReadWriteLocator locator = new Locator();

            locator.FindBy(null);
        }
Esempio n. 10
0
        public void FindingByPredicateCanFindsResultsFromBothParentAndChild()
        {
            object o = new object();
            string s = "Hello world";
            IReadWriteLocator rootLocator = new Locator();
            IReadWriteLocator childLocator = new Locator(rootLocator);

            rootLocator.Add("foo", o);
            childLocator.Add("bar", s);

            IReadableLocator results;

            results = childLocator.FindBy(
                SearchMode.Up,
                delegate(KeyValuePair<object, object> kvp)
                {
                    return true;
                });

            Assert.AreEqual(2, results.Count);
            Assert.AreSame(o, results.Get("foo"));
            Assert.AreSame(s, results.Get("bar"));
        }
Esempio n. 11
0
        public void FindingByPredicateCanClimbTheTree()
        {
            object o = new object();
            IReadWriteLocator rootLocator = new Locator();
            IReadWriteLocator childLocator = new Locator(rootLocator);

            rootLocator.Add("bar", o);

            IReadableLocator results;

            results = childLocator.FindBy(
                SearchMode.Up,
                delegate(KeyValuePair<object, object> kvp)
                {
                    return true;
                });

            Assert.AreEqual(1, results.Count);
            Assert.AreSame(o, results.Get("bar"));
        }
Esempio n. 12
0
        public void DefaultFindByBehaviorIsAskParent()
        {
            object o = new object();
            IReadWriteLocator rootLocator = new Locator();
            IReadWriteLocator childLocator = new Locator(rootLocator);

            rootLocator.Add("foo", o);

            IReadableLocator results;

            results = childLocator.FindBy(delegate(KeyValuePair<object, object> kvp)
                                                                            {
                                                                                return true;
                                                                            });

            Assert.AreEqual(1, results.Count);
        }
Esempio n. 13
0
        public void CanFindByPredicate()
        {
            bool wasCalled = false;
            object o1 = new object();
            object o2 = new object();
            IReadWriteLocator locator = new Locator();

            locator.Add("foo1", o1);
            locator.Add("foo2", o2);

            IReadableLocator results;

            results = locator.FindBy(
                delegate(KeyValuePair<object, object> kvp)
                {
                    wasCalled = true;
                    return kvp.Key.Equals("foo1");
                });

            Assert.IsNotNull(results);
            Assert.IsTrue(wasCalled);
            Assert.AreEqual(1, results.Count);
            Assert.AreSame(o1, results.Get("foo1"));
        }
Esempio n. 14
0
        public void BadSearchModeOnFindByThrows()
        {
            IReadWriteLocator locator = new Locator();

            locator.FindBy((SearchMode)254, delegate { return(true); });
        }