Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting, remove extra tests, add qodana #20

Merged
merged 2 commits into from
Mar 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions OddsCollector.Functions.Tests/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
global using FluentAssertions;
global using NSubstitute;
global using NUnit.Framework;

[assembly: Parallelizable(ParallelScope.Fixtures)]
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public Anonymous2Builder SetId(string id)
return this;
}

// ReSharper disable once MemberCanBePrivate.Global
public Anonymous2Builder SetCommenceTime(DateTime commenceTime)
{
Instance.Commence_time = commenceTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ public Anonymous3Builder SetHomeTeam(string? homeTeam)
return this;
}

// ReSharper disable once MemberCanBePrivate.Global
public Anonymous3Builder SetId(string id)
{
Instance.Id = id;

return this;
}

// ReSharper disable once MemberCanBePrivate.Global
public Anonymous3Builder SetCommenceTime(DateTime commenceTime)
{
Instance.Commence_time = commenceTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static ServiceBusReceivedMessage CreateFromObject(object obj)

var ampqAnnotatedMessage = new AmqpAnnotatedMessage(ampqMessage);

return ServiceBusReceivedMessage.FromAmqpMessage(ampqAnnotatedMessage, new BinaryData(Array.Empty<byte>()));
return ServiceBusReceivedMessage.FromAmqpMessage(
ampqAnnotatedMessage, new BinaryData(Array.Empty<byte>()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\OddsCollector.Functions\OddsCollector.Functions.csproj" />
<ProjectReference Include="..\OddsCollector.Functions\OddsCollector.Functions.csproj"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using NSubstitute.ExceptionExtensions;
using OddsCollector.Functions.Models;
using OddsCollector.Functions.OddsApi;
Expand All @@ -8,10 +9,11 @@ namespace OddsCollector.Functions.Tests.Tests.Functions;
internal class EventResultsFunction
{
[Test]
[SuppressMessage("Usage", "CA2254:Template should be a static expression")]
public async Task Run_WithValidParameters_ReturnsEventResults()
{
// Arrange
IEnumerable<EventResult> expectedEventResults = new List<EventResult>() { new() };
IEnumerable<EventResult> expectedEventResults = new List<EventResult> { new() };

var loggerMock = Substitute.For<ILogger<OddsCollector.Functions.Functions.EventResultsFunction>>();

Expand Down Expand Up @@ -58,6 +60,7 @@ public async Task Run_WithException_ReturnsEmptyEventResults()
}

[Test]
[SuppressMessage("Usage", "CA2254:Template should be a static expression")]
public async Task Run_WithValidParameters_ReturnsNoEventResults()
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,8 @@ public void Run_WithValidArguments_ReturnsValidResponse()

var timestamp = DateTime.UtcNow;

var predictions = new[]
{
new EventPredictionBuilder().SetSampleData().SetTimestamp(timestamp).Instance,
};
var predictions =
new[] { new EventPredictionBuilder().SetSampleData().SetTimestamp(timestamp).Instance };

// Act
var response = function.Run(requestStub, predictions);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Logging;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.Logging;
using NSubstitute.ExceptionExtensions;
using OddsCollector.Functions.Models;
using OddsCollector.Functions.OddsApi;
Expand All @@ -8,10 +9,11 @@ namespace OddsCollector.Functions.Tests.Tests.Functions;
internal class UpcomingEventsFunction
{
[Test]
[SuppressMessage("Usage", "CA2254:Template should be a static expression")]
public async Task Run_WithValidParameters_ReturnsEventResults()
{
// Arrange
IEnumerable<UpcomingEvent> expectedEventResults = new List<UpcomingEvent>() { new() };
IEnumerable<UpcomingEvent> expectedEventResults = new List<UpcomingEvent> { new() };

var loggerMock = Substitute.For<ILogger<OddsCollector.Functions.Functions.UpcomingEventsFunction>>();

Expand Down Expand Up @@ -54,6 +56,7 @@ public async Task Run_WithException_ReturnsEmptyEventResults()
}

[Test]
[SuppressMessage("Usage", "CA2254:Template should be a static expression")]
public async Task Run_WithValidParameters_ReturnsNoEventResults()
{
// Arrange
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ internal class OddsApiOptions
{
private static readonly IEnumerable<(string LeagueString, HashSet<string> ExpectedLeagues)>
TestCases = new List<(string LeagueString, HashSet<string> ExpectedLeagues)>
{
("league", new HashSet<string>() { "league" }),
("league1;league2", new HashSet<string>() { "league1", "league2" }),
("league1;;league2", new HashSet<string>() { "league1", "league2" }),
("league1;league1", new HashSet<string>() { "league1" })
};
{
("league", ["league"]),
("league1;league2", ["league1", "league2"]),
("league1;;league2", ["league1", "league2"]),
("league1;league1", ["league1"])
};

[TestCaseSource(nameof(TestCases))]
public void SetLeagues_WithValidLeagueInputString_ReturnsCorrectLeagues(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,37 @@ public void AddOddsApiClientWithDependencies_AddsProperlyConfiguredOddsApiClient
var services = new ServiceCollection();

// Act
services.AddOddsApiClientWithDependencies();
services.AddOddsApiClientWithDependencies("leagues", "key");

// Assert
var options =
var optionsDescriptor =
services.FirstOrDefault(
x => x.ServiceType == typeof(IConfigureOptions<OddsApiClientOptions>)
&& x.Lifetime == ServiceLifetime.Singleton);

options.Should().NotBeNull();
optionsDescriptor.Should().NotBeNull();

var httpClient =
var httpClientDescriptor =
services.FirstOrDefault(
x => x.ServiceType == typeof(HttpClient)
&& x.Lifetime == ServiceLifetime.Transient);

httpClient.Should().NotBeNull();
httpClientDescriptor.Should().NotBeNull();

var client =
var clientDescriptor =
services.FirstOrDefault(
x => x.ImplementationType == typeof(Client)
&& x.ServiceType == typeof(IClient)
&& x.Lifetime == ServiceLifetime.Singleton);

client.Should().NotBeNull();
clientDescriptor.Should().NotBeNull();

var oddsApiClient =
var oddsApiClientDescriptor =
services.FirstOrDefault(
x => x.ImplementationType == typeof(OddsCollector.Functions.OddsApi.OddsApiClient)
&& x.ServiceType == typeof(IOddsApiClient)
&& x.Lifetime == ServiceLifetime.Singleton);

oddsApiClient.Should().NotBeNull();
oddsApiClientDescriptor.Should().NotBeNull();
}
}
Loading
Loading