Skip to content

Commit

Permalink
Improved string representation of AppManagerOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmcroft committed Jun 18, 2021
1 parent 9e485e1 commit e699e8a
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 deletions.
30 changes: 29 additions & 1 deletion src/Legerity.Core/Android/AndroidAppManagerOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace Legerity.Android
{
using System;
using System.Collections.Generic;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Enums;

Expand Down Expand Up @@ -270,7 +271,34 @@ public void Configure((string, object)[] additionalOptions)
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return $"{base.ToString()}, App ID [{this.AppId}]";
return $"Platform [Android], {base.ToString()}, {this.GetOptionDetails()}";
}

private string GetOptionDetails()
{
var options = new List<string>();

if (!string.IsNullOrWhiteSpace(this.AppId))
{
options.Add($"App ID [{this.AppId}]");
}

if (!string.IsNullOrWhiteSpace(this.AppPath))
{
options.Add($"App Path [{this.AppPath}]");
}

if (!string.IsNullOrWhiteSpace(this.DeviceId))
{
options.Add($"Device ID [{this.DeviceId}]");
}

if (!string.IsNullOrWhiteSpace(this.DeviceName))
{
options.Add($"Device Name [{this.DeviceName}]");
}

return string.Join(", ", options);
}
}
}
25 changes: 24 additions & 1 deletion src/Legerity.Core/IOS/IOSAppManagerOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Legerity.IOS
{
using System.Collections.Generic;
using OpenQA.Selenium.Appium;
using OpenQA.Selenium.Appium.Enums;

Expand Down Expand Up @@ -119,7 +120,29 @@ public void Configure((string, object)[] additionalOptions)
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return $"{base.ToString()}, App ID [{this.AppId}]";
return $"Platform [IOS], {base.ToString()}, {this.GetOptionDetails()}";
}

private string GetOptionDetails()
{
var options = new List<string>();

if (!string.IsNullOrWhiteSpace(this.AppId))
{
options.Add($"App ID [{this.AppId}]");
}

if (!string.IsNullOrWhiteSpace(this.DeviceId))
{
options.Add($"Device ID [{this.DeviceId}]");
}

if (!string.IsNullOrWhiteSpace(this.DeviceName))
{
options.Add($"Device Name [{this.DeviceName}]");
}

return string.Join(", ", options);
}
}
}
15 changes: 14 additions & 1 deletion src/Legerity.Core/Web/WebAppManagerOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Legerity.Web
{
using System.Collections.Generic;
using System.Drawing;

/// <summary>
Expand Down Expand Up @@ -48,7 +49,19 @@ public WebAppManagerOptions(WebAppDriverType driverType, string driverDirectoryP
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return $"{base.ToString()}, App URL [{this.Url}]";
return $"Platform [{this.DriverType}], {base.ToString()}, {this.GetOptionDetails()}";
}

private string GetOptionDetails()
{
var options = new List<string>();

if (!string.IsNullOrWhiteSpace(this.Url))
{
options.Add($"URL [{this.Url}]");
}

return string.Join(", ", options);
}
}

Expand Down
15 changes: 14 additions & 1 deletion src/Legerity.Core/Windows/WindowsAppManagerOptions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace Legerity.Windows
{
using System.Collections.Generic;
using Helpers;
using OpenQA.Selenium.Appium;

Expand Down Expand Up @@ -86,7 +87,19 @@ public void Configure((string, object)[] additionalOptions)
/// <returns>A string that represents the current object.</returns>
public override string ToString()
{
return $"{base.ToString()}, App ID [{this.AppId}]";
return $"Platform [Windows], {base.ToString()}, {this.GetOptionDetails()}";
}

private string GetOptionDetails()
{
var options = new List<string>();

if (!string.IsNullOrWhiteSpace(this.AppId))
{
options.Add($"App ID [{this.AppId}]");
}

return string.Join(", ", options);
}
}
}

0 comments on commit e699e8a

Please sign in to comment.