dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/_AppDomain.cs ...


From: Klaus Treichel
Subject: [dotgnu-pnet-commits] pnetlib ChangeLog runtime/System/_AppDomain.cs ...
Date: Sun, 10 Aug 2008 16:18:38 +0000

CVSROOT:        /cvsroot/dotgnu-pnet
Module name:    pnetlib
Changes by:     Klaus Treichel <ktreichel>      08/08/10 16:18:38

Modified files:
        .              : ChangeLog 
        runtime/System : _AppDomain.cs AppDomain.cs AppDomainSetup.cs 
        tests/runtime/System: SuiteSystem.cs 
Added files:
        tests/runtime/System: TestAppDomain.cs 

Log message:
        Implement more AppDomain support and add some tests.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pnetlib/ChangeLog?cvsroot=dotgnu-pnet&r1=1.2536&r2=1.2537
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/_AppDomain.cs?cvsroot=dotgnu-pnet&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/AppDomain.cs?cvsroot=dotgnu-pnet&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/pnetlib/runtime/System/AppDomainSetup.cs?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/pnetlib/tests/runtime/System/SuiteSystem.cs?cvsroot=dotgnu-pnet&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/pnetlib/tests/runtime/System/TestAppDomain.cs?cvsroot=dotgnu-pnet&rev=1.1

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/ChangeLog,v
retrieving revision 1.2536
retrieving revision 1.2537
diff -u -b -r1.2536 -r1.2537
--- ChangeLog   1 Aug 2008 17:42:58 -0000       1.2536
+++ ChangeLog   10 Aug 2008 16:18:37 -0000      1.2537
@@ -1,3 +1,19 @@
+2008-08-10  Klaus Treichel  <address@hidden>
+
+       * runtime/System/_AppDomain.cs: Rename the argument assemblyName to
+       assemblyFile in the CreateInstanceFrom members.
+
+       * runtime/System/AppDomain.cs: Replace the dummy implementations with
+       real ines using the new internalcalls
+
+       * runtime/System/AppDomainSetup.cs: Implement the GetPrivateBinPaths
+       property.
+
+       * tests/runtime/System/SuiteSystem.cs: Add the AppDomain tests to the
+       suite.
+
+       * tests/runtime/System/TestAppDomain.cs: Add tests for AppDomain 
support.
+
 2008-08-01  Klaus Treichel  <address@hidden>
 
        * runtime/System/Threading/Timer.cs (DisposeInternal): Add an additional

Index: runtime/System/_AppDomain.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/_AppDomain.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- runtime/System/_AppDomain.cs        29 May 2003 03:12:58 -0000      1.8
+++ runtime/System/_AppDomain.cs        10 Aug 2008 16:18:37 -0000      1.9
@@ -211,10 +211,10 @@
                                                                Evidence 
securityAttributes);
 
        // Create a remote instance of a type within this application domain.
