コード例 #1
0
        public void GetAny()
        {
            Assert.IsTrue(_collection.Contains(_collection.GetAny()));

            Int32HashSet collection = new Int32HashSet();

            Assert.Throws <InvalidOperationException>(() => collection.GetAny());
        }
コード例 #2
0
        public void SetUp()
        {
            _collection = new Int32HashSet();
            _readOnly   = _collection.AsReadOnly();
            Assert.AreEqual(0, _collection.Count);

            _collection.Add(1);
            _collection.Add(2);
            _collection.Add(3);
            Assert.AreEqual(3, _collection.Count);
        }
コード例 #3
0
        public void Constructor()
        {
            var dictionary = new Int32HashSet();

            dictionary.Add(37);
            dictionary.Add(43);
            Assert.AreEqual(2, dictionary.Count);

            var clone = new Int32HashSet(dictionary);

            Assert.AreEqual(2, clone.Count);
        }
コード例 #4
0
        public void Equals()
        {
            Int32HashSet collection = new Int32HashSet();

            collection.Add(1);
            collection.Add(2);
            collection.Add(3);
            Assert.IsTrue(_collection.Equals(collection));

            collection.Add(37);
            Assert.IsFalse(_collection.Equals(collection));
        }
コード例 #5
0
        public void AddRange()
        {
            var collection = new Int32HashSet();

            collection.Add(4);
            collection.Add(5);

            Assert.Throws <NotSupportedException>(() => _readOnly.AddRange(collection));
            _collection.AddRange(collection);

            Assert.AreEqual(5, _collection.Count);
            Assert.IsTrue(_collection.Contains(4));
            Assert.IsTrue(_collection.Contains(5));

            Assert.Throws <ArgumentException>(() => _collection.AddRange(collection));
        }
コード例 #6
0
 public void TearDown()
 {
     _collection.Clear();
     _collection = null;
 }