diff --git a/OddsCollector.Common.Tests/KeyVault/Client/KeyVaultClientTests.cs b/OddsCollector.Common.Tests/KeyVault/Client/KeyVaultClientTests.cs index 4e9a4b3..a2da9c5 100644 --- a/OddsCollector.Common.Tests/KeyVault/Client/KeyVaultClientTests.cs +++ b/OddsCollector.Common.Tests/KeyVault/Client/KeyVaultClientTests.cs @@ -21,7 +21,7 @@ public void Constructor_WithValidDependenciest_ReturnsNewInstance() [Test] public void Constructor_WithNullSecretClient_ThrowsException() { - Action action = () => + var action = () => { _ = new KeyVaultClient(null); }; diff --git a/OddsCollector.Common.Tests/KeyVault/Secrets/SecretClientFactoryTests.cs b/OddsCollector.Common.Tests/KeyVault/Secrets/SecretClientFactoryTests.cs index 9818a95..34b8ff9 100644 --- a/OddsCollector.Common.Tests/KeyVault/Secrets/SecretClientFactoryTests.cs +++ b/OddsCollector.Common.Tests/KeyVault/Secrets/SecretClientFactoryTests.cs @@ -21,7 +21,7 @@ public void CreateSecretClient_WithValidName_ReturnsNewInstance() [TestCase(null)] public void CreateSecretClient_WithNullOrEmptyString_ThrowsException(string? vaultName) { - Action action = () => + var action = () => { _ = SecretClientFactory.CreateSecretClient(vaultName); }; diff --git a/OddsCollector.Common.Tests/OddsApi/Client/OddsClientTests.cs b/OddsCollector.Common.Tests/OddsApi/Client/OddsClientTests.cs index 9438a32..468ba9d 100644 --- a/OddsCollector.Common.Tests/OddsApi/Client/OddsClientTests.cs +++ b/OddsCollector.Common.Tests/OddsApi/Client/OddsClientTests.cs @@ -28,7 +28,7 @@ public void Constructor_WithNullWebApiClient_ThrowsException() var keyVaultClientStub = Substitute.For(); var converterStub = Substitute.For(); - Action action = () => + var action = () => { _ = new OddsClient(null, keyVaultClientStub, converterStub); }; @@ -42,7 +42,7 @@ public void Constructor_WithNullKeyVaultClient_ThrowsException() var webApiClientStub = Substitute.For(); var converterStub = Substitute.For(); - Action action = () => + var action = () => { _ = new OddsClient(webApiClientStub, null, converterStub); }; @@ -56,7 +56,7 @@ public void Constructor_WithNullConverter_ThrowsException() var webApiClientStub = Substitute.For(); var keyVaultClientStub = Substitute.For(); - Action action = () => + var action = () => { _ = new OddsClient(webApiClientStub, keyVaultClientStub, null); }; @@ -210,7 +210,7 @@ public void GetUpcomingEventsAsync_WithNullLeagues_ThrowsException() var oddsClient = new OddsClient(webApiClient, keyVaultClient, converter); - Action action = () => + var action = () => { _ = oddsClient.GetUpcomingEventsAsync(leagues: null).GetAwaiter().GetResult(); }; @@ -227,7 +227,7 @@ public void GetEventResultsAsync_WithNullLeagues_ThrowsException() var oddsClient = new OddsClient(webApiClient, keyVaultClient, converter); - Action action = () => + var action = () => { _ = oddsClient.GetEventResultsAsync(leagues: null).GetAwaiter().GetResult(); }; diff --git a/OddsCollector.Common.Tests/OddsApi/Converter/OddsApiObjectConverterTests.cs b/OddsCollector.Common.Tests/OddsApi/Converter/OddsApiObjectConverterTests.cs index 0a0916e..0c8c60e 100644 --- a/OddsCollector.Common.Tests/OddsApi/Converter/OddsApiObjectConverterTests.cs +++ b/OddsCollector.Common.Tests/OddsApi/Converter/OddsApiObjectConverterTests.cs @@ -15,10 +15,11 @@ public void ToUpcomingEvents_WithOddList_ReturnsConvertedEvents() var timestamp = DateTime.UtcNow; var traceId = Guid.NewGuid(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().GetRawUpcomingEvent(), - new RawUpcomingEventBuilder().SetDefaults().SetId("1766194919f1cbfbd846576434f0499b").GetRawUpcomingEvent() + new RawUpcomingEventBuilder().SetDefaults().SetId("1766194919f1cbfbd846576434f0499b") + .GetRawUpcomingEvent() }; var upcomingEvents = converter.ToUpcomingEvents(rawUpcomingEvents, traceId, timestamp); @@ -75,9 +76,7 @@ public void ToUpcomingEvents_WithEmptyOddList_ReturnsEmptyConvertedEventsList() var timestamp = DateTime.UtcNow; var traceId = Guid.NewGuid(); - var rawUpcomingEvents = new List() - { - }; + var rawUpcomingEvents = new List(); var upcomingEvents = converter.ToUpcomingEvents(rawUpcomingEvents, traceId, timestamp); @@ -89,7 +88,7 @@ public void ToUpcomingEvents_WithNullEvents_ThrowsException() { var converter = new OddsApiObjectConverter(); - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(null, Guid.NewGuid(), DateTime.UtcNow); }; @@ -102,12 +101,9 @@ public void ToUpcomingEvents_WithNullEvent_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() - { - null! - }; + var rawUpcomingEvents = new List { null! }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -120,12 +116,12 @@ public void ToUpcomingEvents_WithNullBookmakers_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetBookmakers(null).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -139,12 +135,12 @@ public void ToUpcomingEvents_WithNullOrEmptyAwayTeam_ThrowsException(string? awa { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetAwayTeam(awayTeam).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -158,12 +154,12 @@ public void ToUpcomingEvents_WithNullOrEmptyHomeTeam_ThrowsException(string? hom { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetHomeTeam(homeTeam).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -177,36 +173,24 @@ public void ToUpcomingEvents_WithNullOrEmptyBookmakerKey_ThrowsException(string? { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetBookmakers( - new List() + new List { new() { Key = bookmaker, - Markets = new List() + Markets = new List { new() { Key = Markets2Key.H2h, - Outcomes = new List() + Outcomes = new List { - new() - { - Name = "Liverpool", - Price = 4.08 - }, - new() - { - Name = "Manchester City", - Price = 1.7 - }, - new() - { - Name = "Draw", - Price = 3.82 - } + new() { Name = "Liverpool", Price = 4.08 }, + new() { Name = "Manchester City", Price = 1.7 }, + new() { Name = "Draw", Price = 3.82 } } } } @@ -215,7 +199,7 @@ public void ToUpcomingEvents_WithNullOrEmptyBookmakerKey_ThrowsException(string? ).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -228,21 +212,14 @@ public void ToUpcomingEvents_WithNullMarkets_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetBookmakers( - new List() - { - new() - { - Key = "onexbet", - Markets = null - } - } + new List { new() { Key = "onexbet", Markets = null } } ).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -255,36 +232,24 @@ public void ToUpcomingEvents_WithNullMarketKey_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetBookmakers( - new List() + new List { new() { Key = "onexbet", - Markets = new List() + Markets = new List { new() { Key = null, - Outcomes = new List() + Outcomes = new List { - new() - { - Name = "Liverpool", - Price = 4.33 - }, - new() - { - Name = "Manchester City", - Price = 1.7 - }, - new() - { - Name = "Draw", - Price = 4.33 - } + new() { Name = "Liverpool", Price = 4.33 }, + new() { Name = "Manchester City", Price = 1.7 }, + new() { Name = "Draw", Price = 4.33 } } } } @@ -293,7 +258,7 @@ public void ToUpcomingEvents_WithNullMarketKey_ThrowsException() ).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -306,21 +271,14 @@ public void ToUpcomingEvents_WithEmptyMarkets_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetBookmakers( - new List() - { - new() - { - Key = "onexbet", - Markets = new List() - } - } + new List { new() { Key = "onexbet", Markets = new List() } } ).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -333,28 +291,21 @@ public void ToUpcomingEvents_WithNullOutcomes_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetBookmakers( - new List() + new List { new() { Key = "onexbet", - Markets = new List() - { - new() - { - Key = Markets2Key.H2h, - Outcomes = null - } - } + Markets = new List { new() { Key = Markets2Key.H2h, Outcomes = null } } } } ).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -367,28 +318,24 @@ public void ToUpcomingEvents_WithEmptyOutcomes_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetBookmakers( - new List() + new List { new() { Key = "onexbet", - Markets = new List() + Markets = new List { - new() - { - Key = Markets2Key.H2h, - Outcomes = new List() - } + new() { Key = Markets2Key.H2h, Outcomes = new List() } } } } ).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -401,31 +348,23 @@ public void ToUpcomingEvents_WithOneOutcome_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetBookmakers( - new List() + new List { new() { Key = "onexbet", - Markets = new List() + Markets = new List { new() { Key = Markets2Key.H2h, - Outcomes = new List() + Outcomes = new List { - new() - { - Name = "Manchester City", - Price = 1.7 - }, - new() - { - Name = "Draw", - Price = 4.33 - } + new() { Name = "Manchester City", Price = 1.7 }, + new() { Name = "Draw", Price = 4.33 } } } } @@ -434,7 +373,7 @@ public void ToUpcomingEvents_WithOneOutcome_ThrowsException() ).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -447,36 +386,24 @@ public void ToUpcomingEvents_WithNullPrice_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawUpcomingEvents = new List() + var rawUpcomingEvents = new List { new RawUpcomingEventBuilder().SetDefaults().SetBookmakers( - new List() + new List { new() { Key = "onexbet", - Markets = new List() + Markets = new List { new() { Key = Markets2Key.H2h, - Outcomes = new List() + Outcomes = new List { - new() - { - Name = "Liverpool", - Price = null - }, - new() - { - Name = "Manchester City", - Price = null - }, - new() - { - Name = "Draw", - Price = null - } + new() { Name = "Liverpool", Price = null }, + new() { Name = "Manchester City", Price = null }, + new() { Name = "Draw", Price = null } } } } @@ -485,7 +412,7 @@ public void ToUpcomingEvents_WithNullPrice_ThrowsException() ).GetRawUpcomingEvent() }; - Action action = () => + var action = () => { _ = converter.ToUpcomingEvents(rawUpcomingEvents, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -501,47 +428,20 @@ public void ToEventResults_WithCompletedEvents_ReturnsConvertedEvents() var timestamp = DateTime.UtcNow; var traceId = Guid.NewGuid(); - var rawEventResults = new List() + var rawEventResults = new List { - new RawEventResultBuilder().SetDefaults().SetScores(new List() - { - new() - { - Name = "Manchester City", - Score = "1" - }, - new() - { - Name = "Liverpool", - Score = "0" - } - }).GetRawEventResult(), - new RawEventResultBuilder().SetDefaults().SetScores(new List() - { - new() - { - Name = "Manchester City", - Score = "0" - }, - new() - { - Name = "Liverpool", - Score = "1" - } - }).GetRawEventResult(), - new RawEventResultBuilder().SetDefaults().SetScores(new List() - { - new() - { - Name = "Manchester City", - Score = "1" - }, - new() - { - Name = "Liverpool", - Score = "1" - } - }).GetRawEventResult(), + new RawEventResultBuilder().SetDefaults().SetScores(new List + { + new() { Name = "Manchester City", Score = "1" }, new() { Name = "Liverpool", Score = "0" } + }).GetRawEventResult(), + new RawEventResultBuilder().SetDefaults().SetScores(new List + { + new() { Name = "Manchester City", Score = "0" }, new() { Name = "Liverpool", Score = "1" } + }).GetRawEventResult(), + new RawEventResultBuilder().SetDefaults().SetScores(new List + { + new() { Name = "Manchester City", Score = "1" }, new() { Name = "Liverpool", Score = "1" } + }).GetRawEventResult() }; var results = converter.ToEventResults(rawEventResults, traceId, timestamp); @@ -584,7 +484,7 @@ public void ToEventResults_WithEmptyCompletedEventsList_ReturnsEmptyConvertedEve var timestamp = DateTime.UtcNow; var traceId = Guid.NewGuid(); - var rawEventResults = new List() { }; + var rawEventResults = new List(); var eventResults = converter.ToEventResults(rawEventResults, traceId, timestamp); @@ -606,7 +506,7 @@ public void ToEventResults_WithUncompletedEvents_ReturnsNoEvents() { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { new RawEventResultBuilder().SetDefaults().SetCompleted(null).GetRawEventResult(), new RawEventResultBuilder().SetDefaults().SetCompleted(false).GetRawEventResult() @@ -622,10 +522,7 @@ public void ToEventResults_WithNullEvent_ThrowsNoException() { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() - { - null! - }; + var rawEventResults = new List { null! }; var results = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); @@ -637,12 +534,12 @@ public void ToEventResults_WithEmptyScores_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { new RawEventResultBuilder().SetDefaults().SetScores(null).GetRawEventResult() }; - Action action = () => + var action = () => { _ = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -656,12 +553,12 @@ public void ToEventResults_WithNullOrEmptyHomeTeam_ThrowsException(string? homeT { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { new RawEventResultBuilder().SetDefaults().SetHomeTeam(homeTeam).GetRawEventResult() }; - Action action = () => + var action = () => { _ = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -675,12 +572,12 @@ public void ToEventResults_WithNullOrEmptyAwayTeam_ThrowsException(string? awayT { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { new RawEventResultBuilder().SetDefaults().SetAwayTeam(awayTeam).GetRawEventResult() }; - Action action = () => + var action = () => { _ = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -694,24 +591,15 @@ public void ToEventResults_WithNullOrEmptyTeamName_ThrowsException(string? name) { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { - new RawEventResultBuilder().SetDefaults().SetScores(new List() - { - new() - { - Name = name, - Score = "1" - }, - new() - { - Name = name, - Score = "1" - } - }).GetRawEventResult() + new RawEventResultBuilder().SetDefaults().SetScores(new List + { + new() { Name = name, Score = "1" }, new() { Name = name, Score = "1" } + }).GetRawEventResult() }; - Action action = () => + var action = () => { _ = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -725,24 +613,15 @@ public void ToEventResults_WithNullOrEmptyScoreValue_ThrowsException(string? sco { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { - new RawEventResultBuilder().SetDefaults().SetScores(new List() - { - new() - { - Name = "Manchester City", - Score = score - }, - new() - { - Name = "Liverpool", - Score = score - } - }).GetRawEventResult() + new RawEventResultBuilder().SetDefaults().SetScores(new List + { + new() { Name = "Manchester City", Score = score }, new() { Name = "Liverpool", Score = score } + }).GetRawEventResult() }; - Action action = () => + var action = () => { _ = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -755,29 +634,17 @@ public void ToEventResults_WithDuplicatedScore_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { - new RawEventResultBuilder().SetDefaults().SetScores(new List() - { - new() - { - Name = "Manchester City", - Score = "1" - }, - new() - { - Name = "Liverpool", - Score = "1" - }, - new() - { - Name = "Liverpool", - Score = "1" - } - }).GetRawEventResult() + new RawEventResultBuilder().SetDefaults().SetScores(new List + { + new() { Name = "Manchester City", Score = "1" }, + new() { Name = "Liverpool", Score = "1" }, + new() { Name = "Liverpool", Score = "1" } + }).GetRawEventResult() }; - Action action = () => + var action = () => { _ = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -790,26 +657,14 @@ public void ToEventResults_WithExtraScore_ReturnsEventResult() { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { - new RawEventResultBuilder().SetDefaults().SetScores(new List() - { - new() - { - Name = "Manchester City", - Score = "1" - }, - new() - { - Name = "Liverpool", - Score = "0" - }, - new() - { - Name = "Nottingham Forest", - Score = "1" - } - }).GetRawEventResult() + new RawEventResultBuilder().SetDefaults().SetScores(new List + { + new() { Name = "Manchester City", Score = "1" }, + new() { Name = "Liverpool", Score = "0" }, + new() { Name = "Nottingham Forest", Score = "1" } + }).GetRawEventResult() }; var result = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); @@ -824,19 +679,15 @@ public void ToEventResults_WithoutAwayTeamScore_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { - new RawEventResultBuilder().SetDefaults().SetScores(new List() - { - new() - { - Name = "Manchester City", - Score = "1" - } - }).GetRawEventResult() + new RawEventResultBuilder().SetDefaults().SetScores(new List + { + new() { Name = "Manchester City", Score = "1" } + }).GetRawEventResult() }; - Action action = () => + var action = () => { _ = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; @@ -849,19 +700,15 @@ public void ToEventResults_WithoutHomeTeamScore_ThrowsException() { var converter = new OddsApiObjectConverter(); - var rawEventResults = new List() + var rawEventResults = new List { - new RawEventResultBuilder().SetDefaults().SetScores(new List() - { - new() - { - Name = "Liverpool", - Score = "1" - } - }).GetRawEventResult() + new RawEventResultBuilder().SetDefaults().SetScores(new List + { + new() { Name = "Liverpool", Score = "1" } + }).GetRawEventResult() }; - Action action = () => + var action = () => { _ = converter.ToEventResults(rawEventResults, Guid.NewGuid(), DateTime.UtcNow).ToList(); }; diff --git a/OddsCollector.Common.Tests/OddsApi/Converter/RawEventResultBuilder.cs b/OddsCollector.Common.Tests/OddsApi/Converter/RawEventResultBuilder.cs index 5dc24f3..e721d58 100644 --- a/OddsCollector.Common.Tests/OddsApi/Converter/RawEventResultBuilder.cs +++ b/OddsCollector.Common.Tests/OddsApi/Converter/RawEventResultBuilder.cs @@ -9,25 +9,17 @@ internal sealed class RawEventResultBuilder public const string DefaultHomeTeam = "Manchester City"; public const string DefaultId = "4acd8f2675ca847ba33eea3664f6c0bb"; public static readonly DateTime DefaultCommenceTime = new(2023, 11, 25, 12, 30, 0); - public static readonly ICollection DefaultScores = new List() - { - new() - { - Name = "Manchester City", - Score = "1" - }, - new() - { - Name = "Liverpool", - Score = "0" - } - }; + + public static readonly ICollection DefaultScores = new List + { + new() { Name = "Manchester City", Score = "1" }, new() { Name = "Liverpool", Score = "0" } + }; private Anonymous3 _state = new(); public RawEventResultBuilder SetDefaults() { - _state = new() + _state = new Anonymous3 { Away_team = DefaultAwayTeam, Completed = DefaultCompleted, diff --git a/OddsCollector.Common.Tests/OddsApi/Converter/RawUpcomingEventBuilder.cs b/OddsCollector.Common.Tests/OddsApi/Converter/RawUpcomingEventBuilder.cs index 5327f15..3e968e5 100644 --- a/OddsCollector.Common.Tests/OddsApi/Converter/RawUpcomingEventBuilder.cs +++ b/OddsCollector.Common.Tests/OddsApi/Converter/RawUpcomingEventBuilder.cs @@ -8,33 +8,22 @@ internal class RawUpcomingEventBuilder public const string DefaultHomeTeam = "Manchester City"; public const string DefaultId = "4acd8f2675ca847ba33eea3664f6c0bb"; public static readonly DateTime DefaultCommenceTime = new(2023, 11, 25, 12, 30, 0); - public static readonly ICollection DefaultBookmakers = new List() + + public static readonly ICollection DefaultBookmakers = new List { new() { Key = "betclic", - Markets = new List() + Markets = new List { new() { Key = Markets2Key.H2h, - Outcomes = new List() + Outcomes = new List { - new() - { - Name = "Liverpool", - Price = 4.08 - }, - new() - { - Name = "Manchester City", - Price = 1.7 - }, - new() - { - Name = "Draw", - Price = 3.82 - } + new() { Name = "Liverpool", Price = 4.08 }, + new() { Name = "Manchester City", Price = 1.7 }, + new() { Name = "Draw", Price = 3.82 } } } } @@ -42,39 +31,27 @@ internal class RawUpcomingEventBuilder new() { Key = "sport888", - Markets = new List() + Markets = new List { new() { Key = Markets2Key.H2h, - Outcomes = new List() + Outcomes = new List { - new() - { - Name = "Liverpool", - Price = 4.33 - }, - new() - { - Name = "Manchester City", - Price = 1.7 - }, - new() - { - Name = "Draw", - Price = 4.33 - } + new() { Name = "Liverpool", Price = 4.33 }, + new() { Name = "Manchester City", Price = 1.7 }, + new() { Name = "Draw", Price = 4.33 } } } } - }, + } }; private Anonymous2 _state = new(); public RawUpcomingEventBuilder SetDefaults() { - _state = new Anonymous2() + _state = new Anonymous2 { Away_team = DefaultAwayTeam, Commence_time = DefaultCommenceTime, diff --git a/OddsCollector.Common.Tests/OddsCollector.Common.Tests.csproj b/OddsCollector.Common.Tests/OddsCollector.Common.Tests.csproj index 581d60f..049ea7d 100644 --- a/OddsCollector.Common.Tests/OddsCollector.Common.Tests.csproj +++ b/OddsCollector.Common.Tests/OddsCollector.Common.Tests.csproj @@ -10,11 +10,11 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -26,7 +26,7 @@ - + diff --git a/OddsCollector.Common/Models/EventPrediction.cs b/OddsCollector.Common/Models/EventPrediction.cs index d24249a..31034e3 100644 --- a/OddsCollector.Common/Models/EventPrediction.cs +++ b/OddsCollector.Common/Models/EventPrediction.cs @@ -6,11 +6,15 @@ public class EventPrediction { // duplicating information to avoid complex queries to cosmosdb public string? AwayTeam { get; init; } + public string? Bookmaker { get; init; } + // duplicating information to avoid complex queries to cosmosdb public DateTime? CommenceTime { get; init; } + // duplicating information to avoid complex queries to cosmosdb public string? HomeTeam { get; init; } + // fix for cosmosdb [JsonPropertyName("id")] public string? Id { get; init; } public string? Strategy { get; init; } diff --git a/OddsCollector.Common/Models/EventResult.cs b/OddsCollector.Common/Models/EventResult.cs index 7424236..203241d 100644 --- a/OddsCollector.Common/Models/EventResult.cs +++ b/OddsCollector.Common/Models/EventResult.cs @@ -5,6 +5,7 @@ namespace OddsCollector.Common.Models; public class EventResult { public DateTime? CommenceTime { get; init; } + // fix for cosmosdb [JsonPropertyName("id")] public string? Id { get; init; } public DateTime? Timestamp { get; init; } diff --git a/OddsCollector.Common/OddsApi/Converter/OddsApiObjectConverter.cs b/OddsCollector.Common/OddsApi/Converter/OddsApiObjectConverter.cs index bb7f054..7843c18 100644 --- a/OddsCollector.Common/OddsApi/Converter/OddsApiObjectConverter.cs +++ b/OddsCollector.Common/OddsApi/Converter/OddsApiObjectConverter.cs @@ -133,7 +133,8 @@ private static Odd ToOdd(ICollection? outcomes, string bookmaker, strin throw new ArgumentException($"{nameof(outcomes)} has duplicates for {oddType}", nameof(outcomes)); } - return matches.First().Price ?? throw new ArgumentException($"{nameof(outcomes)} doesn't have price for {oddType}", nameof(outcomes)); + return matches.First().Price ?? + throw new ArgumentException($"{nameof(outcomes)} doesn't have price for {oddType}", nameof(outcomes)); } private static EventResult ToEventResult(Anonymous3 eventResult, Guid traceId, DateTime timestamp) diff --git a/OddsCollector.Functions.EventResults.Tests/EventResultsFunctionTests.cs b/OddsCollector.Functions.EventResults.Tests/EventResultsFunctionTests.cs index 3878d45..2d4da03 100644 --- a/OddsCollector.Functions.EventResults.Tests/EventResultsFunctionTests.cs +++ b/OddsCollector.Functions.EventResults.Tests/EventResultsFunctionTests.cs @@ -15,7 +15,7 @@ public void Constructor_WithValidDependencies_ReturnsNewInstance() { var clientStub = Substitute.For(); var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = new HashSet() { "league1" } }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = new HashSet { "league1" } }); var function = new EventResultsFunction(optionsStub, clientStub); @@ -27,7 +27,7 @@ public void Constructor_WithEmptyLeagues_ReturnsNewInstance() { var clientStub = Substitute.For(); var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = new HashSet() { } }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = new HashSet() }); var function = new EventResultsFunction(optionsStub, clientStub); @@ -38,9 +38,9 @@ public void Constructor_WithEmptyLeagues_ReturnsNewInstance() public void Constructor_WithNullOddsClient_ThrowsException() { var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = new HashSet() { "league1" } }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = new HashSet { "league1" } }); - Action action = () => + var action = () => { _ = new EventResultsFunction(optionsStub, null); }; @@ -53,7 +53,7 @@ public void Constructor_WithNullOptions_ThrowsException() { var clientStub = Substitute.For(); - Action action = () => + var action = () => { _ = new EventResultsFunction(null, clientStub); }; @@ -66,9 +66,9 @@ public void Constructor_WithNullLeagues_ThrowsException() { var clientStub = Substitute.For(); var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = null! }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = null! }); - Action action = () => + var action = () => { _ = new EventResultsFunction(null, clientStub); }; @@ -79,13 +79,13 @@ public void Constructor_WithNullLeagues_ThrowsException() [Test] public async Task Run_WithValidTimer_ReturnsEventResults() { - IEnumerable expectedEventResults = new List() {}; + IEnumerable expectedEventResults = new List(); var clientStub = Substitute.For(); clientStub.GetEventResultsAsync(Arg.Any>()).Returns(Task.FromResult(expectedEventResults)); var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = new HashSet() {} }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = new HashSet() }); var function = new EventResultsFunction(optionsStub, clientStub); diff --git a/OddsCollector.Functions.EventResults.Tests/GlobalUsings.cs b/OddsCollector.Functions.EventResults.Tests/GlobalUsings.cs index cefced4..3244567 100644 --- a/OddsCollector.Functions.EventResults.Tests/GlobalUsings.cs +++ b/OddsCollector.Functions.EventResults.Tests/GlobalUsings.cs @@ -1 +1 @@ -global using NUnit.Framework; \ No newline at end of file +global using NUnit.Framework; diff --git a/OddsCollector.Functions.EventResults.Tests/OddsCollector.Functions.EventResults.Tests.csproj b/OddsCollector.Functions.EventResults.Tests/OddsCollector.Functions.EventResults.Tests.csproj index bb81d91..7abfffc 100644 --- a/OddsCollector.Functions.EventResults.Tests/OddsCollector.Functions.EventResults.Tests.csproj +++ b/OddsCollector.Functions.EventResults.Tests/OddsCollector.Functions.EventResults.Tests.csproj @@ -10,11 +10,11 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -26,7 +26,7 @@ - + diff --git a/OddsCollector.Functions.EventResults/EventResultsFunction.cs b/OddsCollector.Functions.EventResults/EventResultsFunction.cs index de2cc9a..80c1582 100644 --- a/OddsCollector.Functions.EventResults/EventResultsFunction.cs +++ b/OddsCollector.Functions.EventResults/EventResultsFunction.cs @@ -6,6 +6,7 @@ using OddsCollector.Common.OddsApi.Configuration; [assembly: InternalsVisibleTo("OddsCollector.Functions.EventResults.Tests")] + namespace OddsCollector.Functions.EventResults; internal sealed class EventResultsFunction diff --git a/OddsCollector.Functions.Notification/CosmosDb/CosmosDbClient.cs b/OddsCollector.Functions.Notification/CosmosDb/CosmosDbClient.cs index 584fa90..1c3d65a 100644 --- a/OddsCollector.Functions.Notification/CosmosDb/CosmosDbClient.cs +++ b/OddsCollector.Functions.Notification/CosmosDb/CosmosDbClient.cs @@ -22,8 +22,8 @@ public CosmosDbClient(IOptions options) // cosmosdb doesn't support grouping var matches = from prediction in queryable - where prediction.CommenceTime >= DateTime.UtcNow - select prediction; + where prediction.CommenceTime >= DateTime.UtcNow + select prediction; var cosmosdbresult = new List(); diff --git a/OddsCollector.Functions.UpcomingEvents.Tests/GlobalUsings.cs b/OddsCollector.Functions.UpcomingEvents.Tests/GlobalUsings.cs index cefced4..3244567 100644 --- a/OddsCollector.Functions.UpcomingEvents.Tests/GlobalUsings.cs +++ b/OddsCollector.Functions.UpcomingEvents.Tests/GlobalUsings.cs @@ -1 +1 @@ -global using NUnit.Framework; \ No newline at end of file +global using NUnit.Framework; diff --git a/OddsCollector.Functions.UpcomingEvents.Tests/OddsCollector.Functions.UpcomingEvents.Tests.csproj b/OddsCollector.Functions.UpcomingEvents.Tests/OddsCollector.Functions.UpcomingEvents.Tests.csproj index e0b1eff..89c16b0 100644 --- a/OddsCollector.Functions.UpcomingEvents.Tests/OddsCollector.Functions.UpcomingEvents.Tests.csproj +++ b/OddsCollector.Functions.UpcomingEvents.Tests/OddsCollector.Functions.UpcomingEvents.Tests.csproj @@ -10,11 +10,11 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive @@ -26,7 +26,7 @@ - + diff --git a/OddsCollector.Functions.UpcomingEvents.Tests/UpcomingEventsFunctionTest.cs b/OddsCollector.Functions.UpcomingEvents.Tests/UpcomingEventsFunctionTest.cs index 04a8f62..76afa04 100644 --- a/OddsCollector.Functions.UpcomingEvents.Tests/UpcomingEventsFunctionTest.cs +++ b/OddsCollector.Functions.UpcomingEvents.Tests/UpcomingEventsFunctionTest.cs @@ -15,7 +15,7 @@ public void Constructor_WithValidDependencies_ReturnsNewInstance() { var clientStub = Substitute.For(); var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = new HashSet() { "league1" } }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = new HashSet { "league1" } }); var function = new UpcomingEventsFunction(optionsStub, clientStub); @@ -27,7 +27,7 @@ public void Constructor_WithEmptyLeagues_ReturnsNewInstance() { var clientStub = Substitute.For(); var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = new HashSet() { } }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = new HashSet() }); var function = new UpcomingEventsFunction(optionsStub, clientStub); @@ -38,9 +38,9 @@ public void Constructor_WithEmptyLeagues_ReturnsNewInstance() public void Constructor_WithNullOddsClient_ThrowsException() { var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = new HashSet() { "league1" } }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = new HashSet { "league1" } }); - Action action = () => + var action = () => { _ = new UpcomingEventsFunction(optionsStub, null); }; @@ -53,7 +53,7 @@ public void Constructor_WithNullOptions_ThrowsException() { var clientStub = Substitute.For(); - Action action = () => + var action = () => { _ = new UpcomingEventsFunction(null!, clientStub); }; @@ -66,9 +66,9 @@ public void Constructor_WithNullLeagues_ThrowsException() { var clientStub = Substitute.For(); var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = null! }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = null! }); - Action action = () => + var action = () => { _ = new UpcomingEventsFunction(null!, clientStub); }; @@ -79,13 +79,13 @@ public void Constructor_WithNullLeagues_ThrowsException() [Test] public async Task Run_WithValidTimer_ReturnsEventResults() { - IEnumerable expectedEventResults = new List() { }; + IEnumerable expectedEventResults = new List(); var clientStub = Substitute.For(); clientStub.GetUpcomingEventsAsync(Arg.Any>()).Returns(Task.FromResult(expectedEventResults)); var optionsStub = Substitute.For>(); - optionsStub.Value.Returns(new OddsApiOptions() { Leagues = new HashSet() { } }); + optionsStub.Value.Returns(new OddsApiOptions { Leagues = new HashSet() }); var function = new UpcomingEventsFunction(optionsStub, clientStub); diff --git a/OddsCollector.Functions.UpcomingEvents/UpcomingEventsFunction.cs b/OddsCollector.Functions.UpcomingEvents/UpcomingEventsFunction.cs index f30b9fb..31a85e1 100644 --- a/OddsCollector.Functions.UpcomingEvents/UpcomingEventsFunction.cs +++ b/OddsCollector.Functions.UpcomingEvents/UpcomingEventsFunction.cs @@ -6,6 +6,7 @@ using OddsCollector.Common.OddsApi.Configuration; [assembly: InternalsVisibleTo("OddsCollector.Functions.UpcomingEvents.Tests")] + namespace OddsCollector.Functions.UpcomingEvents; internal sealed class UpcomingEventsFunction