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:
authorJose Perez Rodriguez <joperezr@microsoft.com>2017-01-06 01:03:56 +0300
committerJose Perez Rodriguez <joperezr@microsoft.com>2017-01-06 01:03:56 +0300
commit44b68e694948065c1b61457cec125d3d64c1fa22 (patch)
treefc7093fb753c57f29ce42de9dd64ecc435d2e95c /src/System.Runtime.Extensions/tests
parentd4d3bbdf7b8b35b5a330c94427051582470531d0 (diff)
parent05ae65fd6b51f865750e8d400c60511fcdbbbfb5 (diff)
Merge branch master into dev/eng
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/Environment.GetEnvironmentVariable.cs48
-rw-r--r--src/System.Runtime.Extensions/tests/System/EnvironmentTests.cs2
-rw-r--r--src/System.Runtime.Extensions/tests/System/UnloadingAndProcessExitTests.netcoreapp1.1.cs37
4 files changed, 87 insertions, 1 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 8173f0c8f1..4c8148131f 100644
--- a/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
+++ b/src/System.Runtime.Extensions/tests/System.Runtime.Extensions.Tests.csproj
@@ -46,6 +46,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/Environment.GetEnvironmentVariable.cs b/src/System.Runtime.Extensions/tests/System/Environment.GetEnvironmentVariable.cs
index e5add5ba72..c0c45b7688 100644
--- a/src/System.Runtime.Extensions/tests/System/Environment.GetEnvironmentVariable.cs
+++ b/src/System.Runtime.Extensions/tests/System/Environment.GetEnvironmentVariable.cs
@@ -134,7 +134,55 @@ namespace System.Tests
}
}
+ public void EnumerateYieldsDictionaryEntryFromIEnumerable()
+ {
+ // GetEnvironmentVariables has always yielded DictionaryEntry from IEnumerable
+ IDictionary vars = Environment.GetEnvironmentVariables();
+ IEnumerator enumerator = ((IEnumerable)vars).GetEnumerator();
+ if (enumerator.MoveNext())
+ {
+ Assert.IsType<DictionaryEntry>(enumerator.Current);
+ }
+ else
+ {
+ Assert.Throws<InvalidOperationException>(() => enumerator.Current);
+ }
+ }
+
#if netstandard17
+ public void EnvironmentVariablesAreHashtable()
+ {
+ // On NetFX, the type returned was always Hashtable
+ Assert.IsType<Hashtable>(Environment.GetEnvironmentVariables());
+ }
+
+ [InlineData(EnvironmentVariableTarget.Process)]
+ [InlineData(EnvironmentVariableTarget.Machine)]
+ [InlineData(EnvironmentVariableTarget.User)]
+ public void EnvironmentVariablesAreHashtable(EnvironmentVariableTarget target)
+ {
+ // On NetFX, the type returned was always Hashtable
+ Assert.IsType<Hashtable>(Environment.GetEnvironmentVariables(target));
+ }
+
+ [InlineData(EnvironmentVariableTarget.Process)]
+ [InlineData(EnvironmentVariableTarget.Machine)]
+ [InlineData(EnvironmentVariableTarget.User)]
+ public void EnumerateYieldsDictionaryEntryFromIEnumerable(EnvironmentVariableTarget target)
+ {
+ // GetEnvironmentVariables has always yielded DictionaryEntry from IEnumerable
+ IDictionary vars = Environment.GetEnvironmentVariables(target);
+ IEnumerator enumerator = ((IEnumerable)vars).GetEnumerator();
+ if (enumerator.MoveNext())
+ {
+ Assert.IsType<DictionaryEntry>(enumerator.Current);
+ }
+ else
+ {
+ Assert.Throws<InvalidOperationException>(() => enumerator.Current);
+ }
+ }
+
[OuterLoop] // manipulating environment variables broader in scope than the process
[Theory]
[InlineData(EnvironmentVariableTarget.Process)]
diff --git a/src/System.Runtime.Extensions/tests/System/EnvironmentTests.cs b/src/System.Runtime.Extensions/tests/System/EnvironmentTests.cs
index 86ed3a434b..51561a2ad3 100644
--- a/src/System.Runtime.Extensions/tests/System/EnvironmentTests.cs
+++ b/src/System.Runtime.Extensions/tests/System/EnvironmentTests.cs
@@ -349,7 +349,7 @@ namespace System.Tests
internal static extern int GetLogicalDrives();
[DllImport("shell32.dll", SetLastError = false, BestFitMapping = false, ExactSpelling = true)]
- internal unsafe static extern int SHGetFolderPathW(
+ internal static extern unsafe int SHGetFolderPathW(
IntPtr hwndOwner,
int nFolder,
IntPtr hToken,
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");
+ }
+ }
+}