Rename WebApi project to Vegasco.Server.Api
continuous-integration/drone/push Build is passing

And update all references including comments etc.
This commit is contained in:
2025-06-12 18:22:37 +02:00
parent 9d71c86474
commit a1999bfe41
71 changed files with 177 additions and 224 deletions
+6 -6
View File
@@ -10,18 +10,18 @@ USER app
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["src/WebApi/WebApi.csproj", "src/WebApi/"]
RUN dotnet restore "./src/WebApi/WebApi.csproj"
COPY ["src/Vegasco.Server.Api/Vegasco.Server.Api.csproj", "src/Vegasco.Server.Api/"]
RUN dotnet restore "./src/Vegasco.Server.Api/Vegasco.Server.Api.csproj"
COPY . .
WORKDIR "/src/src/WebApi"
RUN dotnet build "./WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/build
WORKDIR "/src/src/Vegasco.Server.Api"
RUN dotnet build "./Vegasco.Server.Api.csproj" -c $BUILD_CONFIGURATION -o /app/build
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./WebApi.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
RUN dotnet publish "./Vegasco.Server.Api.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
HEALTHCHECK --interval=20s --timeout=1s --start-period=10s --retries=3 CMD curl --fail http://localhost:8080/health || exit 1
ENTRYPOINT ["dotnet", "WebApi.dll"]
ENTRYPOINT ["dotnet", "Vegasco.Server.Api.dll"]
+1 -1
View File
@@ -60,7 +60,7 @@ As appsettings.json (or a environment specific appsettings.*.json):
### Running the application
The solution uses Aspire to orchestrate the application. Specifically, it introduces sensible service defaults, including but not limited to OpenTelemetry,
creates a Postgres database as a docker container, and starts the WebApi with the correct configuration to communicate with the database.
creates a Postgres database as a docker container, and starts the Api with the correct configuration to communicate with the database.
Ensure you have an identity provider set up, for example Keycloak, and configured the relevant options described above.
@@ -1,6 +1,6 @@
using FluentValidation;
namespace Vegasco.WebApi.Authentication;
namespace Vegasco.Server.Api.Authentication;
public class JwtOptions
{
@@ -2,7 +2,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Security.Claims;
namespace Vegasco.WebApi.Authentication;
namespace Vegasco.Server.Api.Authentication;
public sealed class UserAccessor
{
@@ -1,9 +1,9 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Users;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Users;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public class Car
{
@@ -1,6 +1,6 @@
using StronglyTypedIds;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
[StronglyTypedId]
public partial struct CarId;
@@ -1,11 +1,11 @@
using FluentValidation;
using FluentValidation.Results;
using Vegasco.WebApi.Authentication;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Persistence;
using Vegasco.WebApi.Users;
using Vegasco.Server.Api.Authentication;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
using Vegasco.Server.Api.Users;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class CreateCar
{
@@ -1,6 +1,6 @@
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class DeleteCar
{
@@ -1,6 +1,6 @@
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class GetCar
{
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class GetCars
{
@@ -1,10 +1,10 @@
using FluentValidation;
using FluentValidation.Results;
using Vegasco.WebApi.Authentication;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Authentication;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Cars;
namespace Vegasco.Server.Api.Cars;
public static class UpdateCar
{
@@ -1,4 +1,4 @@
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
public static class Constants
{
@@ -2,18 +2,19 @@
using FluentValidation;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.Extensions.Options;
using Vegasco.WebApi.Authentication;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Authentication;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
public static class DependencyInjectionExtensions
{
/// <summary>
/// Adds all the WebApi related services to the Dependency Injection container.
/// Adds all the Api related services to the Dependency Injection container.
/// </summary>
/// <param name="builder"></param>
public static void AddWebApiServices(this IHostApplicationBuilder builder)
public static void AddApiServices(this IHostApplicationBuilder builder)
{
builder.Services
.AddMiscellaneousServices()
@@ -30,7 +31,7 @@ public static class DependencyInjectionExtensions
services.AddValidatorsFromAssemblies(
[
typeof(IWebApiMarker).Assembly
typeof(IApiMarker).Assembly
], ServiceLifetime.Singleton);
services.AddHealthChecks();
@@ -125,7 +126,7 @@ public static class DependencyInjectionExtensions
private static IHostApplicationBuilder AddDbContext(this IHostApplicationBuilder builder)
{
builder.AddNpgsqlDbContext<ApplicationDbContext>(Server.AppHost.Shared.Constants.Database.Name);
builder.AddNpgsqlDbContext<ApplicationDbContext>(AppHost.Shared.Constants.Database.Name);
return builder;
}
}
@@ -2,7 +2,7 @@
using FluentValidation.Results;
using Microsoft.Extensions.Options;
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
public class FluentValidationOptions<TOptions> : IValidateOptions<TOptions>
where TOptions : class
@@ -0,0 +1,3 @@
namespace Vegasco.Server.Api.Common;
public interface IApiMarker;
@@ -1,8 +1,9 @@
using Microsoft.AspNetCore.Localization;
using System.Globalization;
using Vegasco.WebApi.Endpoints;
using Vegasco.Server.Api.Endpoints;
using Vegasco.Server.ServiceDefaults;
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
internal static class StartupExtensions
{
@@ -12,7 +13,7 @@ internal static class StartupExtensions
builder.Configuration.AddEnvironmentVariables("Vegasco_");
builder.AddWebApiServices();
builder.AddApiServices();
WebApplication app = builder.Build();
return app;
@@ -2,7 +2,7 @@
using FluentValidation.Results;
using Microsoft.Extensions.Options;
namespace Vegasco.WebApi.Common;
namespace Vegasco.Server.Api.Common;
public static class ValidatorExtensions
{
@@ -38,7 +38,7 @@ public static class ValidatorExtensions
{
if (!combinedErrors.TryGetValue(error.PropertyName, out HashSet<string>? value))
{
value = ([error.ErrorMessage]);
value = [error.ErrorMessage];
combinedErrors[error.PropertyName] = value;
continue;
}
@@ -1,8 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Vegasco.WebApi.Cars;
using Vegasco.Server.Api.Cars;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public class Consumption
{
@@ -1,6 +1,6 @@
using StronglyTypedIds;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
[StronglyTypedId]
@@ -1,10 +1,10 @@
using FluentValidation;
using FluentValidation.Results;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class CreateConsumption
{
@@ -1,6 +1,6 @@
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class DeleteConsumption
{
@@ -1,6 +1,6 @@
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class GetConsumption
{
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class GetConsumptions
{
@@ -1,9 +1,9 @@
using FluentValidation;
using FluentValidation.Results;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Persistence;
namespace Vegasco.WebApi.Consumptions;
namespace Vegasco.Server.Api.Consumptions;
public static class UpdateConsumption
{
@@ -1,12 +1,11 @@
using Asp.Versioning.Builder;
using Asp.Versioning.Conventions;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Info;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Info;
namespace Vegasco.WebApi.Endpoints;
namespace Vegasco.Server.Api.Endpoints;
public static class EndpointExtensions
{
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Http.HttpResults;
namespace Vegasco.WebApi.Info;
namespace Vegasco.Server.Api.Info;
public class GetServerInfo
{
@@ -1,10 +1,10 @@
using Microsoft.EntityFrameworkCore;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Common;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Users;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Common;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Users;
namespace Vegasco.WebApi.Persistence;
namespace Vegasco.Server.Api.Persistence;
public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
{
@@ -17,6 +17,6 @@ public class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ApplyConfigurationsFromAssembly(typeof(IWebApiMarker).Assembly);
modelBuilder.ApplyConfigurationsFromAssembly(typeof(IApiMarker).Assembly);
}
}
@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore;
namespace Vegasco.WebApi.Persistence;
namespace Vegasco.Server.Api.Persistence;
public class ApplyMigrationsService(ILogger<ApplyMigrationsService> logger, IServiceScopeFactory scopeFactory)
: IHostedService
@@ -5,11 +5,12 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
#nullable disable
namespace Vegasco.WebApi.Persistence.Migrations
namespace Vegasco.Server.Api.Persistence.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20240818105918_Initial")]
@@ -25,7 +26,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
@@ -46,7 +47,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Cars");
});
modelBuilder.Entity("Vegasco.WebApi.Consumptions.Consumption", b =>
modelBuilder.Entity("Vegasco.Server.Api.Consumptions.Consumption", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
@@ -73,7 +74,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Consumptions");
});
modelBuilder.Entity("Vegasco.WebApi.Users.User", b =>
modelBuilder.Entity("Vegasco.Server.Api.Users.User", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
@@ -83,9 +84,9 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Users");
});
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.HasOne("Vegasco.WebApi.Users.User", "User")
b.HasOne("Vegasco.Server.Api.Users.User", "User")
.WithMany("Cars")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
@@ -94,9 +95,9 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Vegasco.WebApi.Consumptions.Consumption", b =>
modelBuilder.Entity("Vegasco.Server.Api.Consumptions.Consumption", b =>
{
b.HasOne("Vegasco.WebApi.Cars.Car", "Car")
b.HasOne("Vegasco.Server.Api.Cars.Car", "Car")
.WithMany("Consumptions")
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
@@ -105,12 +106,12 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.Navigation("Car");
});
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.Navigation("Consumptions");
});
modelBuilder.Entity("Vegasco.WebApi.Users.User", b =>
modelBuilder.Entity("Vegasco.Server.Api.Users.User", b =>
{
b.Navigation("Cars");
});
@@ -1,9 +1,8 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Vegasco.WebApi.Persistence.Migrations
namespace Vegasco.Server.Api.Persistence.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration
@@ -4,11 +4,12 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Persistence;
#nullable disable
namespace Vegasco.WebApi.Persistence.Migrations
namespace Vegasco.Server.Api.Persistence.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
@@ -22,7 +23,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
@@ -43,7 +44,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Cars");
});
modelBuilder.Entity("Vegasco.WebApi.Consumptions.Consumption", b =>
modelBuilder.Entity("Vegasco.Server.Api.Consumptions.Consumption", b =>
{
b.Property<Guid>("Id")
.HasColumnType("uuid");
@@ -70,7 +71,7 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Consumptions");
});
modelBuilder.Entity("Vegasco.WebApi.Users.User", b =>
modelBuilder.Entity("Vegasco.Server.Api.Users.User", b =>
{
b.Property<string>("Id")
.HasColumnType("text");
@@ -80,9 +81,9 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.ToTable("Users");
});
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.HasOne("Vegasco.WebApi.Users.User", "User")
b.HasOne("Vegasco.Server.Api.Users.User", "User")
.WithMany("Cars")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
@@ -91,9 +92,9 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Vegasco.WebApi.Consumptions.Consumption", b =>
modelBuilder.Entity("Vegasco.Server.Api.Consumptions.Consumption", b =>
{
b.HasOne("Vegasco.WebApi.Cars.Car", "Car")
b.HasOne("Vegasco.Server.Api.Cars.Car", "Car")
.WithMany("Consumptions")
.HasForeignKey("CarId")
.OnDelete(DeleteBehavior.Cascade)
@@ -102,12 +103,12 @@ namespace Vegasco.WebApi.Persistence.Migrations
b.Navigation("Car");
});
modelBuilder.Entity("Vegasco.WebApi.Cars.Car", b =>
modelBuilder.Entity("Vegasco.Server.Api.Cars.Car", b =>
{
b.Navigation("Consumptions");
});
modelBuilder.Entity("Vegasco.WebApi.Users.User", b =>
modelBuilder.Entity("Vegasco.Server.Api.Users.User", b =>
{
b.Navigation("Cars");
});
@@ -1,4 +1,4 @@
using Vegasco.WebApi.Common;
using Vegasco.Server.Api.Common;
WebApplication.CreateBuilder(args)
.ConfigureServices()
@@ -1,6 +1,6 @@
using Vegasco.WebApi.Cars;
using Vegasco.Server.Api.Cars;
namespace Vegasco.WebApi.Users;
namespace Vegasco.Server.Api.Users;
public class User
{
@@ -1,7 +1,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace Vegasco.WebApi.Users;
namespace Vegasco.Server.Api.Users;
public class UserTableConfiguration : IEntityTypeConfiguration<User>
{
@@ -7,7 +7,7 @@
<UserSecretsId>4bf893d3-0c16-41ec-8b46-2768d841215d</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>..\..</DockerfileContext>
<RootNamespace>Vegasco.WebApi</RootNamespace>
<RootNamespace>Vegasco.Server.Api</RootNamespace>
</PropertyGroup>
<ItemGroup>
@@ -4,7 +4,7 @@ public static class Constants
{
public static class Projects
{
public const string WebApiName = "webapi";
public const string Api = "Vegasco_Server_Api";
}
public static class Database
+1 -1
View File
@@ -7,7 +7,7 @@ IResourceBuilder<PostgresDatabaseResource> postgres = builder.AddPostgres(Consta
.AddDatabase(Constants.Database.Name);
builder
.AddProject<Projects.WebApi>(Constants.Projects.WebApiName)
.AddProject<Projects.Vegasco_Server_Api>(Constants.Projects.Api)
.WithReference(postgres)
.WaitFor(postgres);
@@ -21,7 +21,7 @@
<ItemGroup>
<ProjectReference Include="..\Vegasco.Server.AppHost.Shared\Vegasco.Server.AppHost.Shared.csproj" IsAspireProjectResource="false" />
<ProjectReference Include="..\WebApi\WebApi.csproj" />
<ProjectReference Include="..\Vegasco.Server.Api\Vegasco.Server.Api.csproj" />
</ItemGroup>
</Project>
@@ -2,13 +2,13 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Diagnostics.HealthChecks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.ServiceDiscovery;
using OpenTelemetry;
using OpenTelemetry.Metrics;
using OpenTelemetry.Trace;
namespace Microsoft.Extensions.Hosting;
namespace Vegasco.Server.ServiceDefaults;
// Adds common .NET Aspire services: service discovery, resilience, health checks, and OpenTelemetry.
// This project should be referenced by each service project in your solution.
-3
View File
@@ -1,3 +0,0 @@
namespace Vegasco.WebApi.Common;
public interface IWebApiMarker;
@@ -1,7 +1,7 @@
using Bogus;
using Vegasco.WebApi.Cars;
using Vegasco.Server.Api.Cars;
namespace WebApi.Tests.Integration;
namespace Vegasco.Server.Api.Tests.Integration;
internal class CarFaker
{
@@ -3,10 +3,10 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Persistence;
namespace WebApi.Tests.Integration.Cars;
namespace Vegasco.Server.Api.Tests.Integration.Cars;
[Collection(SharedTestCollection.Name)]
public class CreateCarTests : IAsyncLifetime
@@ -2,10 +2,10 @@
using Microsoft.Extensions.DependencyInjection;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Persistence;
namespace WebApi.Tests.Integration.Cars;
namespace Vegasco.Server.Api.Tests.Integration.Cars;
[Collection(SharedTestCollection.Name)]
public class DeleteCarTests : IAsyncLifetime
@@ -1,9 +1,9 @@
using FluentAssertions;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.Server.Api.Cars;
namespace WebApi.Tests.Integration.Cars;
namespace Vegasco.Server.Api.Tests.Integration.Cars;
[Collection(SharedTestCollection.Name)]
public class GetCarTests : IAsyncLifetime
@@ -1,9 +1,9 @@
using FluentAssertions;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.Server.Api.Cars;
namespace WebApi.Tests.Integration.Cars;
namespace Vegasco.Server.Api.Tests.Integration.Cars;
[Collection(SharedTestCollection.Name)]
public class GetCarsTests : IAsyncLifetime
@@ -3,10 +3,10 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Persistence;
namespace WebApi.Tests.Integration.Cars;
namespace Vegasco.Server.Api.Tests.Integration.Cars;
[Collection(SharedTestCollection.Name)]
public class UpdateCarTests : IAsyncLifetime
@@ -1,7 +1,7 @@
using Bogus;
using Vegasco.WebApi.Consumptions;
using Vegasco.Server.Api.Consumptions;
namespace WebApi.Tests.Integration;
namespace Vegasco.Server.Api.Tests.Integration;
internal class ConsumptionFaker
{
@@ -3,11 +3,11 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Persistence;
namespace WebApi.Tests.Integration.Consumptions;
namespace Vegasco.Server.Api.Tests.Integration.Consumptions;
[Collection(SharedTestCollection.Name)]
public class CreateConsumptionTests : IAsyncLifetime
@@ -2,11 +2,11 @@
using Microsoft.Extensions.DependencyInjection;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Persistence;
namespace WebApi.Tests.Integration.Consumptions;
namespace Vegasco.Server.Api.Tests.Integration.Consumptions;
[Collection(SharedTestCollection.Name)]
public class DeleteConsumptionTests : IAsyncLifetime
@@ -2,11 +2,11 @@
using Microsoft.Extensions.DependencyInjection;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Persistence;
namespace WebApi.Tests.Integration.Consumptions;
namespace Vegasco.Server.Api.Tests.Integration.Consumptions;
[Collection(SharedTestCollection.Name)]
public class GetConsumptionTests : IAsyncLifetime
@@ -2,11 +2,11 @@
using Microsoft.Extensions.DependencyInjection;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Persistence;
namespace WebApi.Tests.Integration.Consumptions;
namespace Vegasco.Server.Api.Tests.Integration.Consumptions;
[Collection(SharedTestCollection.Name)]
public class GetConsumptionsTests : IAsyncLifetime
@@ -3,11 +3,11 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using System.Net;
using System.Net.Http.Json;
using Vegasco.WebApi.Cars;
using Vegasco.WebApi.Consumptions;
using Vegasco.WebApi.Persistence;
using Vegasco.Server.Api.Cars;
using Vegasco.Server.Api.Consumptions;
using Vegasco.Server.Api.Persistence;
namespace WebApi.Tests.Integration.Consumptions;
namespace Vegasco.Server.Api.Tests.Integration.Consumptions;
[Collection(SharedTestCollection.Name)]
public class UpdateConsumptionTests : IAsyncLifetime
@@ -1,6 +1,7 @@
using FluentAssertions;
namespace WebApi.Tests.Integration;
namespace Vegasco.Server.Api.Tests.Integration;
internal static class FluentAssertionConfiguration
{
private const int DateTimeComparisonPrecision = 100;
@@ -1,9 +1,9 @@
using System.Net.Http.Json;
using FluentAssertions;
using FluentAssertions.Extensions;
using Vegasco.WebApi.Info;
using Vegasco.Server.Api.Info;
namespace WebApi.Tests.Integration.Info;
namespace Vegasco.Server.Api.Tests.Integration.Info;
[Collection(SharedTestCollection.Name)]
public class GetServerInfoTests
@@ -2,7 +2,7 @@
using Respawn;
using System.Data.Common;
namespace WebApi.Tests.Integration;
namespace Vegasco.Server.Api.Tests.Integration;
internal sealed class PostgresRespawner : IDisposable
{
private readonly DbConnection _connection;
@@ -1,4 +1,4 @@
namespace WebApi.Tests.Integration;
namespace Vegasco.Server.Api.Tests.Integration;
[CollectionDefinition(Name)]
public class SharedTestCollection : ICollectionFixture<WebAppFactory>
@@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Authorization.Policy;
using Microsoft.AspNetCore.Http;
using System.Security.Claims;
namespace WebApi.Tests.Integration;
namespace Vegasco.Server.Api.Tests.Integration;
public sealed class TestUserAlwaysAuthorizedPolicyEvaluator : IPolicyEvaluator
{
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
@@ -16,7 +16,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="8.3.0" />
<PackageReference Include="FluentAssertions" Version="[7.2.0,8.0.0)" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="9.0.5" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
@@ -32,7 +32,7 @@
<ItemGroup>
<ProjectReference Include="..\..\src\Vegasco.Server.AppHost.Shared\Vegasco.Server.AppHost.Shared.csproj" />
<ProjectReference Include="..\..\src\WebApi\WebApi.csproj" />
<ProjectReference Include="..\..\src\Vegasco.Server.Api\Vegasco.Server.Api.csproj" />
</ItemGroup>
<ItemGroup>
@@ -7,11 +7,11 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Testcontainers.PostgreSql;
using Vegasco.WebApi.Common;
using Vegasco.Server.Api.Common;
namespace WebApi.Tests.Integration;
namespace Vegasco.Server.Api.Tests.Integration;
public sealed class WebAppFactory : WebApplicationFactory<IWebApiMarker>, IAsyncLifetime
public sealed class WebAppFactory : WebApplicationFactory<IApiMarker>, IAsyncLifetime
{
private readonly PostgreSqlContainer _database = new PostgreSqlBuilder()
.WithImage(DockerImage)
@@ -38,7 +38,7 @@ public sealed class WebAppFactory : WebApplicationFactory<IWebApiMarker>, IAsync
{
IEnumerable<KeyValuePair<string, string?>> customConfig =
[
new KeyValuePair<string, string?>($"ConnectionStrings:{Vegasco.Server.AppHost.Shared.Constants.Database.Name}", _database.GetConnectionString()),
new KeyValuePair<string, string?>($"ConnectionStrings:{AppHost.Shared.Constants.Database.Name}", _database.GetConnectionString()),
new KeyValuePair<string, string?>("JWT:ValidAudience", "https://localhost"),
new KeyValuePair<string, string?>("JWT:MetadataUrl", "https://localhost"),
new KeyValuePair<string, string?>("JWT:NameClaimType", null),
@@ -3,9 +3,9 @@ using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
using NSubstitute;
using System.Security.Claims;
using Vegasco.WebApi.Authentication;
using Vegasco.Server.Api.Authentication;
namespace WebApi.Tests.Unit.Authentication;
namespace Vegasco.Server.Api.Tests.Unit.Authentication;
public sealed class UserAccessorTests
{
private readonly UserAccessor _sut;
@@ -1,8 +1,8 @@
using FluentAssertions;
using FluentValidation.Results;
using Vegasco.WebApi.Cars;
using Vegasco.Server.Api.Cars;
namespace WebApi.Tests.Unit.Cars;
namespace Vegasco.Server.Api.Tests.Unit.Cars;
public sealed class CreateCarRequestValidatorTests
{
@@ -1,8 +1,8 @@
using FluentAssertions;
using FluentValidation.Results;
using Vegasco.WebApi.Cars;
using Vegasco.Server.Api.Cars;
namespace WebApi.Tests.Unit.Cars;
namespace Vegasco.Server.Api.Tests.Unit.Cars;
public sealed class UpdateCarRequestValidatorTests
{
@@ -1,9 +1,9 @@
using FluentAssertions;
using FluentValidation.Results;
using NSubstitute;
using Vegasco.WebApi.Consumptions;
using Vegasco.Server.Api.Consumptions;
namespace WebApi.Tests.Unit.Consumptions;
namespace Vegasco.Server.Api.Tests.Unit.Consumptions;
public class CreateConsumptionRequestValidatorTests
{
private readonly CreateConsumption.Validator _sut;
@@ -1,9 +1,9 @@
using FluentAssertions;
using FluentValidation.Results;
using NSubstitute;
using Vegasco.WebApi.Consumptions;
using Vegasco.Server.Api.Consumptions;
namespace WebApi.Tests.Unit.Consumptions;
namespace Vegasco.Server.Api.Tests.Unit.Consumptions;
public class UpdateConsumptionRequestValidatorTests
{
@@ -26,7 +26,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\WebApi\WebApi.csproj" />
<ProjectReference Include="..\..\src\Vegasco.Server.Api\Vegasco.Server.Api.csproj" />
</ItemGroup>
<ItemGroup>
-50
View File
@@ -1,50 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.13.35617.110
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{089100B1-113F-4E66-888A-E83F3999EAFD}"
ProjectSection(SolutionItems) = preProject
.drone.yml = .drone.yml
Dockerfile = Dockerfile
README.md = README.md
version.json = version.json
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{827E0CD3-B72D-47B6-A68D-7590B98EB39B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi", "src\WebApi\WebApi.csproj", "{1B0A04C3-E6BC-0FB7-7994-7C99BDAB1788}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{0AB3BF05-4346-4AA6-1389-037BE0695223}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi.Tests.Integration", "tests\WebApi.Tests.Integration\WebApi.Tests.Integration.csproj", "{72BF8CBC-E916-1472-A1E2-8F5DCF1A95C6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WebApi.Tests.Unit", "tests\WebApi.Tests.Unit\WebApi.Tests.Unit.csproj", "{2DD4D427-6FA5-EC56-76FC-9D71C4631E00}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B0A04C3-E6BC-0FB7-7994-7C99BDAB1788}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1B0A04C3-E6BC-0FB7-7994-7C99BDAB1788}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1B0A04C3-E6BC-0FB7-7994-7C99BDAB1788}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1B0A04C3-E6BC-0FB7-7994-7C99BDAB1788}.Release|Any CPU.Build.0 = Release|Any CPU
{72BF8CBC-E916-1472-A1E2-8F5DCF1A95C6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{72BF8CBC-E916-1472-A1E2-8F5DCF1A95C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{72BF8CBC-E916-1472-A1E2-8F5DCF1A95C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{72BF8CBC-E916-1472-A1E2-8F5DCF1A95C6}.Release|Any CPU.Build.0 = Release|Any CPU
{2DD4D427-6FA5-EC56-76FC-9D71C4631E00}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2DD4D427-6FA5-EC56-76FC-9D71C4631E00}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2DD4D427-6FA5-EC56-76FC-9D71C4631E00}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2DD4D427-6FA5-EC56-76FC-9D71C4631E00}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1B0A04C3-E6BC-0FB7-7994-7C99BDAB1788} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
{72BF8CBC-E916-1472-A1E2-8F5DCF1A95C6} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
{2DD4D427-6FA5-EC56-76FC-9D71C4631E00} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
EndGlobalSection
EndGlobal
+3 -3
View File
@@ -9,10 +9,10 @@
<Project Path="src/Vegasco.Server.AppHost.Shared/Vegasco.Server.AppHost.Shared.csproj" />
<Project Path="src/Vegasco.Server.AppHost/Vegasco.Server.AppHost.csproj" />
<Project Path="src/Vegasco.Server.ServiceDefaults/Vegasco.Server.ServiceDefaults.csproj" />
<Project Path="src/WebApi/WebApi.csproj" />
<Project Path="src/Vegasco.Server.Api/Vegasco.Server.Api.csproj" />
</Folder>
<Folder Name="/tests/">
<Project Path="tests/WebApi.Tests.Integration/WebApi.Tests.Integration.csproj" />
<Project Path="tests/WebApi.Tests.Unit/WebApi.Tests.Unit.csproj" />
<Project Path="tests/Vegasco.Server.Api.Tests.Integration/Vegasco.Server.Api.Tests.Integration.csproj" />
<Project Path="tests/Vegasco.Server.Api.Tests.Unit/Vegasco.Server.Api.Tests.Unit.csproj" />
</Folder>
</Solution>