From 1a097e1e9119b9e4c7635372181021506d6567da Mon Sep 17 00:00:00 2001 From: mroloux Date: Tue, 20 Nov 2018 09:28:33 +0100 Subject: [PATCH] When key is not found when fetching a specific event report, None is returned to be consistent with the server-side API --- SeatsioDotNet.Test/EventReports/EventReportsTest.cs | 11 +++++++++++ SeatsioDotNet/EventReports/EventReports.cs | 6 +++++- SeatsioDotNet/SeatsioDotNet.csproj | 2 +- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/SeatsioDotNet.Test/EventReports/EventReportsTest.cs b/SeatsioDotNet.Test/EventReports/EventReportsTest.cs index d937b0d..f4abb65 100644 --- a/SeatsioDotNet.Test/EventReports/EventReportsTest.cs +++ b/SeatsioDotNet.Test/EventReports/EventReportsTest.cs @@ -89,6 +89,17 @@ public void BySpecificStatus() var report = Client.EventReports.ByStatus(evnt.Key, "lolzor"); Assert.Equal(2, report.Count()); + } + + [Fact] + public void BySpecificNonExistingStatus() + { + var chartKey = CreateTestChart(); + var evnt = Client.Events.Create(chartKey); + + var report = Client.EventReports.ByStatus(evnt.Key, "lolzor"); + + Assert.Null(report); } [Fact] diff --git a/SeatsioDotNet/EventReports/EventReports.cs b/SeatsioDotNet/EventReports/EventReports.cs index 5439e99..e50bbdd 100644 --- a/SeatsioDotNet/EventReports/EventReports.cs +++ b/SeatsioDotNet/EventReports/EventReports.cs @@ -116,7 +116,11 @@ private IEnumerable FetchReport(string reportType, string event .AddUrlSegment("reportType", reportType) .AddUrlSegment("filter", filter); var report = AssertOk(_restClient.Execute>>(restRequest)); - return report[filter]; + if (report.ContainsKey(filter)) + { + return report[filter]; + } + return null; } } } \ No newline at end of file diff --git a/SeatsioDotNet/SeatsioDotNet.csproj b/SeatsioDotNet/SeatsioDotNet.csproj index ccbe1c1..8e246ca 100644 --- a/SeatsioDotNet/SeatsioDotNet.csproj +++ b/SeatsioDotNet/SeatsioDotNet.csproj @@ -2,7 +2,7 @@ Library true - 46 + 47 mroloux;bverbeken Official Seats.io .NET API client Official Seats.io .NET API client