Browse Source

Moved StringCollectionTest.cs and NameValueCollectionTest to this dir

svn path=/trunk/mcs/; revision=4445
Lawrence Pit 23 years ago
parent
commit
b04cb804fe

+ 29 - 0
mcs/class/System/Test/System.Collections.Specialized/AllTests.cs

@@ -0,0 +1,29 @@
+//
+// MonoTests.System.Collections.Specialized.AllTests, System.dll
+//
+// Author:
+//   Lawrence Pit <[email protected]>
+//
+
+using NUnit.Framework;
+using System;
+
+namespace MonoTests.System.Collections.Specialized  {
+	
+	public class AllTests : TestCase {
+
+		public AllTests (string name) : base (name)
+		{
+		}
+
+		public static ITest Suite {
+			get {
+				TestSuite suite = new TestSuite ();
+				suite.AddTest (NameValueCollectionTest.Suite);
+				suite.AddTest (StringCollectionTest.Suite);
+				return suite;
+			}
+		}
+	}
+}
+

+ 3 - 0
mcs/class/System/Test/System.Collections.Specialized/ChangeLog

@@ -0,0 +1,3 @@
+2002-05-09  Lawrence Pit <[email protected]>
+
+	* Moved StringCollectionTest.cs and NameValueCollectionTest to this dir

+ 30 - 0
mcs/class/System/Test/System.Collections.Specialized/NameValueCollectionTest.cs

@@ -0,0 +1,30 @@
+// created on 7/21/2001 at 2:36 PM
+
+using System;
+using System.Collections;
+using System.Collections.Specialized;
+using System.Text;
+
+using NUnit.Framework;
+
+namespace MonoTests.System.Collections.Specialized {
+
+
+	/// <summary>Microsoft NameValueCollection test.</summary>
+	public class NameValueCollectionTest : TestCase {
+
+		public NameValueCollectionTest() : base("MonoTests.System.Collections.Specialized.NameValueCollectionTest testsuite") {}
+		public NameValueCollectionTest(String name) : base(name) {}
+
+		public static ITest Suite {
+			get {
+				return new TestSuite(typeof(NameValueCollectionTest));
+			}
+		}
+		
+		public void TestToDo ()
+		{
+		}
+	}
+}
+

+ 157 - 0
mcs/class/System/Test/System.Collections.Specialized/StringCollectionTest.cs

@@ -0,0 +1,157 @@
+/* System.Collections.Specialized.StringCollection.cs
+ * Authors:
+ *   John Barnette ([email protected])
+ *
+ *  Copyright (C) 2001 John Barnette
+*/
+
+using NUnit.Framework;
+using System.Collections.Specialized;
+
+namespace MonoTests.System.Collections.Specialized {
+	public class StringCollectionTest : TestCase {
+
+		public static ITest Suite {
+			get {
+				return new TestSuite(typeof (StringCollectionTest));
+			}
+		}
+
+		private StringCollection sc;
+		string[] strings = {
+			"foo",
+			"bar",
+			"baz",
+			"john",
+			"paul",
+			"george",
+			"ringo"
+		};
+		
+		public StringCollectionTest() : base("MonoTests.System.Collections.Specialized.StringCollectionTest testsuite") {}
+		public StringCollectionTest(string name) : base(name) {}
+		
+		protected override void SetUp() {
+			sc = new StringCollection();
+			sc.AddRange(strings);
+		}
+
+		// Simple Tests
+		
+		public void TestSimpleCount() {
+			Assert(sc.Count == 7);
+		}
+		
+		public void TestSimpleIsReadOnly() {
+			Assert(!sc.IsReadOnly);
+		}
+		
+		public void TestSimpleIsSynchronized() {
+			Assert(!sc.IsSynchronized);
+		}
+		
+		public void TestSimpleItemGet() {
+			for(int i = 0; i < strings.Length; i++) {
+				Assert(strings[i].Equals(sc[i]));
+			}
+		}
+		
+		public void TestSimpleItemSet() {
+			sc[0] = "bob";
+			Assert(sc[0].Equals("bob"));
+		}
+		
+		public void TestSimpleSyncRoot() {
+			Assert(sc.Equals(sc.SyncRoot));
+		}
+		
+		public void TestSimpleAdd() {
+			int index = sc.Add("chuck");
+			Assert(index == strings.Length);
+			Assert(sc[strings.Length].Equals("chuck"));
+			
+		}
+		
+		public void TestSimpleAddRange() {
+			string[] newStrings = {
+				"peter",
+				"paul",
+				"mary"
+			};
+			
+			int index = sc.Count;
+			sc.AddRange(newStrings);
+			
+			Assert(sc.Count == index + newStrings.Length);
+			
+			for (int i = 0; i+index <= sc.Count-1; i++) {
+				Assert(newStrings[i].Equals(sc[i+index]));
+			}
+		}
+		
+		public void TestSimpleClear() {
+			sc.Clear();
+			Assert(sc.Count == 0);
+		}
+		
+		public void TestSimpleContains() {
+			Assert(sc.Contains(strings[0]));
+			Assert(!sc.Contains("NOT CONTAINED"));
+		}
+		
+		public void TestSimpleCopyTo() {
+			string[] copyArray = new string[sc.Count];
+			sc.CopyTo(copyArray, 0);
+			for (int i = 0; i < copyArray.Length; i++) {
+				Assert(copyArray[i] == sc[i]);
+			}
+		}
+		
+		public void TestSimpleGetEnumerator() {
+			int index = 0;
+			foreach(string s in sc) {
+				Assert(s.Equals(strings[index]));
+				index++;
+			}
+		}
+		
+		public void TestSimpleIndexOf() {
+			Assert(sc.IndexOf(strings[0]) == 0);
+		}
+		
+		public void TestSimpleInsert() {
+			int index = 3;
+			int oldCount = sc.Count;
+			string before  = sc[index - 1];
+			string current = sc[index];
+			string after   = sc[index + 1];
+			string newStr  = "paco";
+			
+			sc.Insert(index, newStr);
+			
+			Assert(sc.Count == oldCount + 1);
+			Assert(sc[index].Equals(newStr));
+			Assert(sc[index-1].Equals(before));
+			Assert(sc[index+1].Equals(current));
+			Assert(sc[index+2].Equals(after));
+		}
+		
+		public void TestSimpleRemove() {
+			int oldCount = sc.Count;
+			sc.Remove(strings[0]);
+			Assert(oldCount == sc.Count + 1);
+			Assert(!sc.Contains(strings[0]));
+		}
+		
+		public void TestSimpleRemoveAt() {
+			int index = 3;
+			int oldCount = sc.Count;
+			string after = sc[index+1];
+			
+			sc.RemoveAt(index);
+			Assert(oldCount == sc.Count + 1);
+			Assert(sc[index].Equals(after));
+		}
+			
+	}
+}