<ItemGroup>
<Compile Include="CalendarHelpers.cs" />
<Compile Include="EndianessChecker.cs" />
- <Compile Include="Env.cs" />
<Compile Include="Generator.cs" />
<Compile Include="GlobLocHelper.cs" />
<Compile Include="Logging.cs" />
+++ /dev/null
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-using System;
-using System.IO;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using System.Security;
-using System.Text;
-
-namespace TestLibrary
-{
- public static partial class Env
- {
- const int MAX_PATH = 260;
- const int ERROR_ENVVAR_NOT_FOUND = 0xCB;
-
- public static string NewLine
- {
- get
- {
- if (Utilities.IsWindows)
- {
- return "\r\n";
- }
- else
- {
- return "\n";
- }
- }
- }
-
- public static string FileSeperator
- {
- get
- {
- if (Utilities.IsWindows)
- {
- return "\\";
- }
- else
- {
- return "/";
- }
- }
- }
-
- public static string VolumeSeperator
- {
- get
- {
- if (Utilities.IsWindows)
- {
- return ":";
- }
- else
- {
- return "/";
- }
- }
- }
-
- public static string AltFileSeperator
- {
- get
- {
- if (Utilities.IsWindows)
- {
- return "/";
- }
- else
- {
- return "\\";
- }
- }
- }
-
- public static string PathDelimiter
- {
- get
- {
- if (Utilities.IsWindows)
- {
- return ";";
- }
- else
- {
- return ":";
- }
- }
- }
-
- public static int MaxPath
- {
- get
- {
- return 248;
- }
- }
-
- public static int MaxFileName
- {
- get
- {
- return 260;
- }
- }
-
- public static String CurrentDirectory
- {
- get { return ""; }
- }
- }
-}
#else
Random rand = new Random();
- if (Env.GetEnvVariable("CORECLR_SEED") != null)
+ if (Environment.GetEnvironmentVariable("CORECLR_SEED") != null)
{
try
{
- seed = int.Parse(Env.GetEnvVariable("CORECLR_SEED"));
+ seed = int.Parse(Environment.GetEnvironmentVariable("CORECLR_SEED"));
}
catch (FormatException) { seed = rand.Next(); }
}
TestLibrary.TestFramework.LogError("001", "The result is not the value as expected");
retVal = false;
}
- if ((argumentOutOfRangeException.Message != "Specified argument was out of the range of valid values."+TestLibrary.Env.NewLine+"Parameter name: " + randValue) &
+ if ((argumentOutOfRangeException.Message != "Specified argument was out of the range of valid values."+Environment.NewLine+"Parameter name: " + randValue) &
(!argumentOutOfRangeException.Message.Contains("[Arg_ArgumentOutOfRangeException]")))
{
TestLibrary.TestFramework.LogError("002", "The result is not the value as expected" + argumentOutOfRangeException.Message);
{
string randValue = TestLibrary.Generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
ArgumentOutOfRangeException argumentOutOfRangeException = new ArgumentOutOfRangeException(randValue);
- if ((argumentOutOfRangeException.Message != "Specified argument was out of the range of valid values." + TestLibrary.Env.NewLine + "Parameter name: " + randValue) &
+ if ((argumentOutOfRangeException.Message != "Specified argument was out of the range of valid values." + Environment.NewLine + "Parameter name: " + randValue) &
(!argumentOutOfRangeException.Message.Contains("[Arg_ArgumentOutOfRangeException]")))
{
TestLibrary.TestFramework.LogError("001", "The result is not the value as expected");
string randValue = TestLibrary.Generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
string paramName = TestLibrary.Generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
ArgumentOutOfRangeException argumentOutOfRangeException = new ArgumentOutOfRangeException(paramName, randValue);
- if ((argumentOutOfRangeException.Message != randValue + "" + TestLibrary.Env.NewLine + "Parameter name: " + paramName) &
+ if ((argumentOutOfRangeException.Message != randValue + "" + Environment.NewLine + "Parameter name: " + paramName) &
(argumentOutOfRangeException.Message != randValue))
{
TestLibrary.TestFramework.LogError("003", "The result is not the value as expected");
string paramName = TestLibrary.Generator.GetString(-55, false, c_MIN_STRING_LENGTH, c_MAX_STRING_LENGTH);
string Value = null;
ArgumentOutOfRangeException argumentOutOfRangeException = new ArgumentOutOfRangeException(paramName, Value);
- if ((argumentOutOfRangeException.Message != "Exception of type 'System.ArgumentOutOfRangeException' was thrown." + TestLibrary.Env.NewLine + "Parameter name: " + paramName) &
+ if ((argumentOutOfRangeException.Message != "Exception of type 'System.ArgumentOutOfRangeException' was thrown." + Environment.NewLine + "Parameter name: " + paramName) &
(argumentOutOfRangeException.Message != "Exception of type 'System.ArgumentOutOfRangeException' was thrown."))
{
TestLibrary.TestFramework.LogError("005", "The result is not the value as expected");
const string c_TEST_DESC = "PosTest1: Verify the Path.AltDirectorySeparatorChar value is '/' ";
const string c_TEST_ID = "P001";
- char correctChar = Env.AltFileSeperator[0];
+ char correctChar = Utilities.IsWindows ? '/' : '/';
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
/// </summary>
public class PathCombine
{
+ char fileSeperator = Utilities.IsWindows ? '\\' : '/';
public static int Main()
{
const string c_TEST_DESC = "PosTest1: Verify Combine two paths . ";
const string c_TEST_ID = "P001";
- string path1 = @"mydir" + Env.FileSeperator + "myfolder" + Env.FileSeperator + "";
- string path2 = @"youfolder" + Env.FileSeperator + "youfile";
- string resPath = @"mydir" + Env.FileSeperator + "myfolder" + Env.FileSeperator + "youfolder" + Env.FileSeperator + "youfile";
+ string path1 = @"mydir" + fileSeperator + "myfolder" + fileSeperator + "";
+ string path2 = @"youfolder" + fileSeperator + "youfile";
+ string resPath = @"mydir" + fileSeperator + "myfolder" + fileSeperator + "youfolder" + fileSeperator + "youfile";
string newPath ;
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
const string c_TEST_DESC = "PosTest2: path1 does not end with a valid separator character. ";
const string c_TEST_ID = "P002";
- string path1 = @"mydir" + Env.FileSeperator + "myfolder";
- string path2 = @"youfolder" + Env.FileSeperator + "youfile";
- string resPath = @"mydir" + Env.FileSeperator + "myfolder" + Env.FileSeperator + "youfolder" + Env.FileSeperator + "youfile";
+ string path1 = @"mydir" + fileSeperator + "myfolder";
+ string path2 = @"youfolder" + fileSeperator + "youfile";
+ string resPath = @"mydir" + fileSeperator + "myfolder" + fileSeperator + "youfolder" + fileSeperator + "youfile";
string newPath;
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
const string c_TEST_ID = "P003";
string path1 = "";
- string path2 = @"yourfolder" + Env.FileSeperator + "" + Env.FileSeperator + "youfile";
- string resPath = @"yourfolder" + Env.FileSeperator + "" + Env.FileSeperator + "youfile";
+ string path2 = @"yourfolder" + fileSeperator + "" + fileSeperator + "youfile";
+ string resPath = @"yourfolder" + fileSeperator + "" + fileSeperator + "youfile";
string newPath;
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
const string c_TEST_DESC = "PosTest6: path2 have a willcard";
const string c_TEST_ID = "P006";
- string path1 = "mydir" + Env.FileSeperator + "my folder";
+ string path1 = "mydir" + fileSeperator + "my folder";
string path2 = "*.txt";
- string resPath = "mydir" + Env.FileSeperator + "my folder" + Env.FileSeperator + "*.txt";
+ string resPath = "mydir" + fileSeperator + "my folder" + fileSeperator + "*.txt";
string newPath;
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
const string c_TEST_DESC = "PosTest1: Verify the Path.DirectorySeparatorChar value is backslash... ";
const string c_TEST_ID = "P001";
- char correctChar = Env.FileSeperator[0];
+ char correctChar = Utilities.IsWindows ? '\\' : '/';
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
public class PathGetDirectoryName
{
private const int c_MAX_PATH_LEN = 256;
+ char fileSeperator = Utilities.IsWindows ? '\\' : '/';
public static int Main()
{
const string c_TEST_DESC = "PosTest1:the source path is a file name.";
const string c_TEST_ID = "P001";
- string sourcePath = @"C:" + Env.FileSeperator + "mydir" + Env.FileSeperator + "myfolder" + Env.FileSeperator + "test.txt";
- string directoryName = @"C:" + Env.FileSeperator + "mydir" + Env.FileSeperator + "myfolder";
+ string sourcePath = @"C:" + fileSeperator + "mydir" + fileSeperator + "myfolder" + fileSeperator + "test.txt";
+ string directoryName = @"C:" + fileSeperator + "mydir" + fileSeperator + "myfolder";
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
const string c_TEST_DESC = "PosTest1: Verify the Path.PathSeparator value is semicolon ... ";
const string c_TEST_ID = "P001";
- char correctChar = Env.PathDelimiter[0];
+ char correctChar = Utilities.IsWindows ? ';' : ':';
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
const string c_TEST_DESC = "PosTest1: Verify the Path.VolumeSeparatorChar value is colon ... ";
const string c_TEST_ID = "P001";
- char correctChar = Env.VolumeSeperator[0];
+ char correctChar = Utilities.IsWindows ? ':' : '/';
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
if (index == -1)
{
string errorDesc = "Message shoule contains the object name";
- errorDesc += TestLibrary.Env.NewLine + "objectName is " + name;
- errorDesc += TestLibrary.Env.NewLine + "message is " + message;
- errorDesc += TestLibrary.Env.NewLine + "exception's message is " + exception.Message;
+ errorDesc += Environment.NewLine + "objectName is " + name;
+ errorDesc += Environment.NewLine + "message is " + message;
+ errorDesc += Environment.NewLine + "exception's message is " + exception.Message;
TestLibrary.TestFramework.LogError("001 " + "TestID_" + c_TEST_ID, errorDesc);
retVal = false;
}
if (index == -1)
{
string errorDesc = "Message shoule contains the message";
- errorDesc += TestLibrary.Env.NewLine + "objectName is " + name;
- errorDesc += TestLibrary.Env.NewLine + "message is " + message;
- errorDesc += TestLibrary.Env.NewLine + "exception's message is " + exception.Message;
+ errorDesc += Environment.NewLine + "objectName is " + name;
+ errorDesc += Environment.NewLine + "message is " + message;
+ errorDesc += Environment.NewLine + "exception's message is " + exception.Message;
TestLibrary.TestFramework.LogError("001 " + "TestID_" + c_TEST_ID, errorDesc);
retVal = false;
}
if (index == -1)
{
string errorDesc = "Message shoule contains the message";
- errorDesc += TestLibrary.Env.NewLine + "objectName is empty";
- errorDesc += TestLibrary.Env.NewLine + "message parameter" + message;
- errorDesc += TestLibrary.Env.NewLine + "exception's message is " + exception.Message;
+ errorDesc += Environment.NewLine + "objectName is empty";
+ errorDesc += Environment.NewLine + "message parameter" + message;
+ errorDesc += Environment.NewLine + "exception's message is " + exception.Message;
TestLibrary.TestFramework.LogError("003 " + "TestID_" + c_TEST_ID, errorDesc);
retVal = false;
}
string assemblyName;
string actualFriendAssemblyName;
- assemblyName = "::B:" + TestLibrary.Env.FileSeperator + "\n\v\r\t\0myTestCase.dll";
+ assemblyName = "::B:" + System.IO.Path.DirectorySeparatorChar + "\n\v\r\t\0myTestCase.dll";
TestLibrary.TestFramework.BeginScenario(c_TEST_DESC);
try
{
string processorArchEnvVar = null;
-#if CORECLR
- processorArchEnvVar = TestLibrary.Env.GetEnvVariable("PROCESSOR_ARCHITECTURE");
-#else
processorArchEnvVar = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
-#endif
if ((processorArchEnvVar != null) && processorArchEnvVar.Equals("ARM", StringComparison.CurrentCultureIgnoreCase))
{
public void WriteLine(string str)
{
_actual += str;
- _actual += Env.NewLine;
+ _actual += Environment.NewLine;
// Console.WriteLine(str);
}