Пример #1
0
        public void TestGet()
        {
            TestAddobjectobject();

            Assert.AreEqual("a", LazyList.Get("a", 0));

            try
            {
                LazyList.Get(null, 0);
                Assert.IsTrue(false);
            }
            catch (IndexOutOfRangeException)
            {
                Assert.IsTrue(true);
            }

            try
            {
                LazyList.Get("a", 1);
                Assert.IsTrue(false);
            }
            catch (IndexOutOfRangeException)
            {
                Assert.IsTrue(true);
            }
        }
Пример #2
0
        public void TestRemoveobjectint()
        {
            object list = null;

            Assert.IsTrue(LazyList.Remove(list, 0) == null);

            list = LazyList.Add(list, "a");
            Assert.AreEqual("a", LazyList.Remove(list, 1));
            Assert.IsTrue(LazyList.Remove(list, 0) == null);

            list = LazyList.Add(list, "b");
            list = LazyList.Remove(list, 1);
            list = LazyList.Add(list, "b");
            list = LazyList.Add(list, "c");
            list = LazyList.Add(list, "d");
            list = LazyList.Add(list, "e");
            list = LazyList.Remove(list, 0);
            list = LazyList.Remove(list, 2);
            list = LazyList.Remove(list, 2);

            Assert.AreEqual(2, LazyList.Size(list));
            Assert.AreEqual("b", LazyList.Get(list, 0));
            Assert.AreEqual("c", LazyList.Get(list, 1));

            list = LazyList.Remove(list, 0);
            list = LazyList.Remove(list, 0);
            Assert.AreEqual(null, list);
        }
Пример #3
0
 public void RemoveBean(object obj)
 {
     if (_listeners != null)
     {
         for (int i = 0; i < LazyList.Size(_listeners); i++)
         {
             LazyList.Get <IContainerListener>(_listeners, i).RemoveBean(obj);
         }
     }
 }
Пример #4
0
        /// <summary>
        /// remove a parent child relationship
        /// </summary>
        /// <param name="parent"></param>
        /// <param name="child"></param>
        /// <param name="relationship"></param>
        private void Remove(object parent, object child, string relationship)
        {
            if (Log.IsDebugEnabled)
            {
                Log.Debug("Container {0} - {1} as {2}", parent, child, relationship);
            }

            if (_listeners != null)
            {
                ContainerRelationship eventObject = new ContainerRelationship(this, parent, child, relationship);
                for (int i = 0; i < LazyList.Size(_listeners); i++)
                {
                    LazyList.Get <IContainerListener>(_listeners, i).Remove(eventObject);
                }
            }
        }
Пример #5
0
        public void TestAddCollection()
        {
            List <object> l = new List <object>();

            l.Add("a");
            l.Add("b");

            object list = null;

            list = LazyList.AddCollection(list, l);
            list = LazyList.AddCollection(list, l);

            Assert.AreEqual(4, LazyList.Size(list));
            Assert.AreEqual("a", LazyList.Get(list, 0));
            Assert.AreEqual("b", LazyList.Get(list, 1));
            Assert.AreEqual("a", LazyList.Get(list, 2));
            Assert.AreEqual("b", LazyList.Get(list, 3));
        }
Пример #6
0
        public void TestAddobjectintobject()
        {
            object list = null;

            list = LazyList.Add(list, 0, "c");
            list = LazyList.Add(list, 0, "a");
            list = LazyList.Add(list, 1, "b");
            list = LazyList.Add(list, 3, "d");

            Assert.AreEqual(4, LazyList.Size(list));
            Assert.AreEqual("a", LazyList.Get(list, 0));
            Assert.AreEqual("b", LazyList.Get(list, 1));
            Assert.AreEqual("c", LazyList.Get(list, 2));
            Assert.AreEqual("d", LazyList.Get(list, 3));

            list = LazyList.Add(null, 0, null);
            Assert.IsTrue(list is IList);

            list = LazyList.Add(null, 0, new List <object>());
            Assert.IsTrue(list is IList);
        }
Пример #7
0
        public void TestAddobjectobject()
        {
            object list = null;

            Assert.AreEqual(0, LazyList.Size(list));

            list = LazyList.Add(list, "a");
            Assert.AreEqual(1, LazyList.Size(list));
            Assert.AreEqual("a", LazyList.Get(list, 0));

            list = LazyList.Add(list, "b");
            Assert.AreEqual(2, LazyList.Size(list));
            Assert.AreEqual("a", LazyList.Get(list, 0));
            Assert.AreEqual("b", LazyList.Get(list, 1));

            list = null;
            list = LazyList.Add(list, null);
            Assert.AreEqual(1, LazyList.Size(list));
            Assert.AreEqual(null, LazyList.Get(list, 0));

            list = "a";
            list = LazyList.Add(list, null);
            Assert.AreEqual(2, LazyList.Size(list));
            Assert.AreEqual("a", LazyList.Get(list, 0));
            Assert.AreEqual(null, LazyList.Get(list, 1));

            list = LazyList.Add(list, null);
            Assert.AreEqual(3, LazyList.Size(list));
            Assert.AreEqual("a", LazyList.Get(list, 0));
            Assert.AreEqual(null, LazyList.Get(list, 1));
            Assert.AreEqual(null, LazyList.Get(list, 2));

            list = LazyList.Add(null, list);
            Assert.AreEqual(1, LazyList.Size(list));
            object l = LazyList.Get(list, 0);

            Assert.IsTrue(l is IList);
        }