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
path: root/src
diff options
context:
space:
mode:
authorStephen Toub <stoub@microsoft.com>2017-01-04 02:01:32 +0300
committerGitHub <noreply@github.com>2017-01-04 02:01:32 +0300
commita384f0ad82aa75cd3a4c8b0bb41dd84643781c77 (patch)
tree6b3fec847a374afdad44f1f21d670dee8723b46e /src
parent8fbd6be2498ecad874d5179254116ca1848a7931 (diff)
parent369c2a174cd8b8b8cc662a4fbc3d3c70a78bfa7a (diff)
Merge pull request #14733 from cakine/UnloadingProcessExitFx
Add test for order of raising AssemblyLoadContext.Unloading and AppDo…
Diffstat (limited to 'src')
-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");
+ }
+ }
+}