Skip to content
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
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ tab_width = 4
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = false

# Namespace matching folder structure preferences
dotnet_style_namespace_match_folder = true:warning

# this. and Me. preferences
dotnet_style_qualification_for_event = false:warning
dotnet_style_qualification_for_field = false:warning
Expand Down Expand Up @@ -202,6 +205,16 @@ dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.async_methods_end_in_async.symbols = async_methods
dotnet_naming_rule.async_methods_end_in_async.style = end_in_async
dotnet_naming_rule.async_methods_end_in_async.severity = warning

dotnet_naming_symbols.async_methods.applicable_kinds = method
dotnet_naming_symbols.async_methods.required_modifiers = async

dotnet_naming_style.end_in_async.required_suffix = Async
dotnet_naming_style.end_in_async.capitalization = pascal_case
Comment thread
jldsilva marked this conversation as resolved.

# Symbol specifications

dotnet_naming_symbols.interface.applicable_kinds = interface
Expand Down
60 changes: 30 additions & 30 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,30 @@
</PropertyGroup>

<ItemGroup Label=".Net Packages: Essentials">
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.3" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.3" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="10.0.5" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="10.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.InMemory" Version="10.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Relational" Version="10.0.5" />
<PackageVersion Include="Microsoft.EntityFrameworkCore.Tools" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Configuration" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Abstractions" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Configuration.Binder" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Configuration.FileExtensions" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Configuration.UserSecrets" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Logging" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.5" />
<PackageVersion Include="Microsoft.Extensions.Options" Version="10.0.5" />
</ItemGroup>

<ItemGroup Label="System Packages">
<PackageVersion Include="AspNetCore.HealthChecks.NpgSql" Version="9.0.0" />
<PackageVersion Include="Dapper" Version="2.1.66" />
<PackageVersion Include="Dapper" Version="2.1.72" />
<PackageVersion Include="EFCore.BulkExtensions.Dotnet10" Version="10.0.0" />
<PackageVersion Include="EFCore.BulkExtensions.Dotnet10.PostgreSql" Version="10.0.0" />
<PackageVersion Include="Google.Apis.Gmail.v1" Version="1.73.0.4029" />
Expand All @@ -40,26 +40,26 @@
<PackageVersion Include="Microsoft.AspNetCore.Authentication.Abstractions" Version="2.3.9" />
<PackageVersion Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.9" />
<PackageVersion Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageVersion Include="Npgsql" Version="10.0.1" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.0" />
<PackageVersion Include="Quartz" Version="3.16.0" />
<PackageVersion Include="Scalar.AspNetCore" Version="2.12.54" />
<PackageVersion Include="Npgsql" Version="10.0.2" />
<PackageVersion Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="10.0.1" />
<PackageVersion Include="Quartz" Version="3.16.1" />
<PackageVersion Include="Scalar.AspNetCore" Version="2.13.8" />
<PackageVersion Include="Scrutor" Version="7.0.0" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.20.0.135146" />
<PackageVersion Include="SonarAnalyzer.CSharp" Version="10.21.0.135717" />
<PackageVersion Include="System.IdentityModel.Tokens.Jwt" Version="8.16.0" />
<PackageVersion Include="Telegram.Bot" Version="22.9.5.2" />
<PackageVersion Include="Telegram.Bot" Version="22.9.5.3" />
</ItemGroup>

<ItemGroup Label="Unit Tests Packages: Support">
<PackageVersion Include="Bogus" Version="35.6.5" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.3" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="10.0.5" />
<PackageVersion Include="NetArchTest.Rules" Version="1.3.2" />
<PackageVersion Include="NSubstitute" Version="5.3.0" />
<PackageVersion Include="NSubstitute.Analyzers.CSharp" Version="1.0.17" />
<PackageVersion Include="Shouldly" Version="4.3.0" />
<PackageVersion Include="System.CodeDom" Version="10.0.3" />
<PackageVersion Include="Testcontainers" Version="4.10.0" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.10.0" />
<PackageVersion Include="System.CodeDom" Version="10.0.5" />
<PackageVersion Include="Testcontainers" Version="4.11.0" />
<PackageVersion Include="Testcontainers.PostgreSql" Version="4.11.0" />
</ItemGroup>

