コード例 #1
0
        public void ICollection_Generic_Add_AfterRemovingAnyValue(int count)
        {
            if (!IsReadOnly && !AddRemoveClear_ThrowsNotSupported)
            {
                int             seed       = 840;
                ICollection <T> collection = GenericICollectionFactory(count);
                List <T>        items      = collection.ToList();
                T toAdd = CreateT(seed++);
                while (collection.Contains(toAdd))
                {
                    toAdd = CreateT(seed++);
                }
                collection.Add(toAdd);
                collection.Remove(toAdd);

                toAdd = CreateT(seed++);
                while (collection.Contains(toAdd))
                {
                    toAdd = CreateT(seed++);
                }

                collection.Add(toAdd);
                items.Add(toAdd);
                CollectionAsserts.EqualUnordered(items, collection);
            }
        }
コード例 #2
0
        public void AsReadOnly_TurnsIListIntoReadOnlyCollection()
        {
            IList <string> list = new List <string> {
                "A", "B"
            };
            ReadOnlyCollection <string> readOnlyCollection = list.AsReadOnly();

            Assert.NotNull(readOnlyCollection);
            CollectionAsserts.Equal(list, readOnlyCollection);
        }