Skip to content

Commit

Permalink
Correct Properties on RecentEvents Object
Browse files Browse the repository at this point in the history
- Use "decimal" type for "PercentRank"
- Properly interpret "BestLapTime" as "TimeSpan" similar to other times

Fixes: #210
  • Loading branch information
AdrianJSClark committed Jul 1, 2024
1 parent 11f17e9 commit 2c795bf
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,13 +267,25 @@ public async Task GetMemberProfileSuccessfulAsync()

var memberProfileResponse = await sut.GetMemberProfileAsync().ConfigureAwait(false);

Assert.That(memberProfileResponse, Is.Not.Null);
Assert.That(memberProfileResponse!.Data, Is.Not.Null);

Assert.That(memberProfileResponse.RateLimitRemaining, Is.EqualTo(239));
Assert.That(memberProfileResponse.TotalRateLimit, Is.EqualTo(240));
Assert.That(memberProfileResponse.RateLimitReset, Is.EqualTo(new DateTimeOffset(2024, 3, 17, 11, 15, 55, TimeSpan.Zero)));
Assert.That(memberProfileResponse.DataExpires, Is.EqualTo(new DateTimeOffset(2024, 3, 17, 11, 29, 55, 769, TimeSpan.Zero)));
Assert.Multiple(() =>
{
Assert.That(memberProfileResponse, Is.Not.Null);
Assert.That(memberProfileResponse!.Data, Is.Not.Null);

Assert.That(memberProfileResponse.Data.CustomerId, Is.EqualTo(341554));
Assert.That(memberProfileResponse.Data.RecentEvents, Has.Length.EqualTo(5));

var sampleEvent = memberProfileResponse.Data.RecentEvents.FirstOrDefault(re => re.SubsessionId == 67375848);
Assert.That(sampleEvent, Is.Not.Null);
Assert.That(sampleEvent!.EventType, Is.EqualTo("RACE"));
Assert.That(sampleEvent.PercentRank, Is.EqualTo(0.8369153));
Assert.That(sampleEvent.BestLapTime, Is.EqualTo(TimeSpan.FromSeconds(76.8907)));

Assert.That(memberProfileResponse.RateLimitRemaining, Is.EqualTo(239));
Assert.That(memberProfileResponse.TotalRateLimit, Is.EqualTo(240));
Assert.That(memberProfileResponse.RateLimitReset, Is.EqualTo(new DateTimeOffset(2024, 3, 17, 11, 15, 55, TimeSpan.Zero)));
Assert.That(memberProfileResponse.DataExpires, Is.EqualTo(new DateTimeOffset(2024, 3, 17, 11, 29, 55, 769, TimeSpan.Zero)));
});
}

[Test(TestOf = typeof(DataClient))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@
"starting_position": 1,
"finish_position": 1,
"best_lap_time": 768907,
"percent_rank": -1,
"percent_rank": 0.8369153,
"car_id": 161,
"car_name": "Mercedes-AMG W13 E Performance",
"logo_url": null,
Expand Down
42 changes: 42 additions & 0 deletions src/Aydsko.iRacingData/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@
<Right>lib/net6.0/Aydsko.iRacingData.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Aydsko.iRacingData.Member.RecentEvents.get_BestLapTime</Target>
<Left>lib/net6.0/Aydsko.iRacingData.dll</Left>
<Right>lib/net6.0/Aydsko.iRacingData.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Aydsko.iRacingData.Member.RecentEvents.get_PercentRank</Target>
<Left>lib/net6.0/Aydsko.iRacingData.dll</Left>
<Right>lib/net6.0/Aydsko.iRacingData.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Aydsko.iRacingData.Series.Weather.get_RelHumidity</Target>
Expand Down Expand Up @@ -280,6 +294,20 @@
<Right>lib/net8.0/Aydsko.iRacingData.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Aydsko.iRacingData.Member.RecentEvents.get_BestLapTime</Target>
<Left>lib/net8.0/Aydsko.iRacingData.dll</Left>
<Right>lib/net8.0/Aydsko.iRacingData.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Aydsko.iRacingData.Member.RecentEvents.get_PercentRank</Target>
<Left>lib/net8.0/Aydsko.iRacingData.dll</Left>
<Right>lib/net8.0/Aydsko.iRacingData.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Aydsko.iRacingData.Series.Weather.get_RelHumidity</Target>
Expand Down Expand Up @@ -521,6 +549,20 @@
<Right>lib/netstandard2.0/Aydsko.iRacingData.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Aydsko.iRacingData.Member.RecentEvents.get_BestLapTime</Target>
<Left>lib/netstandard2.0/Aydsko.iRacingData.dll</Left>
<Right>lib/netstandard2.0/Aydsko.iRacingData.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Aydsko.iRacingData.Member.RecentEvents.get_PercentRank</Target>
<Left>lib/netstandard2.0/Aydsko.iRacingData.dll</Left>
<Right>lib/netstandard2.0/Aydsko.iRacingData.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Aydsko.iRacingData.Series.Weather.get_RelHumidity</Target>
Expand Down
8 changes: 5 additions & 3 deletions src/Aydsko.iRacingData/Member/RecentEvents.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// © 2023 Adrian Clark
// This file is licensed to you under the MIT license.

using Aydsko.iRacingData.Converters;

namespace Aydsko.iRacingData.Member;

public class RecentEvents
Expand Down Expand Up @@ -29,11 +31,11 @@ public class RecentEvents
[JsonPropertyName("finish_position")]
public int FinishPosition { get; set; }

[JsonPropertyName("best_lap_time")]
public int BestLapTime { get; set; }
[JsonPropertyName("best_lap_time"), JsonConverter(typeof(TenThousandthSecondDurationConverter))]
public TimeSpan? BestLapTime { get; set; }

[JsonPropertyName("percent_rank")]
public int PercentRank { get; set; }
public decimal PercentRank { get; set; }

[JsonPropertyName("car_id")]
public int CarId { get; set; }
Expand Down
6 changes: 4 additions & 2 deletions src/Aydsko.iRacingData/Package Release Notes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
BREAKING CHANGES:

-
- "RecentEvents" type:
- Properly interpret "BestLapTime" as "TimeSpan" similar to other times
- "PercentRank" is now a "decimal" type instead of "int"



Expand All @@ -15,5 +17,5 @@ Thanks for helping out with pull requests to the library!

Fixes / Changes:

-
- Incorrect datatype for RecentEvents.PercentRank field (Issue: #210)

0 comments on commit 2c795bf

Please sign in to comment.