Skip to content

Commit 4e7f797

Browse files
committed
custom args
1 parent 910ae24 commit 4e7f797

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

BrowserStack/BrowserStack Unit Tests/LocalTests.cs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void TestWorksWithBooleanOptions()
130130
local.setTunnel(tunnelMock.Object);
131131
local.start(options);
132132
tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
133-
tunnelMock.Verify(mock => mock.addBinaryArguments(It.IsRegex("-vvv.*-force.*-forcelocal*-forceproxy.*-onlyAutomate")), Times.Once());
133+
tunnelMock.Verify(mock => mock.addBinaryArguments(It.IsRegex("-vvv.*-force.*-forcelocal.*-forceproxy.*-onlyAutomate")), Times.Once());
134134
tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute), Times.Once());
135135
local.stop();
136136
}
@@ -160,6 +160,29 @@ public void TestWorksWithValueOptions()
160160
local.stop();
161161
}
162162

163+
[TestMethod]
164+
public void TestWorksWithCustomOptions()
165+
{
166+
options = new List<KeyValuePair<string, string>>();
167+
options.Add(new KeyValuePair<string, string>("key", "dummyKey"));
168+
options.Add(new KeyValuePair<string, string>("customBoolKey1", "true"));
169+
options.Add(new KeyValuePair<string, string>("customBoolKey2", "false"));
170+
options.Add(new KeyValuePair<string, string>("customKey1", "customValue1"));
171+
options.Add(new KeyValuePair<string, string>("customKey2", "customValue2"));
172+
173+
local = new LocalClass();
174+
Mock<BrowserStackTunnel> tunnelMock = new Mock<BrowserStackTunnel>();
175+
tunnelMock.Setup(mock => mock.Run("dummyKey", "", logAbsolute));
176+
local.setTunnel(tunnelMock.Object);
177+
local.start(options);
178+
tunnelMock.Verify(mock => mock.addBinaryPath(""), Times.Once);
179+
tunnelMock.Verify(mock => mock.addBinaryArguments(
180+
It.IsRegex("-customBoolKey1.*customBoolKey2.*-customKey1.*'customValue1'.*-customKey2.*'customValue2'")
181+
), Times.Once());
182+
tunnelMock.Verify(mock => mock.Run("dummyKey", "", logAbsolute), Times.Once());
183+
local.stop();
184+
}
185+
163186
[TestMethod]
164187
public void TestCallsFallbackOnFailure()
165188
{

BrowserStack/BrowserStack/Local.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,18 @@ private void addArgs(string key, string value)
6868
else if (key.Equals("logfile"))
6969
{
7070
customLogPath = value;
71+
}
72+
else if (key.Equals("verbose"))
73+
{
74+
7175
}
7276
else
7377
{
7478
result = valueCommands.Find(pair => pair.Key == key);
7579
if (!result.Equals(emptyStringPair))
7680
{
77-
argumentString += result.Value + " " + value + " ";
81+
argumentString += result.Value + " '" + value + "' ";
82+
return;
7883
}
7984

8085
result = booleanCommands.Find(pair => pair.Key == key);
@@ -83,8 +88,18 @@ private void addArgs(string key, string value)
8388
if (value.Trim().ToLower() == "true")
8489
{
8590
argumentString += result.Value + " ";
91+
return;
8692
}
8793
}
94+
95+
if (value.Trim().ToLower() == "true")
96+
{
97+
argumentString += "-" + key + " ";
98+
}
99+
else
100+
{
101+
argumentString += "-" + key + " '" + value + "' ";
102+
}
88103
}
89104
}
90105
private void setupLogging()

0 commit comments

Comments
 (0)