Skip to content

Commit

Permalink
Update TestSessionConfiguration.cs (#14934)
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 authored Feb 13, 2024
1 parent 0435f08 commit c46b0fe
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/Libraries/TestServices/TestSessionConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,24 @@ public class TestSessionConfiguration
/// </summary>
public Version RequestedLibraryVersion2 { get; private set; }

private static string TryGetFullPath(string dynamoCoreDirectory)
{
string output = dynamoCoreDirectory;
if (!string.IsNullOrEmpty(dynamoCoreDirectory))
{
try
{
if (!Path.IsPathFullyQualified(dynamoCoreDirectory))
{// Try to get the full path
output = Path.GetFullPath(dynamoCoreDirectory);
}
}
catch
{}
}
return output;
}

/// <summary>
/// This constructor does not read configuration from a config file, the configuration properties are
/// set directly by the parameters passed to this constructor.
Expand All @@ -41,7 +59,7 @@ public class TestSessionConfiguration
/// <param name="requestedVersion"></param>
public TestSessionConfiguration(string dynamoCoreDirectory, Version requestedVersion)
{
DynamoCorePath = dynamoCoreDirectory;
DynamoCorePath = TryGetFullPath(dynamoCoreDirectory);
RequestedLibraryVersion2 = requestedVersion;
}

Expand All @@ -68,6 +86,8 @@ public TestSessionConfiguration(string dynamoCoreDirectory, string configFileDir
configPath = Path.Combine(configFileDirectory, CONFIG_FILE_NAME);
}

dynamoCoreDirectory = TryGetFullPath(dynamoCoreDirectory);

// If a config file cannot be found, fall back to
// using the executing assembly's directory for core
// and version 219 for the shape manager.
Expand All @@ -86,7 +106,9 @@ public TestSessionConfiguration(string dynamoCoreDirectory, string configFileDir
var config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);

var dir = GetAppSetting(config, "DynamoBasePath");
DynamoCorePath = string.IsNullOrEmpty(dir) ? dynamoCoreDirectory : dir;


DynamoCorePath = string.IsNullOrEmpty(dir) ? dynamoCoreDirectory : TryGetFullPath(dir);

// if an old client supplies an older format test config we should still load it.
var versionStrOld = GetAppSetting(config, "RequestedLibraryVersion");
Expand Down

0 comments on commit c46b0fe

Please sign in to comment.