-       ObjectHandle CreateInstanceFrom(String assemblyName, String typeName);
-       ObjectHandle CreateInstanceFrom(String assemblyName, String typeName,
+       ObjectHandle CreateInstanceFrom(String assemblyFile, String typeName);
+       ObjectHandle CreateInstanceFrom(String assemblyFile, String typeName,
                                                                    Object[] 
activationAttributes);
-       ObjectHandle CreateInstanceFrom(String assemblyName, String typeName,
+       ObjectHandle CreateInstanceFrom(String assemblyFile, String typeName,
                                                                    bool 
ignoreCase, BindingFlags bindingAttr,
                                                                    Binder 
binder, Object[] args,
                                                                    CultureInfo 
culture,

Index: runtime/System/AppDomain.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/AppDomain.cs,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- runtime/System/AppDomain.cs 15 Sep 2004 14:23:20 -0000      1.29
+++ runtime/System/AppDomain.cs 10 Aug 2008 16:18:37 -0000      1.30
@@ -50,7 +50,7 @@
 {
        // Internal state.
        private static int nextDomainID = 0;
-       private String friendlyName;
+       private IntPtr appDomain;  // Pointer to the ILExecProcess this 
AppDomain represents
        internal int domainID;
 #if !ECMA_COMPAT
        private Evidence evidence;
@@ -63,8 +63,85 @@
        internal LifetimeServices.Manager lifetimeManager;
 #endif
 
+       // InternalCalls
+       // Append the Paths to the private paths for the appDomain
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void AppendPrivatePathsInternal(IntPtr appDomain, 
String[] paths);
+
+       // Clear the search paths for private assemblies
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void ClearPrivatePathInternal(IntPtr appDomain);
+
+       // Clear the paths which assemblies should be shadow copied
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void ClearShadowCopyPathInternal(IntPtr 
appDomain);
+
+       // Create a new instance of ILExecProcess
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void CreateAppDomain(ref IntPtr appDomain);
+
+       // Get the current instance of ILExecProcess
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void CurrentAppDomain(ref IntPtr appDomain);
+
+       // Get the base directory for this application domain.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static String GetBaseDirectoryInternal(IntPtr appDomain);
+
+       // Get the friendly name associated with this application domain.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static String GetFriendlyNameInternal(IntPtr appDomain);
+
+       // Get the search path relative to the application base for this 
application domain.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static String GetRelativeSearchPathInternal(IntPtr 
appDomain);
+
+       // Get the flag if files should be shadow copied.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static bool GetShadowCopyFilesInternal(IntPtr appDomain);
+
+       // Check if this is the default AppDomain
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static bool IsDefaultAppDomainInternal(IntPtr appDomain);
+
+       // Set the base directory for this application domain.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void SetBaseDirectoryInternal(IntPtr appDomain, 
String baseDirectory);
+
+       // Set the friendly name associated with this application domain.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void SetFriendlyNameInternal(IntPtr appDomain, 
String friendlyName);
+
+       // Set the search path relative to the application base for this 
application domain.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void SetRelativeSearchPathInternal(IntPtr 
appDomain, String appRelativePath);
+
+       // Set the flag if files should be shadow copied.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void SetShadowCopyFilesInternal(IntPtr appDomain, 
bool shadowCopyFiles);
+
+       // Set the paths which assemblies should be shadow copied for the 
appDomain
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void SetShadowCopyPathInternal(IntPtr appDomain, 
String[] paths);
+
+       // Unload the instance of ILExecProcess
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void UnloadAppDomain(IntPtr appDomain);
+
+
+       // Constructor for the CurrentDomain
+       private AppDomain(IntPtr appDomain)
+       {
+               this.appDomain = appDomain;
+#if !ECMA_COMPAT
+                               setup = new AppDomainSetup(appDomain);
+                               items = new Hashtable();
+                               this.evidence = new Evidence();
+#endif
+       }
+
        // Construct a new AppDomain instance.
-       private AppDomain(String name)
+       private AppDomain(String name, IntPtr appDomain)
                        {
                                if(name == null)
                                {
@@ -74,20 +151,22 @@
                                {
                                        domainID = ++nextDomainID;
                                }
-                               friendlyName = name;
+                               this.appDomain = appDomain;
+                               SetFriendlyNameInternal(appDomain, name);
 #if !ECMA_COMPAT
-                               setup = new AppDomainSetup();
+                               setup = new AppDomainSetup(appDomain);
                                items = new Hashtable();
 #endif
                        }
 #if !ECMA_COMPAT
-       private AppDomain(String name, Evidence evidence, AppDomainSetup setup)
+       private AppDomain(String name, Evidence evidence, AppDomainSetup setup, 
IntPtr appDomain)
                        {
                                if(name == null)
                                {
                                        throw new ArgumentNullException("name");
                                }
-                               friendlyName = name;
+                               this.appDomain = appDomain;
+                               SetFriendlyNameInternal(appDomain, name);
                                this.evidence = evidence;
                                this.setup = setup;
                                this.items = new Hashtable();
@@ -97,27 +176,30 @@
        // Create a new application domain with a specified name.
        public static AppDomain CreateDomain(String friendlyName)
                        {
-                               // we have only one app domain , fake creation 
for now
-                               return CurrentDomain;
-                               // return new AppDomain(friendlyName);
+                               IntPtr appDomain;
+
+                               CreateAppDomain(ref appDomain);
+                               return new AppDomain(friendlyName, appDomain);
                        }
 #if !ECMA_COMPAT
        public static AppDomain CreateDomain(String friendlyName,
                                                                                
 Evidence securityInfo)
                        {
-                               // we have only one app domain , fake creation 
for now
-                               return CurrentDomain;
-                               /* return new AppDomain(friendlyName, 
securityInfo,
-                                                                        new 
AppDomainSetup()); */
+                               IntPtr appDomain;
+
+                               CreateAppDomain(ref appDomain);
+                               return new AppDomain(friendlyName, securityInfo,
+                                                                        new 
AppDomainSetup(appDomain),
+                                                                        
appDomain);
                        }
        public static AppDomain CreateDomain(String friendlyName,
                                                                                
 Evidence securityInfo,
                                                                                
 AppDomainSetup info)
                        {
-                               // we have only one app domain , fake creation 
for now
-                               CurrentDomain.setup = info;
-                               return CurrentDomain;
-                               // return new AppDomain(friendlyName, 
securityInfo, info);
+                               IntPtr appDomain;
+
+                               CreateAppDomain(ref appDomain);
+                               return new AppDomain(friendlyName, 
securityInfo, info, appDomain);
                        }
        public static AppDomain CreateDomain(String friendlyName,
                                                                                
 Evidence securityInfo,
@@ -125,22 +207,22 @@
                                                                                
 String appRelativeSearchPath,
                                                                                
 bool shadowCopyFiles)
                        {
-                               // we have only one app domain , fake creation 
for now
-                               AppDomainSetup setup = new AppDomainSetup();
-                               setup.ApplicationBase = appBasePath;
-                               setup.PrivateBinPath = appRelativeSearchPath;
-                               setup.ShadowCopyFiles = 
shadowCopyFiles.ToString();
-                               CurrentDomain.setup = setup;
-                               return CurrentDomain;
-                               /*
-                               return new AppDomain(friendlyName, 
securityInfo, setup);*/
+                               IntPtr appDomain;
+
+                               CreateAppDomain(ref appDomain);
+                               SetBaseDirectoryInternal(appDomain, 
appBasePath);
+                               SetRelativeSearchPathInternal(appDomain, 
appRelativeSearchPath);
+                               SetShadowCopyFilesInternal(appDomain, 
shadowCopyFiles);
+                               return new AppDomain(friendlyName, securityInfo,
+                                                                        new 
AppDomainSetup(appDomain),
+                                                                        
appDomain);
                        }
 #endif
 
        // Return a string representing the current instance.
        public override String ToString()
                        {
-                               return friendlyName;
+                               return FriendlyName;
                        }
 
        // Unload a specific application domain.
@@ -150,7 +232,16 @@
                                {
                                        throw new 
ArgumentNullException("domain");
                                }
-                               // All domains are local, and we cannot unload 
them at present.
+                               // We must not unload the default AppDomain
+                               if 
(IsDefaultAppDomainInternal(domain.appDomain))
+                               {
+                                       throw new 
CannotUnloadAppDomainException();
+                               }
+                               if (domain.DomainUnload != null)
+                               {
+                                       domain.DomainUnload(domain, new 
EventArgs());
+                               }
+                               UnloadAppDomain(domain.appDomain);
                        }
 
        // Get the friendly name associated with this application domain.
@@ -158,7 +249,12 @@
                        {
                                get
                                {
-                                       return friendlyName;
+                                       String name = 
GetFriendlyNameInternal(appDomain);
+                                       if(name == null)
+                                       {
+                                               return String.Empty;
+                                       }
+                                       return name;
                                }
                        }
 
@@ -174,9 +270,9 @@
 #if !ECMA_COMPAT
 
        // Create the setup information block for the current domain.
-       private static AppDomainSetup CreateCurrentSetup()
+       private static AppDomainSetup CreateCurrentSetup(IntPtr appDomain)
                        {
-                               AppDomainSetup setup = new AppDomainSetup();
+                               AppDomainSetup setup = new 
AppDomainSetup(appDomain);
 
                                // Get the location information for the assembly
                                // that contains the program entry point.
@@ -220,13 +316,9 @@
                                        {
                                                if(currentDomain == null)
                                                {
-                                               #if !ECMA_COMPAT
-                                                       currentDomain = new 
AppDomain
-                                                               ("current", new 
Evidence(), 
-                                                                               
        CreateCurrentSetup());
-                                               #else
-                                                       currentDomain = new 
AppDomain("current");
-                                               #endif
+                                                       IntPtr domain = 
IntPtr.Zero;
+                                                       CurrentAppDomain(ref 
domain);
+                                                       currentDomain = new 
AppDomain(domain);
                                                }
                                                return currentDomain;
                                        }
@@ -240,7 +332,7 @@
                        {
                                get
                                {
-                                       return setup.ApplicationBase;
+                                       return 
GetBaseDirectoryInternal(appDomain);
                                }
                        }
 
@@ -267,7 +359,7 @@
                        {
                                get
                                {
-                                       return setup.PrivateBinPath;
+                                       return 
GetRelativeSearchPathInternal(appDomain);
                                }
                        }
 
@@ -276,7 +368,7 @@
                        {
                                get
                                {
-                                       return (setup.ShadowCopyFiles == 
"true");
+                                       return 
GetShadowCopyFilesInternal(appDomain);
                                }
                        }
 
@@ -290,30 +382,34 @@
                        }
 
        // Append a directory to the private path.
+#if CONFIG_FRAMEWORK_2_0
+       [Obsolete()]
+#endif
        public void AppendPrivatePath(String path)
                        {
-                               String previous = setup.PrivateBinPath;
-                               if(previous == null || previous == String.Empty)
-                               {
-                                       setup.PrivateBinPath = path;
-                               }
-                               else
+                               if (path == null || path.Length == 0)
                                {
-                                       setup.PrivateBinPath =
-                                               previous + Path.PathSeparator + 
path;
+                                       // Nothing to do
+                                       return;
                                }
+                               String[] splitPaths = 
path.Split(Path.PathSeparator);
+
+                               AppendPrivatePathsInternal(appDomain, 
splitPaths);
                        }
 
        // Clear the private path.
+#if CONFIG_FRAMEWORK_2_0
+       [Obsolete()]
+#endif
        public void ClearPrivatePath()
                        {
-                               setup.PrivateBinPath = String.Empty;
+                               ClearPrivatePathInternal(appDomain);
                        }
 
        // Clear the shadow copy path.
        public void ClearShadowCopyPath()
                        {
-                               setup.ShadowCopyDirectories = String.Empty;
+                               ClearShadowCopyPathInternal(appDomain);
                        }
 
 #endif // !ECMA_COMPAT
@@ -613,7 +709,13 @@
 
        // Get a list of all assemblies in this application domain.
        [MethodImpl(MethodImplOptions.InternalCall)]
-       extern public Assembly[] GetAssemblies();
+       extern private static Assembly[] GetAssembliesInternal(IntPtr 
appDomain);
+
+       // Get a list of all assemblies in this application domain.
+       public Assembly[] GetAssemblies()
+       {
+               return GetAssembliesInternal(appDomain);
+       }
 
        // Get the current thread identifier.
        public static int GetCurrentThreadId()
@@ -633,10 +735,21 @@
                                return base.GetType();
                        }
 
