Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
tippmar-nr committed Aug 9, 2024
1 parent 12a0278 commit 349cff7
Showing 1 changed file with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,35 +88,39 @@ public AgentLogBase(ITestOutputHelper testLogger)

public abstract IEnumerable<string> GetFileLines();

public string GetAccountId(TimeSpan? timeoutOrZero = null)
public string GetAccountId()
{
var reportingAppLink = GetReportingAppLink(timeoutOrZero);
var reportingAppLink = GetReportingAppLink();
var reportingAppUri = new Uri(reportingAppLink);
var accountId = reportingAppUri.Segments[2];
if (accountId == null)
throw new Exception("Could not find account ID in second segment of reporting app link: " + reportingAppLink);
return accountId.TrimEnd('/');
}

public string GetApplicationId(TimeSpan? timeoutOrZero = null)
public string GetApplicationId()
{
var reportingAppLink = GetReportingAppLink(timeoutOrZero);
var reportingAppLink = GetReportingAppLink();
var reportingAppUri = new Uri(reportingAppLink);
var applicationId = reportingAppUri.Segments[4];
if (applicationId == null)
throw new Exception("Could not find application ID in second segment of reporting app link: " + reportingAppLink);
return applicationId.TrimEnd('/');
}

public string GetCrossProcessId(TimeSpan? timeoutOrZero = null)
public string GetCrossProcessId()
{
return $@"{GetAccountId()}#{GetApplicationId()}";
}

public string GetReportingAppLink(TimeSpan? timeoutOrZero = null)
private string GetReportingAppLink()
{
var match = WaitForLogLine(AgentReportingToLogLineRegex, timeoutOrZero);
return match.Groups[1].Value; }
var match = TryGetLogLine(AgentReportingToLogLineRegex);
if (!match.Success || match.Groups.Count < 2)
throw new Exception("Could not find reporting app link in log file.");

return match.Groups[1].Value;
}

public void WaitForConnect(TimeSpan? timeoutOrZero = null)
{
Expand Down

0 comments on commit 349cff7

Please sign in to comment.