From f423d59a994e0a6f9376d5a1547b959394a03201 Mon Sep 17 00:00:00 2001 From: Adrian Clark Date: Tue, 15 Aug 2023 21:46:21 +1000 Subject: [PATCH 1/5] Reset Package Validation Baseline & Suppressions --- .../Aydsko.iRacingData.csproj | 2 +- .../CompatibilitySuppressions.xml | 392 ------------------ 2 files changed, 1 insertion(+), 393 deletions(-) diff --git a/src/Aydsko.iRacingData/Aydsko.iRacingData.csproj b/src/Aydsko.iRacingData/Aydsko.iRacingData.csproj index dc9cc75..35f98df 100644 --- a/src/Aydsko.iRacingData/Aydsko.iRacingData.csproj +++ b/src/Aydsko.iRacingData/Aydsko.iRacingData.csproj @@ -6,7 +6,7 @@ true - 0.9.0 + 2303.1.0 true true true diff --git a/src/Aydsko.iRacingData/CompatibilitySuppressions.xml b/src/Aydsko.iRacingData/CompatibilitySuppressions.xml index c3d8435..044c191 100644 --- a/src/Aydsko.iRacingData/CompatibilitySuppressions.xml +++ b/src/Aydsko.iRacingData/CompatibilitySuppressions.xml @@ -1,402 +1,10 @@  - - CP0001 - T:Aydsko.iRacingData.Tests - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0001 - T:Aydsko.iRacingData.Websites - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - CP0001 T:Aydsko.iRacingData.Converters.DateOnlyConverter lib/netstandard2.0/Aydsko.iRacingData.dll lib/net6.0/Aydsko.iRacingData.dll - - CP0001 - T:Aydsko.iRacingData.Tests - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0001 - T:Aydsko.iRacingData.Websites - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonDriverStandingsAsync(System.Int32,System.Int32,System.Int32,System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonQualifyResultsAsync(System.Int32,System.Int32,System.Int32,System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonTeamStandingsAsync(System.Int32,System.Int32,System.Int32,System.Threading.CancellationToken) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonTimeTrialResultsAsync(System.Int32,System.Int32,System.Int32,System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonTimeTrialStandingsAsync(System.Int32,System.Int32,System.Int32,System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Member.MemberAward.get_CustId - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Member.MemberAward.set_CustId(System.Int32) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Member.RecentAwards.get_CustId - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Member.RecentAwards.set_CustId(System.Int32) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Results.SubsessionLap.set_Flags(System.Int32) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonDriverStandingsAsync(System.Int32,System.Int32,System.Int32,System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonQualifyResultsAsync(System.Int32,System.Int32,System.Int32,System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonTeamStandingsAsync(System.Int32,System.Int32,System.Int32,System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonTimeTrialResultsAsync(System.Int32,System.Int32,System.Int32,System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.IDataClient.GetSeasonTimeTrialStandingsAsync(System.Int32,System.Int32,System.Int32,System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Member.MemberAward.get_CustId - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Member.MemberAward.set_CustId(System.Int32) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Member.RecentAwards.get_CustId - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Member.RecentAwards.set_CustId(System.Int32) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0002 - M:Aydsko.iRacingData.Results.SubsessionLap.set_Flags(System.Int32) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetCustomerLeagueSessionsAsync(System.Boolean,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetLeagueMembershipAsync(System.Int32,System.Boolean,System.Threading.CancellationToken) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetMemberRecapAsync(System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetSpectatorSubsessionIdentifiersAsync(Aydsko.iRacingData.Common.EventType[],System.Threading.CancellationToken) - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetCustomerLeagueSessionsAsync(System.Boolean,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetLeagueMembershipAsync(System.Int32,System.Boolean,System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetMemberRecapAsync(System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetSeasonDriverStandingsAsync(System.Int32,System.Int32,System.Nullable{System.Int32},System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetSeasonDriverStandingsAsync(System.Int32,System.Int32,System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetSeasonQualifyResultsAsync(System.Int32,System.Int32,System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetSeasonTeamStandingsAsync(System.Int32,System.Int32,System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetSeasonTimeTrialResultsAsync(System.Int32,System.Int32,System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetSeasonTimeTrialStandingsAsync(System.Int32,System.Int32,System.Nullable{System.Int32},System.Nullable{System.Int32},System.Nullable{System.Int32},System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetSpectatorSubsessionIdentifiersAsync(Aydsko.iRacingData.Common.EventType[],System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetTrackAssetScreenshotUris(Aydsko.iRacingData.Common.Track,Aydsko.iRacingData.Tracks.TrackAssets) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetTrackAssetScreenshotUris(Aydsko.iRacingData.Tracks.Track,Aydsko.iRacingData.Tracks.TrackAssets) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0006 - M:Aydsko.iRacingData.IDataClient.GetTrackAssetScreenshotUrisAsync(System.Int32,System.Threading.CancellationToken) - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.CsvStringConverter - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.DateOnlyConverter - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.DateTimeConverter - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.ServiceStatusHistoryItemArrayConverter - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.StatusTimeStampConverter - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.StringFromStringOrNumberConverter - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.TenThousandthSecondDurationConverter - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.UriConverter - lib/net6.0/Aydsko.iRacingData.dll - lib/net6.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.CsvStringConverter - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.DateTimeConverter - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.ServiceStatusHistoryItemArrayConverter - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.StatusTimeStampConverter - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.StringFromStringOrNumberConverter - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.TenThousandthSecondDurationConverter - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - - - CP0009 - T:Aydsko.iRacingData.Converters.UriConverter - lib/netstandard2.0/Aydsko.iRacingData.dll - lib/netstandard2.0/Aydsko.iRacingData.dll - true - \ No newline at end of file From 764fc3bdb6d84b1eb1a04ec800972928e47e2f73 Mon Sep 17 00:00:00 2001 From: Adrian Clark Date: Tue, 15 Aug 2023 21:49:18 +1000 Subject: [PATCH 2/5] Fix Unit Test Builds Not sure how these "using" statements were removed, but seems that they are required. --- .../CapturedResponseValidationTests.cs | 1 + src/Aydsko.iRacingData.UnitTests/MockedHttpMessageHandler.cs | 1 + src/Aydsko.iRacingData.UnitTests/MockedHttpRequest.cs | 2 ++ src/Aydsko.iRacingData.UnitTests/MockedHttpTestBase.cs | 1 + 4 files changed, 5 insertions(+) diff --git a/src/Aydsko.iRacingData.UnitTests/CapturedResponseValidationTests.cs b/src/Aydsko.iRacingData.UnitTests/CapturedResponseValidationTests.cs index 163e2c8..a8f28f4 100644 --- a/src/Aydsko.iRacingData.UnitTests/CapturedResponseValidationTests.cs +++ b/src/Aydsko.iRacingData.UnitTests/CapturedResponseValidationTests.cs @@ -1,6 +1,7 @@ // © 2023 Adrian Clark // This file is licensed to you under the MIT license. +using System.Net.Http; using Aydsko.iRacingData.Constants; using Aydsko.iRacingData.Exceptions; using Aydsko.iRacingData.Leagues; diff --git a/src/Aydsko.iRacingData.UnitTests/MockedHttpMessageHandler.cs b/src/Aydsko.iRacingData.UnitTests/MockedHttpMessageHandler.cs index e611ead..5804c13 100644 --- a/src/Aydsko.iRacingData.UnitTests/MockedHttpMessageHandler.cs +++ b/src/Aydsko.iRacingData.UnitTests/MockedHttpMessageHandler.cs @@ -2,6 +2,7 @@ // This file is licensed to you under the MIT license. using System.Net; +using System.Net.Http; using System.Reflection; using System.Text; using System.Text.Json; diff --git a/src/Aydsko.iRacingData.UnitTests/MockedHttpRequest.cs b/src/Aydsko.iRacingData.UnitTests/MockedHttpRequest.cs index b6da6c8..612af8b 100644 --- a/src/Aydsko.iRacingData.UnitTests/MockedHttpRequest.cs +++ b/src/Aydsko.iRacingData.UnitTests/MockedHttpRequest.cs @@ -1,6 +1,8 @@ // © 2023 Adrian Clark // This file is licensed to you under the MIT license. +using System.Net.Http; + namespace Aydsko.iRacingData.UnitTests; public class MockedHttpRequest diff --git a/src/Aydsko.iRacingData.UnitTests/MockedHttpTestBase.cs b/src/Aydsko.iRacingData.UnitTests/MockedHttpTestBase.cs index 2a1d548..6d7ac49 100644 --- a/src/Aydsko.iRacingData.UnitTests/MockedHttpTestBase.cs +++ b/src/Aydsko.iRacingData.UnitTests/MockedHttpTestBase.cs @@ -2,6 +2,7 @@ // This file is licensed to you under the MIT license. using System.Net; +using System.Net.Http; namespace Aydsko.iRacingData.UnitTests; From da5be9145bad88db970bc9bccdc0804ec4bb1ef8 Mon Sep 17 00:00:00 2001 From: Adrian Clark Date: Tue, 15 Aug 2023 22:51:40 +1000 Subject: [PATCH 3/5] Primary Constructors, Static Arrays, & Other Warning Fixes --- .../Member/Security.cs | 4 +-- .../Tracks/GetTracksTests.cs | 4 +-- .../CapturedResponseValidationTests.cs | 6 +++-- .../DictionaryExtensionTests.cs | 2 ++ .../MockedHttpMessageHandler.cs | 25 ++++++++----------- ...cessfulLogin.json => SuccessfulLogin.json} | 0 src/Aydsko.iRacingData/CachingDataClient.cs | 21 +++++----------- src/Aydsko.iRacingData/DataClient.cs | 22 ++++------------ .../Tracks/TrackCoordinate.cs | 16 +++++------- 9 files changed, 37 insertions(+), 63 deletions(-) rename src/Aydsko.iRacingData.UnitTests/Responses/{SucessfulLogin.json => SuccessfulLogin.json} (100%) diff --git a/src/Aydsko.iRacingData.IntegrationTests/Member/Security.cs b/src/Aydsko.iRacingData.IntegrationTests/Member/Security.cs index d3ba903..778fe21 100644 --- a/src/Aydsko.iRacingData.IntegrationTests/Member/Security.cs +++ b/src/Aydsko.iRacingData.IntegrationTests/Member/Security.cs @@ -1,8 +1,8 @@ namespace Aydsko.iRacingData.IntegrationTests.Member; -internal class Security +internal static class Security { - public static string ObfuscateUsernameOrEmail(string input) + internal static string ObfuscateUsernameOrEmail(string input) { var segments = input.Split('@', 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); diff --git a/src/Aydsko.iRacingData.IntegrationTests/Tracks/GetTracksTests.cs b/src/Aydsko.iRacingData.IntegrationTests/Tracks/GetTracksTests.cs index 82e7070..f209fe6 100644 --- a/src/Aydsko.iRacingData.IntegrationTests/Tracks/GetTracksTests.cs +++ b/src/Aydsko.iRacingData.IntegrationTests/Tracks/GetTracksTests.cs @@ -10,8 +10,8 @@ internal sealed class GetTracksTests : DataClientIntegrationFixture { private Track[] tracksData; - [SetUp] - public async Task SetUp() + [OneTimeSetUp] + public async Task GetTrackDataAsync() { var tracksResponse = await Client.GetTracksAsync(CancellationToken.None).ConfigureAwait(false); tracksData = tracksResponse.Data; diff --git a/src/Aydsko.iRacingData.UnitTests/CapturedResponseValidationTests.cs b/src/Aydsko.iRacingData.UnitTests/CapturedResponseValidationTests.cs index a8f28f4..df67832 100644 --- a/src/Aydsko.iRacingData.UnitTests/CapturedResponseValidationTests.cs +++ b/src/Aydsko.iRacingData.UnitTests/CapturedResponseValidationTests.cs @@ -15,6 +15,8 @@ namespace Aydsko.iRacingData.UnitTests; public class CapturedResponseValidationTests : MockedHttpTestBase { + private static readonly int[] TestCustomerIds = new[] { 123456 }; + // NUnit will ensure that "SetUp" runs before each test so these can all be forced to "null". private DataClient sut = null!; @@ -209,7 +211,7 @@ public async Task GetDriverInfoWithLicensesSuccessfulAsync() { await MessageHandler.QueueResponsesAsync(nameof(GetDriverInfoWithLicensesSuccessfulAsync)).ConfigureAwait(false); - var carAssets = await sut.GetDriverInfoAsync(new[] { 123456 }, true).ConfigureAwait(false); + var carAssets = await sut.GetDriverInfoAsync(TestCustomerIds, true).ConfigureAwait(false); Assert.That(carAssets, Is.Not.Null); Assert.That(carAssets!.Data, Is.Not.Null); @@ -229,7 +231,7 @@ public async Task GetDriverInfoWithoutLicensesSuccessfulAsync() { await MessageHandler.QueueResponsesAsync(nameof(GetDriverInfoWithoutLicensesSuccessfulAsync)).ConfigureAwait(false); - var carAssets = await sut.GetDriverInfoAsync(new[] { 123456 }, false).ConfigureAwait(false); + var carAssets = await sut.GetDriverInfoAsync(TestCustomerIds, false).ConfigureAwait(false); Assert.That(carAssets, Is.Not.Null); Assert.That(carAssets!.Data, Is.Not.Null); diff --git a/src/Aydsko.iRacingData.UnitTests/DictionaryExtensionTests.cs b/src/Aydsko.iRacingData.UnitTests/DictionaryExtensionTests.cs index d16b5be..059a536 100644 --- a/src/Aydsko.iRacingData.UnitTests/DictionaryExtensionTests.cs +++ b/src/Aydsko.iRacingData.UnitTests/DictionaryExtensionTests.cs @@ -10,6 +10,7 @@ public KeyValuePair CheckAddParameterIfNotNull(T value) return parameters.ElementAt(0); } +#pragma warning disable CA1861 // Avoid constant arrays as arguments - not worth it for these unit test cases. public static IEnumerable GetTestCases() { yield return new TestCaseData("foo").Returns(new KeyValuePair("value", "foo")); @@ -19,4 +20,5 @@ public static IEnumerable GetTestCases() yield return new TestCaseData(true).Returns(new KeyValuePair("value", "true")); yield return new TestCaseData(Common.EventType.Practice).Returns(new KeyValuePair("value", "2")); } +#pragma warning restore CA1861 // Avoid constant arrays as arguments } diff --git a/src/Aydsko.iRacingData.UnitTests/MockedHttpMessageHandler.cs b/src/Aydsko.iRacingData.UnitTests/MockedHttpMessageHandler.cs index 5804c13..3e25fb4 100644 --- a/src/Aydsko.iRacingData.UnitTests/MockedHttpMessageHandler.cs +++ b/src/Aydsko.iRacingData.UnitTests/MockedHttpMessageHandler.cs @@ -17,6 +17,8 @@ public class MockedHttpMessageHandler : HttpMessageHandler public Queue RequestContent { get; } = new(); public Queue Responses { get; } = new(); + private static readonly string[] SuccessfulLoginResponse = new[] { "Aydsko.iRacingData.UnitTests.Responses.SuccessfulLogin.json" }; + public MockedHttpMessageHandler(CookieContainer cookieContainer) { this.cookieContainer = cookieContainer; @@ -67,11 +69,9 @@ protected override Task SendAsync(HttpRequestMessage reques public async Task QueueResponsesAsync(string testName, bool prefixLoginResponse = true) { - var manifestResourceNames = (prefixLoginResponse - ? new[] { "Aydsko.iRacingData.UnitTests.Responses.SucessfulLogin.json" } - : Array.Empty() - ).Concat(ResourceAssembly.GetManifestResourceNames() - .Where(mrn => mrn.StartsWith($"Aydsko.iRacingData.UnitTests.Responses.{testName}", StringComparison.InvariantCultureIgnoreCase))); + var manifestResourceNames = (prefixLoginResponse ? SuccessfulLoginResponse : Array.Empty()) + .Concat(ResourceAssembly.GetManifestResourceNames() + .Where(mrn => mrn.StartsWith($"Aydsko.iRacingData.UnitTests.Responses.{testName}", StringComparison.InvariantCultureIgnoreCase))); foreach (var manifestName in manifestResourceNames) { @@ -88,8 +88,8 @@ public async Task QueueResponsesAsync(string testName, bool prefixLoginResponse var responseDictionary = responseDocument!.RootElement.EnumerateObject() .ToDictionary(prop => prop.Name, prop => prop.Value); - if (!responseDictionary.ContainsKey("statuscode") - || !Enum.TryParse(responseDictionary["statuscode"].ToString(), out var statusCode)) + if (!responseDictionary.TryGetValue("statuscode", out var value) + || !Enum.TryParse(value.ToString(), out var statusCode)) { statusCode = HttpStatusCode.OK; } @@ -105,14 +105,9 @@ public async Task QueueResponsesAsync(string testName, bool prefixLoginResponse .ToDictionary(prop => prop.Name, prop => { - if (prop.Value.ValueKind == JsonValueKind.Array) - { - return prop.Value.EnumerateArray().Select(e => e.ToString()).ToArray(); - } - else - { - return new[] { prop.Value.GetString() }; - } + return prop.Value.ValueKind == JsonValueKind.Array + ? prop.Value.EnumerateArray().Select(e => e.ToString()).ToArray() + : (new[] { prop.Value.GetString() }); }).ToArray()) { responseMessage.Headers.Add(header.Key, header.Value); diff --git a/src/Aydsko.iRacingData.UnitTests/Responses/SucessfulLogin.json b/src/Aydsko.iRacingData.UnitTests/Responses/SuccessfulLogin.json similarity index 100% rename from src/Aydsko.iRacingData.UnitTests/Responses/SucessfulLogin.json rename to src/Aydsko.iRacingData.UnitTests/Responses/SuccessfulLogin.json diff --git a/src/Aydsko.iRacingData/CachingDataClient.cs b/src/Aydsko.iRacingData/CachingDataClient.cs index fdf0876..61106a1 100644 --- a/src/Aydsko.iRacingData/CachingDataClient.cs +++ b/src/Aydsko.iRacingData/CachingDataClient.cs @@ -7,22 +7,13 @@ namespace Aydsko.iRacingData; -internal class CachingDataClient : DataClient +internal class CachingDataClient(HttpClient httpClient, + ILogger logger, + iRacingDataClientOptions options, + CookieContainer cookieContainer, + IMemoryCache memoryCache) + : DataClient(httpClient, logger, options, cookieContainer) { - private readonly IMemoryCache memoryCache; - private readonly ILogger logger; - - public CachingDataClient(HttpClient httpClient, - ILogger logger, - iRacingDataClientOptions options, - CookieContainer cookieContainer, - IMemoryCache memoryCache) - : base(httpClient, logger, options, cookieContainer) - { - this.logger = logger; - this.memoryCache = memoryCache; - } - protected override async Task> CreateResponseViaInfoLinkAsync(Uri infoLinkUri, JsonTypeInfo jsonTypeInfo, CancellationToken cancellationToken) diff --git a/src/Aydsko.iRacingData/DataClient.cs b/src/Aydsko.iRacingData/DataClient.cs index 80ace9b..f994498 100644 --- a/src/Aydsko.iRacingData/DataClient.cs +++ b/src/Aydsko.iRacingData/DataClient.cs @@ -26,26 +26,14 @@ namespace Aydsko.iRacingData; -internal class DataClient : IDataClient +internal class DataClient(HttpClient httpClient, + ILogger logger, + iRacingDataClientOptions options, + CookieContainer cookieContainer) + : IDataClient { - private readonly HttpClient httpClient; - private readonly ILogger logger; - private readonly iRacingDataClientOptions options; - private readonly CookieContainer cookieContainer; - public bool IsLoggedIn { get; private set; } - public DataClient(HttpClient httpClient, - ILogger logger, - iRacingDataClientOptions options, - CookieContainer cookieContainer) - { - this.httpClient = httpClient; - this.logger = logger; - this.options = options; - this.cookieContainer = cookieContainer; - } - /// public void UseUsernameAndPassword(string username, string password, bool passwordIsEncoded) { diff --git a/src/Aydsko.iRacingData/Tracks/TrackCoordinate.cs b/src/Aydsko.iRacingData/Tracks/TrackCoordinate.cs index 5e73cc0..dfb4282 100644 --- a/src/Aydsko.iRacingData/Tracks/TrackCoordinate.cs +++ b/src/Aydsko.iRacingData/Tracks/TrackCoordinate.cs @@ -6,18 +6,14 @@ namespace Aydsko.iRacingData.Tracks; /// Represents the latitude and longitude of a track. -public struct TrackCoordinate : IEquatable +public struct TrackCoordinate(double latitude, double longitude) : IEquatable { + private static readonly char[] CoordinatePartSeparator = new[] { ',' }; + /// Latitude value. - public double Latitude { get; private set; } + public double Latitude { get; private set; } = latitude; /// Longitude value. - public double Longitude { get; private set; } - - public TrackCoordinate(double latitude, double longitude) - { - Latitude = latitude; - Longitude = longitude; - } + public double Longitude { get; private set; } = longitude; /// Attempt to parse the given string into a object. /// The value to parse. @@ -26,7 +22,7 @@ public TrackCoordinate(double latitude, double longitude) public static bool TryParse(string? input, out TrackCoordinate? result) { if (input is null - || (input.Split(new[] { ',' }, 2, StringSplitOptions.RemoveEmptyEntries) is not string[] values) + || (input.Split(CoordinatePartSeparator, 2, StringSplitOptions.RemoveEmptyEntries) is not string[] values) || (!double.TryParse(values[0], NumberStyles.Number, CultureInfo.InvariantCulture, out var lat)) || (!double.TryParse(values[1], NumberStyles.Number, CultureInfo.InvariantCulture, out var lon))) { From e4f9ecb87f48f1a73b07c7d0ffdae7f41b7bcff4 Mon Sep 17 00:00:00 2001 From: Adrian Clark Date: Tue, 15 Aug 2023 23:01:06 +1000 Subject: [PATCH 4/5] Update Test Packages & MinVer --- .../Aydsko.iRacingData.IntegrationTests.csproj | 6 +++--- .../Aydsko.iRacingData.UnitTests.csproj | 6 +++--- src/Aydsko.iRacingData/Aydsko.iRacingData.csproj | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Aydsko.iRacingData.IntegrationTests/Aydsko.iRacingData.IntegrationTests.csproj b/src/Aydsko.iRacingData.IntegrationTests/Aydsko.iRacingData.IntegrationTests.csproj index 124c956..bbb37a7 100644 --- a/src/Aydsko.iRacingData.IntegrationTests/Aydsko.iRacingData.IntegrationTests.csproj +++ b/src/Aydsko.iRacingData.IntegrationTests/Aydsko.iRacingData.IntegrationTests.csproj @@ -14,14 +14,14 @@ - + - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Aydsko.iRacingData.UnitTests/Aydsko.iRacingData.UnitTests.csproj b/src/Aydsko.iRacingData.UnitTests/Aydsko.iRacingData.UnitTests.csproj index c1df17d..572afd2 100644 --- a/src/Aydsko.iRacingData.UnitTests/Aydsko.iRacingData.UnitTests.csproj +++ b/src/Aydsko.iRacingData.UnitTests/Aydsko.iRacingData.UnitTests.csproj @@ -8,10 +8,10 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Aydsko.iRacingData/Aydsko.iRacingData.csproj b/src/Aydsko.iRacingData/Aydsko.iRacingData.csproj index 35f98df..dbe3c08 100644 --- a/src/Aydsko.iRacingData/Aydsko.iRacingData.csproj +++ b/src/Aydsko.iRacingData/Aydsko.iRacingData.csproj @@ -77,7 +77,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 3ac5331453547fe145c3e2ffc1d9125809afe4ff Mon Sep 17 00:00:00 2001 From: Adrian Clark Date: Tue, 15 Aug 2023 23:23:24 +1000 Subject: [PATCH 5/5] Use .NET 8 --- .github/workflows/_build-docs.yml | 4 ++-- .github/workflows/_build.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/_build-docs.yml b/.github/workflows/_build-docs.yml index 5dd66bc..be782f4 100644 --- a/.github/workflows/_build-docs.yml +++ b/.github/workflows/_build-docs.yml @@ -19,9 +19,9 @@ jobs: fetch-depth: 0 # Required for MinVer to work properly - name: 'Setup .NET SDK' - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: - dotnet-version: '7.x' + dotnet-version: '8.x' - run: dotnet tool update -g docfx shell: pwsh diff --git a/.github/workflows/_build.yml b/.github/workflows/_build.yml index 00346fe..d12eb17 100644 --- a/.github/workflows/_build.yml +++ b/.github/workflows/_build.yml @@ -19,9 +19,9 @@ jobs: fetch-depth: 0 # Required for MinVer to work properly - name: 'Setup .NET SDK' - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v3 with: - dotnet-version: '6.x' + dotnet-version: '8.x' - name: 'Build Solution' id: build-solution