コード例 #1
0
ファイル: TestSetList.cs プロジェクト: waqashaneef/NosDB
        public void TestIList()
        {
            IList list = new SetList <string>(StringComparer.Ordinal);

            Assert.AreEqual(0, list.Count);
            list.Add("a");
            Assert.AreEqual(1, list.Count);
            list.Add("B");
            Assert.AreEqual(2, list.Count);

            Assert.AreEqual("B", list[0]);
            Assert.AreEqual("a", list[1]);

            Assert.IsTrue(list.Contains("a"));
            Assert.IsFalse(list.Contains("A"));
            Assert.IsFalse(list.Contains("b"));
            Assert.IsTrue(list.Contains("B"));

            Assert.AreEqual(0, list.IndexOf("B"));
            Assert.AreEqual(1, list.IndexOf("a"));

            list = new SetList <string>((IEnumerable <string>)list, StringComparer.OrdinalIgnoreCase);
            Assert.AreEqual(2, list.Count);
            Assert.AreEqual("a", list[0]);
            Assert.AreEqual("B", list[1]);

            Assert.IsTrue(list.Contains("a"));
            Assert.IsTrue(list.Contains("A"));
            Assert.IsTrue(list.Contains("b"));
            Assert.IsTrue(list.Contains("B"));

            Assert.IsFalse(list.Contains(5));
            Assert.IsTrue(list.IndexOf(5) < 0);

            Assert.IsFalse(list.IsFixedSize);
            list.Remove("b");
            Assert.IsFalse(list.Contains("b"));
            Assert.IsFalse(list.Contains("B"));

            list = (IList)((ICloneable)list).Clone();
            Assert.AreEqual(typeof(SetList <string>), list.GetType());
            Assert.IsTrue(list.Contains("a"));
            Assert.IsFalse(list.Contains("b"));
            Assert.AreEqual(0, list.IndexOf("a"));
        }
コード例 #2
0
        private SetList CreateSetList(
            bool addSets = true, bool addActs = true, bool isChildList = true)
        {
            AddData(addSets, addActs);
            var result = new SetList(isChildList)
            {
                Session = Session
            };

            if (isChildList)
            {
                ParentList = (result.CreateParentList() as EventList) !;
                ParentList.ChildListType = result.GetType();
                result.ParentList        = ParentList;
            }
            else
            {
                result.ChildListType = typeof(PieceList);
            }
            return(result);
        }