Пример #1
0
        public void TestArgumentExceptions()
        {
            var      uids = new UniqueIdSet(SortOrder.Ascending);
            UniqueId uid;

            Assert.IsFalse(uids.IsReadOnly);

            uids.Add(UniqueId.MinValue);

            Assert.Throws <ArgumentOutOfRangeException> (() => new UniqueIdSet((SortOrder)500));
            Assert.Throws <ArgumentException> (() => uids.Add(UniqueId.Invalid));
            Assert.Throws <ArgumentNullException> (() => uids.AddRange(null));
            Assert.Throws <ArgumentNullException> (() => uids.CopyTo(null, 0));
            Assert.Throws <ArgumentOutOfRangeException> (() => uids.CopyTo(new UniqueId[1], -1));
            Assert.Throws <ArgumentOutOfRangeException> (() => uids.RemoveAt(-1));
            Assert.Throws <ArgumentOutOfRangeException> (() => uid = uids[-1]);
            Assert.Throws <NotSupportedException> (() => uids[0]   = UniqueId.MinValue);
            Assert.Throws <NotSupportedException> (() => uids.Insert(0, UniqueId.MinValue));

            var list = new List <UniqueId> {
                UniqueId.Invalid
            };

            Assert.Throws <ArgumentNullException> (() => UniqueIdSet.ToString(null));
            Assert.Throws <ArgumentException> (() => UniqueIdSet.ToString(list));

            Assert.Throws <ArgumentNullException> (() => UniqueIdSet.TryParse(null, out uids));
        }
Пример #2
0
		public void TestArgumentExceptions ()
		{
			var uids = new UniqueIdSet (SortOrder.Ascending);
			UniqueId uid;

			uids.Add (UniqueId.MinValue);

			Assert.Throws<ArgumentException> (() => uids.Add (UniqueId.Invalid));
			Assert.Throws<ArgumentNullException> (() => uids.AddRange (null));
			Assert.Throws<ArgumentNullException> (() => uids.CopyTo (null, 0));
			Assert.Throws<ArgumentOutOfRangeException> (() => uids.CopyTo (new UniqueId[1], -1));
			Assert.Throws<ArgumentOutOfRangeException> (() => uids.RemoveAt (-1));
			Assert.Throws<ArgumentOutOfRangeException> (() => uid = uids[-1]);
			Assert.Throws<NotSupportedException> (() => uids[0] = UniqueId.MinValue);
			Assert.Throws<NotSupportedException> (() => uids.Insert (0, UniqueId.MinValue));

			var list = new List<UniqueId> { UniqueId.Invalid };
			Assert.Throws<ArgumentNullException> (() => UniqueIdSet.ToString (null));
			Assert.Throws<ArgumentException> (() => UniqueIdSet.ToString (list));

			Assert.Throws<ArgumentNullException> (() => UniqueIdSet.TryParse (null, out uids));
		}