Skip to content

Commit 6640751

Browse files
Treat null as zero for session durations
If a session has a null duration, treat it as zero to fix deserialization exception.
1 parent 024929f commit 6640751

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/MartinCostello.BrowserStack.Automate/Session.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public class Session : IBrowserInfo
2626
/// <summary>
2727
/// Gets or sets the duration of the session in seconds.
2828
/// </summary>
29-
[JsonProperty("duration")]
29+
[JsonProperty("duration", NullValueHandling = NullValueHandling.Ignore)] // TODO Should be nullable, but don't want to break binary compatibility
3030
public int Duration { get; set; }
3131

3232
/// <summary>

tests/MartinCostello.BrowserStack.Automate.Tests/BrowserStackAutomateClientTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ private static void AssertSession(Session session, string expectedName)
978978
session.ProjectName.Should().NotBeNullOrEmpty();
979979
session.Reason.Should().NotBeNullOrEmpty();
980980
session.Status.Should().NotBeNullOrEmpty();
981-
session.Duration.Should().BeGreaterThan(0);
981+
session.Duration.Should().BeGreaterThan(-1);
982982
}
983983

984984
/// <summary>

0 commit comments

Comments
 (0)