Lucene.Net.Analysis.TestCharArraySet.TestModifyOnUnmodifiable C# (CSharp) Method

TestModifyOnUnmodifiable() private method

private TestModifyOnUnmodifiable ( ) : void
return void
		public virtual void  TestModifyOnUnmodifiable()
		{
            //System.Diagnostics.Debugger.Break();
            CharArraySet set = new CharArraySet(10, true);
			set.AddAll(TEST_STOP_WORDS);
			int size = set.Count;
			set = CharArraySet.UnmodifiableSet(set);

			Assert.AreEqual(size, set.Count, "Set size changed due to UnmodifiableSet call");
			System.String NOT_IN_SET = "SirGallahad";
			Assert.IsFalse(set.Contains(NOT_IN_SET), "Test String already exists in set");
			
            Assert.Throws<NotSupportedException>(() => set.Add(NOT_IN_SET.ToCharArray()), "Modified unmodifiable set");
			Assert.IsFalse(set.Contains(NOT_IN_SET), "Test String has been added to unmodifiable set");
			Assert.AreEqual(size, set.Count, "Size of unmodifiable set has changed");
			
            Assert.Throws<NotSupportedException>(() => set.Add(NOT_IN_SET), "Modified unmodifiable set");
			Assert.IsFalse(set.Contains(NOT_IN_SET), "Test String has been added to unmodifiable set");
			Assert.AreEqual(size, set.Count, "Size of unmodifiable set has changed");
			
            Assert.Throws<NotSupportedException>(() => set.Add(new System.Text.StringBuilder(NOT_IN_SET)), "Modified unmodifiable set");
			Assert.IsFalse(set.Contains(NOT_IN_SET), "Test String has been added to unmodifiable set");
			Assert.AreEqual(size, set.Count, "Size of unmodifiable set has changed");
			
            Assert.Throws<NotSupportedException>(() => set.Clear(), "Modified unmodifiable set");
			Assert.IsFalse(set.Contains(NOT_IN_SET), "Changed unmodifiable set");
			Assert.AreEqual(size, set.Count, "Size of unmodifiable set has changed");

            Assert.Throws<NotSupportedException>(() => set.Add((object)NOT_IN_SET), "Modified unmodifiable set");
			Assert.IsFalse(set.Contains(NOT_IN_SET), "Test String has been added to unmodifiable set");
			Assert.AreEqual(size, set.Count, "Size of unmodifiable set has changed");

            Assert.Throws<NotSupportedException>(() => set.RemoveAll(new List<string>(TEST_STOP_WORDS)), "Modified unmodifiable set");
			Assert.AreEqual(size, set.Count, "Size of unmodifiable set has changed");
			
            Assert.Throws<NotSupportedException>(() => set.RetainAll(new List<string>(new[] { NOT_IN_SET })), "Modified unmodifiable set");
			Assert.AreEqual(size, set.Count, "Size of unmodifiable set has changed");
			
            Assert.Throws<NotSupportedException>(() => set.AddAll(new List<string>(new[] { NOT_IN_SET })), "Modified unmodifiable set");
			Assert.IsFalse(set.Contains(NOT_IN_SET), "Test String has been added to unmodifiable set");
			
			for (int i = 0; i < TEST_STOP_WORDS.Length; i++)
			{
				Assert.IsTrue(set.Contains(TEST_STOP_WORDS[i]));
			}
		}