This commit is contained in:
@@ -35,6 +35,19 @@ namespace BritishHorseRacingApi.Tests
|
||||
Assert.Equal(totalMilliseconds, expectedValue);
|
||||
}
|
||||
|
||||
[Theory()]
|
||||
[InlineData("1m 15.39s(+0.34s)", 340)]
|
||||
[InlineData(null, null)]
|
||||
[InlineData(" ", null)]
|
||||
public void TestStopwatchStringDifferenceToMilliseconds(string time, double? expectedValue)
|
||||
{
|
||||
//Arrange
|
||||
//Act
|
||||
var totalMilliseconds = DataConverterHelper.StopwatchStringDifferenceToMilliseconds(time);
|
||||
//Assert
|
||||
Assert.Equal(totalMilliseconds, expectedValue);
|
||||
}
|
||||
|
||||
[Theory()]
|
||||
[InlineData("1m 1f 104y ", 2084)]
|
||||
[InlineData("1f 104y", 324)]
|
||||
|
||||
@@ -58,10 +58,13 @@ namespace BritishHorseRacingApi.Helpers
|
||||
return (T)Convert.ChangeType(group.Value, typeof(T));
|
||||
}
|
||||
|
||||
public static int StopwatchStringDifferenceToMilliseconds(string timeDifferenceString)
|
||||
public static int? StopwatchStringDifferenceToMilliseconds(string timeDifferenceString)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(timeDifferenceString))
|
||||
return null;
|
||||
|
||||
var match = _stopwatchTimeRegex.Match(timeDifferenceString);
|
||||
var lossDifference = GetComponent(match, "lossDifference", 0);
|
||||
var lossDifference = GetComponent(match, "lossDifference", 0d);
|
||||
return (int)TimeSpan.FromSeconds(lossDifference).TotalMilliseconds;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user