+#if CONFIG_FRAMEWORK_2_0
+       public bool IsDefaultAppDomain()
+                       {
+                               return IsDefaultAppDomainInternal(appDomain);
+                       }
+#endif
+
+       // Determine if this domain is running finalizers prior to unload.
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static bool IsFinalizingForUnloadInternal(IntPtr 
appDomain);
+
        // Determine if this domain is running finalizers prior to unload.
        public bool IsFinalizingForUnload()
                        {
-                               return false;
+                               return IsFinalizingForUnloadInternal(appDomain);
                        }
 
        // Load an assembly into this application domain by name.
@@ -753,13 +866,20 @@
        // Turn on shadow copying.
        public void SetShadowCopyFiles()
                        {
-                               setup.ShadowCopyFiles = "true";
+                               SetShadowCopyFilesInternal(appDomain, true);
                        }
 
        // Set the location of the shadow copy directory.
        public void SetShadowCopyPath(String s)
                        {
-                               setup.ShadowCopyDirectories = s;
+                               if (s == null || s.Length == 0)
+                               {
+                                       // Clear the directories to be shadow 
copied (now all private assemblies are shadow copied)
+                                       ClearShadowCopyPathInternal(appDomain);;
+                               }
+                               String[] splitPaths = 
s.Split(Path.PathSeparator);
+
+                               SetShadowCopyPathInternal(appDomain, 
splitPaths);
                        }
 
        // Event that is emitted to resolve assemblies.

