示例#1
0
		public void Test_readonly() {
			int errorCode = 0;
			// after detaching all references but one, that storage is writeable ? 
			try {
				object[] data = new object[120];
				for (int i = 120; i-- > 0; )
					data[i] = (double)i;
                ILArray<object> B = new ILArray<object>(data, 5, 4, 1, 3, 2, 1);
				errorCode = 1; 
				if (B.IsReadonly() == true)
					throw new Exception();
				errorCode = 2;
                ILArray<object> A1 = B[3,"0:2,4;1,3;0;2,1,0,1"];
				if (A1.IsReadonly() == false | B.IsReadonly() == false)
					throw new Exception();
				errorCode = 3;
                ILArray<object> A2 = B.GetShifted(2);
				if (A1.IsReadonly() == false | B.IsReadonly() == false | A2.IsReadonly() == false)
					throw new Exception();
				errorCode = 4;
				A1.Detach();
				if (A1.IsReadonly() == true | B.IsReadonly() == false | A2.IsReadonly() == false)
					throw new Exception();
				errorCode = 5;
				A2.Detach();
				if (A1.IsReadonly() == true | B.IsReadonly() == true | A2.IsReadonly() == true)
					throw new Exception();
				errorCode = 6;
                ILArray<object> A3 = A2.S(3);
				if (A3.IsReadonly() == false | A2.IsReadonly() == false)
					throw new Exception();
				errorCode = 7;
				A2.Detach();
				if (A3.IsReadonly() == true | A2.IsReadonly() == true)
					throw new Exception();
				errorCode = 8;
				if (Object.Equals(A3,null)) {
                    ILArray<object> A4 = A3[2,"0:2,1"];
					if (A3.IsReadonly() == false | A4.IsReadonly() == false)
						throw new Exception();
					A4.Dispose();
				}
				// after leaving the scope -> A3 is only reference now? 
				// (Is not defined when the GC will clean up A4!)
				if (A3.IsReadonly() == true)
					throw new Exception("A3 should be writable!");
				Success("Test_readonly successful.");
			}
			catch (Exception e) {
				Error("Test_readonly failed at step: " + errorCode  + " Msg: " + e.Message);
			}
		}