protected void AssertContainsOption(
string args,
string expectedOption,
string expectedValue = null)
{
var option = string.Concat("-", expectedOption);
var chunks = args.Split(
" ".ToCharArray(),
StringSplitOptions.RemoveEmptyEntries);
var optionIdx = Array.IndexOf(chunks, option);
if (optionIdx == -1)
Assert.Fail(
"Expected Option: {0}\nWas not found in: {1}",
option, args);
if (expectedValue != null)
{
int valueIdx = optionIdx + 1;
bool isOutOfRange = valueIdx >= chunks.Length;
if (isOutOfRange || chunks[valueIdx] != expectedValue)
Assert.Fail(
"Expected Value For Option <{0}> : {1}\nActual: {2}",
expectedOption,
expectedValue,
isOutOfRange ? "<Has no value>" : chunks[valueIdx]);
}
}