Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaio Cesar Saldanha Maia Orejuela Kinelski <t-cakine@microsoft.com>2016-12-28 01:20:52 +0300
committerCaio Cesar Saldanha Maia Orejuela Kinelski <t-cakine@microsoft.com>2016-12-28 20:59:47 +0300
commit369c2a174cd8b8b8cc662a4fbc3d3c70a78bfa7a (patch)
tree530459c3d4ffb44d2182a0c2eab549b30081d091 /src/System.Runtime.Extensions/tests
parent29160c35139f6e6f452864cf20c71b269e3bfed5 (diff)
Add test for order of raising AssemblyLoadContext.Unloading and AppDomain.ProcessExit
coreclr PR: https://github.com/dotnet/coreclr/pull/8737
Diffstat (limited to 'src/System.Runtime.Extensions/tests')
-rw-r--r--src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj1
-rw-r--r--src/System.Runtime.Extensions/tests/System/UnloadingAndProcessExitTests.netcoreapp1.1.cs37
2 files changed, 38 insertions, 0 deletions
diff --git a/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj b/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
index ffdffdc7a8..a1d0c67a46 100644
--- a/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
+++ b/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
@@ -55,6 +55,7 @@
<Compile Include="System\IO\Path.GetRelativePath.cs" />
<Compile Include="System\MathTests.netcoreapp1.1.cs" />
<Compile Include="System\MathF.netcoreapp1.1.cs" />
+ <Compile Include="System\UnloadingAndProcessExitTests.netcoreapp1.1.cs" />
</ItemGroup>
<ItemGroup>
<Compile Include="System\Diagnostics\Stopwatch.cs" />
diff --git a/src/System.Runtime.Extensions/tests/System/UnloadingAndProcessExitTests.netcoreapp1.1.cs b/src/System.Runtime.Extensions/tests/System/UnloadingAndProcessExitTests.netcoreapp1.1.cs
new file mode 100644
index 0000000000..49b10b0fe3
--- /dev/null
+++ b/src/System.Runtime.Extensions/tests/System/UnloadingAndProcessExitTests.netcoreapp1.1.cs
@@ -0,0 +1,37 @@
+using System.Diagnostics;
+using System.IO;
+using System.Threading;
+using Xunit;
+
+namespace System.Tests
+{
+ public class UnloadingAndProcessExitTests : RemoteExecutorTestBase
+ {
+ [Fact]
+ public void UnloadingEventMustHappenBeforeProcessExitEvent()
+ {
+ string fileName = GetTestFilePath();
+
+ File.WriteAllText(fileName, string.Empty);
+
+ Func<string, int> otherProcess = f =>
+ {
+ Action<int> OnUnloading = i => File.AppendAllText(f, string.Format("u{0}", i));
+ Action<int> OnProcessExit = i => File.AppendAllText(f, string.Format("e{0}", i));
+
+ AppDomain.CurrentDomain.ProcessExit += (sender, e) => OnProcessExit(0);
+ System.Runtime.Loader.AssemblyLoadContext.Default.Unloading += acl => OnUnloading(0);
+ AppDomain.CurrentDomain.ProcessExit += (sender, e) => OnProcessExit(1);
+ System.Runtime.Loader.AssemblyLoadContext.Default.Unloading += acl => OnUnloading(1);
+
+ return SuccessExitCode;
+ };
+
+ using (var remote = RemoteInvoke(otherProcess, fileName))
+ {
+ }
+
+ Assert.Equal(File.ReadAllText(fileName), "u0u1e0e1");
+ }
+ }
+}