Skip to content

Commit

Permalink
Rename
Browse files Browse the repository at this point in the history
  • Loading branch information
FriggaHel committed Mar 22, 2024
1 parent 61ae201 commit 99f87b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions visual-dotnet/SauceLabs.Visual/VisualCheckOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,17 @@ public class VisualCheckOptions

private bool HasIncompleteTestContext() => string.IsNullOrEmpty(SuiteName) || string.IsNullOrEmpty(TestName);

internal void PopulateTestContext(string callerMemberName, string? previousSuiteName)
internal void EnsureTestContextIsPopulated(string callerMemberName, string? previousSuiteName)
{
if (!string.IsNullOrEmpty(callerMemberName) && HasIncompleteTestContext())
if (string.IsNullOrEmpty(callerMemberName) || HasIncompleteTestContext())
{
var stack = new StackTrace();
var frame = stack.GetFrames()?.FirstOrDefault(f => f.GetMethod().Name == callerMemberName);
SuiteName ??= frame?.GetMethod().DeclaringType?.FullName ?? previousSuiteName;
TestName ??= callerMemberName;
return;
}

var stack = new StackTrace();
var frame = stack.GetFrames()?.FirstOrDefault(f => f.GetMethod().Name == callerMemberName);
SuiteName ??= frame?.GetMethod().DeclaringType?.FullName ?? previousSuiteName;
TestName ??= callerMemberName;
}
}
}
2 changes: 1 addition & 1 deletion visual-dotnet/SauceLabs.Visual/VisualClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public Task<string> VisualCheck(string name, VisualCheckOptions? options = null,
[CallerMemberName] string callerMemberName = "")
{
options ??= new VisualCheckOptions();
options.PopulateTestContext(callerMemberName, _previousSuiteName);
options.EnsureTestContextIsPopulated(callerMemberName, _previousSuiteName);
_previousSuiteName = options.SuiteName;
return VisualCheckAsync(name, options);
}
Expand Down

0 comments on commit 99f87b6

Please sign in to comment.