[Mono-list] Patch re-send (in-line)

bucky@phantom.keystreams.com bucky@phantom.keystreams.com
Fri, 8 Feb 2002 14:18:48 -0800 (PST)


Index: ResourceReaderTest.cs
===================================================================
RCS file: /mono/mcs/class/corlib/Test/System.Resources/ResourceReaderTest.cs,v
retrieving revision 1.3
diff -u -r1.3 ResourceReaderTest.cs
--- ResourceReaderTest.cs	25 Jan 2002 11:49:59 -0000	1.3
+++ ResourceReaderTest.cs	8 Feb 2002 21:02:53 -0000
@@ -34,6 +34,31 @@
 		protected override void SetUp() {
 		}
 
+		private static string GetResourceFile()
+		{
+			string filename = m_ResourceFile;
+			//Console.WriteLine("RRT::GRF : Trying filename " + filename);
+			if (File.Exists(filename)) {
+				return filename;
+			}
+			filename = Directory.GetCurrentDirectory() + "\\System.Resources\\" + filename;
+			//Console.WriteLine("RRT::GRF : Trying filename " + filename);
+			if (File.Exists(filename)) {
+				return filename;
+			}
+			filename = Directory.GetParent(Directory.GetCurrentDirectory()).ToString() + "\\" + m_ResourceFile;
+			//Console.WriteLine("RRT::GRF : Trying filename " + filename);
+			if (File.Exists(filename)) {
+				return filename;
+			}
+			return null;
+		}
+
+		public void TestFindResourceFile() {
+			string resourceFile = GetResourceFile();
+			Assert("Null resource file", resourceFile != null);
+		}
+
 		public void TestConstructorStringExceptions() {
 			ResourceReader r;
 			try {
@@ -57,12 +82,13 @@
 		}
 
 		public void TestConstructorString() {
-			if (!File.Exists(m_ResourceFile)) {
-				Fail("Resource file is not where it should be:" + Directory.GetCurrentDirectory()+ "\\" + m_ResourceFile);
+			string resourceFile = GetResourceFile();
+			if (!File.Exists(resourceFile)) {
+				Fail("Resource file is not where it should be:" + Directory.GetCurrentDirectory()+ "\\" + resourceFile);
 			}
 			ResourceReader r = null;
 			try {
-				r = new ResourceReader(m_ResourceFile);
+				r = new ResourceReader(resourceFile);
 			}
 			catch {
 				Fail("Should have been able to open resource file.");
@@ -82,7 +108,7 @@
 			} catch{}
 
 			try {
-				Stream stream = new FileStream (m_ResourceFile, FileMode.Open);
+				Stream stream = new FileStream (GetResourceFile(), FileMode.Open);
 				stream.Close();
 				r = new ResourceReader(stream);
 				Fail("Should throw exception on cannot read");
@@ -92,7 +118,7 @@
 		public void TestStream(){
 			ResourceReader r = null;
 			try {
-				Stream stream = new FileStream (m_ResourceFile, FileMode.Open);
+				Stream stream = new FileStream (GetResourceFile(), FileMode.Open);
 				r = new ResourceReader(stream);
 			} 
 			catch{
@@ -107,11 +133,11 @@
 
 		public void TestClose() {
 			ResourceReader r = null;
-			Stream stream = new FileStream (m_ResourceFile, FileMode.Open);
+			Stream stream = new FileStream (GetResourceFile(), FileMode.Open);
 			r = new ResourceReader(stream);
 			r.Close();
 			try {
-				stream = new FileStream (m_ResourceFile, FileMode.Open);
+				stream = new FileStream (GetResourceFile(), FileMode.Open);
 			} 
 			catch{
 				Fail("Should be able to open the stream again after close");
@@ -125,7 +151,7 @@
 
 		public void TestEnumerator(){
 			ResourceReader reader = null;
-			Stream stream = new FileStream (m_ResourceFile, FileMode.Open);
+			Stream stream = new FileStream (GetResourceFile(), FileMode.Open);
 			reader = new ResourceReader(stream);
 			IDictionaryEnumerator en = reader.GetEnumerator();
 			// Goes through the enumerator, printing out the key and value pairs.