Index: runtime/System/AppDomainSetup.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/runtime/System/AppDomainSetup.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- runtime/System/AppDomainSetup.cs    15 Sep 2004 14:57:39 -0000      1.4
+++ runtime/System/AppDomainSetup.cs    10 Aug 2008 16:18:37 -0000      1.5
@@ -25,7 +25,9 @@
 
 using System;
 using System.IO;
+using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
+using System.Text;
 
 [Serializable]
 #if CONFIG_COM_INTEROP
@@ -34,6 +36,7 @@
 public sealed class AppDomainSetup : IAppDomainSetup
 {
        // Internal state.
+       private IntPtr appDomain; // pointer to the ILExecProcess
        private String applicationBase;
        private String applicationName;
        private String cachePath;
@@ -49,10 +52,24 @@
        private bool disallowCodeDownload;
        private LoaderOptimization loaderOptimization;
 
+       // Get an array with the private paths of the appDomain
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void GetPrivateBinPaths(IntPtr appDomain, ref 
String[] paths);
+
+       // Set the private paths of the appDomain
+       [MethodImpl(MethodImplOptions.InternalCall)]
+       extern private static void SetPrivateBinPaths(IntPtr appDomain, 
String[] paths);
+
+
        // Constructor.
        public AppDomainSetup()
                        {
-                               // Nothing to do here.
+                               appDomain = IntPtr.Zero;
+                       }
+
+       internal AppDomainSetup(IntPtr appDomain)
+                       {
+                               this.appDomain = appDomain;
                        }
 
        // Implement the IAppDomainSetup interface.
@@ -139,12 +156,54 @@
                        {
                                get
                                {
+                                       if (appDomain == IntPtr.Zero)
+                                       {
                                        return privateBinPath;
                                }
+                                       else
+                                       {
+                                               String[] paths;
+
+                                               GetPrivateBinPaths(appDomain, 
ref paths);
+
+                                               if (paths != null && 
paths.Length > 0)
+                                               {
+                                                       StringBuilder builder = 
new StringBuilder();
+                                                       int index;
+
+                                                       
builder.Append(paths[0]);
+                                                       for (index = 1; index < 
paths.Length; index++)
+                                                       {
+                                                               
builder.Append(Path.PathSeparator);
+                                                               
builder.Append(paths[index]);
+                                                       }
+                                                       return 
builder.ToString();
+                                               }
+                                               else
+                                               {
+                                                       return String.Empty;
+                                               }
+                                       }
+                               }
                                set
                                {
+                                       if (appDomain == IntPtr.Zero)
+                                       {
                                        privateBinPath = value;
                                }
+                                       else
+                                       {
+                                               if (value != null)
+                                               {
+                                                       String[] paths = 
value.Split(Path.PathSeparator);
+                                                       
SetPrivateBinPaths(appDomain, paths);
+                                               }
+                                               else
+                                               {
+                                                       
SetPrivateBinPaths(appDomain, null);
+                                               }
+                                       }
+                               }
                        }
        public String PrivateBinPathProbe
                        {

Index: tests/runtime/System/SuiteSystem.cs
===================================================================
RCS file: /cvsroot/dotgnu-pnet/pnetlib/tests/runtime/System/SuiteSystem.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- tests/runtime/System/SuiteSystem.cs 26 Jun 2005 16:08:32 -0000      1.11
+++ tests/runtime/System/SuiteSystem.cs 10 Aug 2008 16:18:37 -0000      1.12
@@ -30,6 +30,9 @@
 #if CONFIG_FRAMEWORK_2_0       
                                suite.AddTests(typeof(TestActivationArguments));
                                suite.AddTests(typeof(TestActivationContext));
+#endif
+                               suite.AddTests(typeof(TestAppDomain));
+#if CONFIG_FRAMEWORK_2_0       
                                suite.AddTests(typeof(TestApplicationId));
                                suite.AddTests(typeof(TestApplicationIdentity));
 #endif

Index: tests/runtime/System/TestAppDomain.cs
===================================================================
RCS file: tests/runtime/System/TestAppDomain.cs
diff -N tests/runtime/System/TestAppDomain.cs
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/runtime/System/TestAppDomain.cs       10 Aug 2008 16:18:37 -0000      
1.1
@@ -0,0 +1,123 @@
+/*
+ * TestAppDomain.cs - Tests for the "AppDomain" class.
+ *
+ * Copyright (C) 2002  Southern Storm Software, Pty Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+using CSUnit;
+using System;
+
+public class TestAppDomain : TestCase
+{
+       // Constructor.
+       public TestAppDomain(String name) : base(name)
+       {
+               // Nothing to do here.
+       }
+
+       // Set up for the tests.
+       protected override void Setup()
+       {
+               // Nothing to do here.
+       }
+
+       // Clean up after the tests.
+       protected override void Cleanup()
+       {
+               // Nothing to do here.
+       }
+
+       public void TestAppDomainCreate01()
+       {
+               AppDomain domain = AppDomain.CreateDomain("test");
+
+               AppDomain.Unload(domain);
+               
+       }
+
+       public void TestAppDomainCreateFriendlyName()
+       {
+               String friendlyName = "test";
+               AppDomain domain = AppDomain.CreateDomain(friendlyName);
+
+               try
+               {
+                       AssertEquals("FriendlyName", friendlyName, 
domain.FriendlyName);
+               }
+               finally
+               {
+                       AppDomain.Unload(domain);
+               }
+       }
+
+       public void TestAppDomainFriendlyNameUnloaded()
+       {
+               String friendlyName = "test";
+               AppDomain domain = AppDomain.CreateDomain(friendlyName);
+
+               AppDomain.Unload(domain);
+               try
+               {
+                       AssertEquals("FriendlyName", friendlyName, 
domain.FriendlyName);
+                       Fail("Should have thrown an AppDomainUnloadedException 
!");
+               }
+               catch(AppDomainUnloadedException)
+               {
+                       // SUCCESS
+               }
+       }
+
+       public void TestAppDomainCurrentName01()
+       {
+               AppDomain domain = AppDomain.CurrentDomain;
+       
+               AssertEquals("Current Appdomain.FriendlyName", "csunit.exe", 
domain.FriendlyName);
+       }
+
+       public void TestAppDomainAssemblies01()
+       {
+               AppDomain appDomain = AppDomain.CreateDomain("Test1");
+               try
+               {
+                       System.Reflection.Assembly[] assemblies = 
appDomain.GetAssemblies();
+                       AssertEquals("AppDomainAssemblies 01 Length", 1, 
assemblies.Length);
+                       AssertEquals("AppDomainAssemblies 01 Name", "mscorlib", 
assemblies[0].GetName().Name);
+               }
+               finally
+               {
+                       AppDomain.Unload(appDomain);
+               }
+       }
+
+       public void TestAppDomainUnloadDefault()
+       {
+               AppDomain domain = AppDomain.CurrentDomain;
+
+               try
+               {
+                       AppDomain.Unload(domain);
+                       Fail("Should have thrown a 
CannotUnloadAppDomainException !");
+               }
+               catch(CannotUnloadAppDomainException)
+               {
+                       // SUCCESS
+               }
+       }
+
+} // class TestAppDomain
+
+




reply via email to

[Prev in Thread] Current Thread [Next in Thread]