<ItemGroup Label="Unit Tests Packages: Essentials">
Expand Down
2 changes: 1 addition & 1 deletion InvoiceReminder.API/Endpoints/SendMessageEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ private static void MapSendMessage(RouteGroupBuilder endpoint)
{
_ = endpoint.MapGet("/{id}", async (ISendMessageService messageService, Guid id, CancellationToken ct) =>
{
var result = await messageService.SendMessage(id, ct);
var result = await messageService.SendMessageAsync(id, ct);

return !string.IsNullOrEmpty(result)
? Results.Ok(result)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,10 @@ private static IServiceCollection AddDbContext(this IServiceCollection services)
var config = sp.GetRequiredService<IConfiguration>();

_ = options.UseNpgsql(config.GetConnectionString("DatabaseConnection"),
b => b.MigrationsHistoryTable("__EFMigrationsHistory", "invoice_reminder")
b => b.MigrationsHistoryTable(
tableName: "__EFMigrationsHistory",
schema: "invoice_reminder"
)
);
});

Expand Down
8 changes: 4 additions & 4 deletions InvoiceReminder.Data/Repository/UnitOfWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task SaveChangesAsync(CancellationToken cancellationToken = default

try
{
await OpenConnection(cancellationToken);
await OpenConnectionAsync(cancellationToken);

transaction = await _context.Database.BeginTransactionAsync(cancellationToken);

Expand Down Expand Up @@ -67,19 +67,19 @@ public async Task SaveChangesAsync(CancellationToken cancellationToken = default
finally
{
transaction?.Dispose();
await CloseConnection();
await CloseConnectionAsync();
}
}

private async Task OpenConnection(CancellationToken cancellationToken = default)
private async Task OpenConnectionAsync(CancellationToken cancellationToken = default)
{
if (_connection.State == ConnectionState.Closed)
{
await _connection.OpenAsync(cancellationToken);
}
}

private async Task CloseConnection()
private async Task CloseConnectionAsync()
{
if (_connection.State == ConnectionState.Open)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace InvoiceReminder.ExternalServices.SendMessage;

public interface ISendMessageService
{
Task<string> SendMessage(Guid userId, CancellationToken cancellationToken = default);
Task<string> SendMessageAsync(Guid userId, CancellationToken cancellationToken = default);
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public SendMessageService(
_logger = logger;
}

public async Task<string> SendMessage(Guid userId, CancellationToken cancellationToken = default)
public async Task<string> SendMessageAsync(Guid userId, CancellationToken cancellationToken = default)
{
IDictionary<string, byte[]> attachments;

Expand Down Expand Up @@ -77,7 +77,7 @@ public async Task<string> SendMessage(Guid userId, CancellationToken cancellatio
}
catch (OperationCanceledException ex) when (cancellationToken.IsCancellationRequested)
{
var method = $"{nameof(SendMessageService)}.{nameof(SendMessage)}";
var method = $"{nameof(SendMessageService)}.{nameof(SendMessageAsync)}";
var contextualInfo = $"Method {method} execution was interrupted by a CancellationToken Request...";

if (_logger.IsEnabled(LogLevel.Warning))
Expand Down
3 changes: 1 addition & 2 deletions InvoiceReminder.JobScheduler/JobSettings/CronJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public async Task Execute(IJobExecutionContext context)
_logger.LogInformation("{Message}", message);
}

// possível uso de um agendamento de envio de mensagem para lembrete no dia do vencimento?...
_ = await service.SendMessage(id);
_ = await service.SendMessageAsync(id, context.CancellationToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task SendMessage_WhenUserIsAuthenticated_ShouldReturnOk()

var expectedResult = "Total messages sent: 1";

_ = _sendMessageService.SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
_ = _sendMessageService.SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult(expectedResult));

_ = _authorizationService.AuthorizeAsync(Arg.Any<ClaimsPrincipal>(), Arg.Any<object>(),
Expand All @@ -56,7 +56,7 @@ public async Task SendMessage_WhenUserIsAuthenticated_ShouldReturnOk()
var result = await response.Content.ReadAsStringAsync(TestContext.CancellationToken);

// Assert
_ = _sendMessageService.Received(1).SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
_ = _sendMessageService.Received(1).SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());

response.StatusCode.ShouldBe(HttpStatusCode.OK);

Expand Down Expand Up @@ -94,7 +94,7 @@ public async Task SendMessage_WhenUserIsAuthenticatedButServiceReturnsEmptyResul
var request = new HttpRequestMessage(HttpMethod.Get, $"{basepath}/{userId}");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "test_token");

_ = _sendMessageService.SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
_ = _sendMessageService.SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult(string.Empty));

_ = _authorizationService.AuthorizeAsync(Arg.Any<ClaimsPrincipal>(), Arg.Any<object>(),
Expand All @@ -106,7 +106,7 @@ public async Task SendMessage_WhenUserIsAuthenticatedButServiceReturnsEmptyResul
var result = await response.Content.ReadFromJsonAsync<ProblemDetails>(TestContext.CancellationToken);

// Assert
_ = _sendMessageService.Received(1).SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
_ = _sendMessageService.Received(1).SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());

response.StatusCode.ShouldBe(HttpStatusCode.InternalServerError);

Expand All @@ -127,7 +127,7 @@ public async Task SendMessage_WhenUserIsAuthenticatedButServiceReturnsNull_Shoul
var request = new HttpRequestMessage(HttpMethod.Get, $"{basepath}/{userId}");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "test_token");

_ = _sendMessageService.SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
_ = _sendMessageService.SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult<string>(null));

_ = _authorizationService.AuthorizeAsync(Arg.Any<ClaimsPrincipal>(), Arg.Any<object>(),
Expand All @@ -139,7 +139,7 @@ public async Task SendMessage_WhenUserIsAuthenticatedButServiceReturnsNull_Shoul
var result = await response.Content.ReadFromJsonAsync<ProblemDetails>(TestContext.CancellationToken);

// Assert
_ = _sendMessageService.Received(1).SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
_ = _sendMessageService.Received(1).SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());

response.StatusCode.ShouldBe(HttpStatusCode.InternalServerError);

Expand All @@ -158,7 +158,7 @@ public async Task SendMessage_WhenUserIsAuthenticatedButServiceThrowsException_S
var request = new HttpRequestMessage(HttpMethod.Get, $"{basepath}/{userId}");
request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", "test_token");

_ = _sendMessageService.SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
_ = _sendMessageService.SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
.ThrowsAsync(new Exception("Service error"));

_ = _authorizationService.AuthorizeAsync(Arg.Any<ClaimsPrincipal>(), Arg.Any<object>(),
Expand All @@ -170,7 +170,7 @@ public async Task SendMessage_WhenUserIsAuthenticatedButServiceThrowsException_S
var result = await response.Content.ReadFromJsonAsync<ProblemDetails>(TestContext.CancellationToken);

// Assert
_ = _sendMessageService.Received(1).SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
_ = _sendMessageService.Received(1).SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());

response.StatusCode.ShouldBe(HttpStatusCode.InternalServerError);

Expand All @@ -191,7 +191,7 @@ public async Task SendMessage_WithValidUserId_CallsServiceWithCorrectParameters(

var expectedResult = "Total messages sent: 3";

_ = _sendMessageService.SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
_ = _sendMessageService.SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult(expectedResult));

_ = _authorizationService.AuthorizeAsync(Arg.Any<ClaimsPrincipal>(), Arg.Any<object>(),
Expand All @@ -202,7 +202,7 @@ public async Task SendMessage_WithValidUserId_CallsServiceWithCorrectParameters(
var response = await _client.SendAsync(request, TestContext.CancellationToken);

// Assert
_ = _sendMessageService.Received(1).SendMessage(
_ = _sendMessageService.Received(1).SendMessageAsync(
Arg.Is<Guid>(id => id == userId),
Arg.Any<CancellationToken>()
);
Expand All @@ -220,7 +220,7 @@ public async Task SendMessage_WhenServiceReturnsNoMessages_ShouldStillReturnOkWi

var expectedResult = "Total messages sent: 0";

_ = _sendMessageService.SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
_ = _sendMessageService.SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult(expectedResult));

_ = _authorizationService.AuthorizeAsync(Arg.Any<ClaimsPrincipal>(), Arg.Any<object>(),
Expand All @@ -232,7 +232,7 @@ public async Task SendMessage_WhenServiceReturnsNoMessages_ShouldStillReturnOkWi
var result = await response.Content.ReadAsStringAsync(TestContext.CancellationToken);

// Assert
_ = _sendMessageService.Received(1).SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
_ = _sendMessageService.Received(1).SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());

response.StatusCode.ShouldBe(HttpStatusCode.OK);

Expand All @@ -253,7 +253,7 @@ public async Task SendMessage_WhenServiceReturnsWarningMessage_ShouldReturnOkWit

var expectedResult = $"No Authentication Token found for userId: {userId}";

_ = _sendMessageService.SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
_ = _sendMessageService.SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>())
.Returns(Task.FromResult(expectedResult));

_ = _authorizationService.AuthorizeAsync(Arg.Any<ClaimsPrincipal>(), Arg.Any<object>(),
Expand All @@ -265,7 +265,7 @@ public async Task SendMessage_WhenServiceReturnsWarningMessage_ShouldReturnOkWit
var result = await response.Content.ReadAsStringAsync(TestContext.CancellationToken);

// Assert
_ = _sendMessageService.Received(1).SendMessage(Arg.Any<Guid>(), Arg.Any<CancellationToken>());
_ = _sendMessageService.Received(1).SendMessageAsync(Arg.Any<Guid>(), Arg.Any<CancellationToken>());

response.StatusCode.ShouldBe(HttpStatusCode.OK);

Expand Down
Loading
Loading