Skip to content

Commit

Permalink
Add dotnet format to pipeline stages
Browse files Browse the repository at this point in the history
- Fix formatting issues
  • Loading branch information
ivan_nizic committed Dec 5, 2024
1 parent ef59155 commit 83cf413
Show file tree
Hide file tree
Showing 32 changed files with 104 additions and 103 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/basic-dotnet-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:

- name: Build
run: dotnet build --no-restore "source/FlightScanner.sln"

- name: Run dotnet format
run: dotnet format "source/FlightScanner.sln" --no-restore --verify-no-changes --exclude source/FlightScanner.Client.BlazorWA/Program.cs

- name: Test
run: dotnet test --no-build --verbosity normal "source/FlightScanner.sln"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Flight Scanner can be used to search for flights and look for available flights.
- Write unit and integration tests for some of features
- Add images for solution architecture, both for project dependencies and logical architecture
- Add test coverage images
- Add automation for build and test stages
- Add automation for build, format and test stages
- Automate generation of SQlite database with IATA codes

## Usage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FlightScanner.AirportCodes.Cli.Models;
using System.Data.SQLite;
using System.Data.SQLite;
using FlightScanner.AirportCodes.Cli.Models;

namespace FlightScanner.AirportCodes.Cli.Database;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using FlightScanner.Client.BlazorWA.Models;
using System.ComponentModel;
using FlightScanner.Client.BlazorWA.Models;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.QuickGrid;
using System.ComponentModel;

namespace FlightScanner.Client.BlazorWA.Components;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FlightScanner.Common.Enumerations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using FlightScanner.Common.Enumerations;

namespace FlightScanner.Client.BlazorWA.Models;

Expand Down
8 changes: 4 additions & 4 deletions source/FlightScanner.Client.BlazorWA/Program.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using FlightScanner.Client.BlazorWA;
using FlightScanner.Client.BlazorWA;
using FlightScanner.Client.BlazorWA.Models;
using FlightScanner.Client.BlazorWA.Services.Contracts;
using FlightScanner.Client.BlazorWA.Services.Implementations;
using FlightScanner.Client.BlazorWA.Models;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using FlightScanner.Client.BlazorWA.Services.Contracts;
using System.Net.Http.Json;
using FlightScanner.DTOs.Responses;
using System.Net.Http.Json;
using FlightScanner.Client.BlazorWA.Services.Contracts;
using FlightScanner.DTOs.Models;
using FlightScanner.DTOs.Responses;

namespace FlightScanner.Client.BlazorWA.Services.Implementations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using FlightScanner.Client.BlazorWA.Models;
using System.Net.Http.Json;
using System.Web;
using FlightScanner.Client.BlazorWA.Models;
using FlightScanner.Client.BlazorWA.Services.Contracts;
using FlightScanner.Common.Constants;
using FlightScanner.DTOs.Models;
using FlightScanner.DTOs.Responses;
using System.Net.Http.Json;
using System.Web;

namespace FlightScanner.Client.BlazorWA.Services.Implementations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FlightScanner.DTOs.Models.Amadeus;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
using FlightScanner.DTOs.Models.Amadeus;

namespace FlightScanner.DTOs.Responses;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FlightScanner.DTOs.Models.Aviation;
using System.Text.Json.Serialization;
using System.Text.Json.Serialization;
using FlightScanner.DTOs.Models.Aviation;

namespace FlightScanner.DTOs.Responses;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using FlightScanner.Domain.Entities;
using Microsoft.EntityFrameworkCore;
using FlightScanner.Domain.Entities;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace FlightScanner.Persistence.Configurations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FlightScanner.Persistence.Database;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;

namespace FlightScanner.Persistence.DesignTime;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,32 @@

#nullable disable

namespace FlightScanner.Persistence.Migrations
namespace FlightScanner.Persistence.Migrations;

/// <inheritdoc />
public partial class InitialMigration : Migration
{
/// <inheritdoc />
public partial class InitialMigration : Migration
protected override void Up(MigrationBuilder migrationBuilder)
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Airports",
columns: table => new
{
IATA_Code = table.Column<string>(type: "TEXT", nullable: false),
Airport_Name = table.Column<string>(type: "TEXT", nullable: true),
Location = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Airports", x => x.IATA_Code);
});
}
migrationBuilder.CreateTable(
name: "Airports",
columns: table => new
{
IATA_Code = table.Column<string>(type: "TEXT", nullable: false),
Airport_Name = table.Column<string>(type: "TEXT", nullable: true),
Location = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Airports", x => x.IATA_Code);
});
}

/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Airports");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Airports");
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using FlightScanner.Domain.Repositories;
using System.Reflection;
using FlightScanner.Domain.Repositories;
using FlightScanner.Persistence.Database;
using FlightScanner.Persistence.Repositories;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using System.Reflection;

namespace FlightScanner.Persistence;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using FlightScanner.Domain.Entities;
using System.Net.Mime;
using FlightScanner.Domain.Entities;
using FlightScanner.DTOs.Exceptions;
using FlightScanner.DTOs.Responses;
using FlightScanner.WebApi.Filters;
Expand All @@ -7,7 +8,6 @@
using FlightsScanner.Application.Airports.Queries.GetAllAirports;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Net.Mime;

namespace FlightScanner.WebApi.Controllers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using FlightScanner.Common.Constants;
using System.Net.Mime;
using FlightScanner.Common.Constants;
using FlightScanner.DTOs.Exceptions;
using FlightScanner.DTOs.Responses;
using FlightScanner.WebApi.Validation;
using FlightsScanner.Application.Flights.Queries.GetFlights;
using MediatR;
using Microsoft.AspNetCore.Mvc;
using System.Net.Mime;

namespace FlightScanner.WebApi.Controllers;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace FlightScanner.WebApi.Filters;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc.Filters;
using FlightScanner.Domain.Entities;
using Microsoft.AspNetCore.Mvc;
using FlightScanner.Domain.Entities;
using Microsoft.AspNetCore.Mvc.Filters;

namespace FlightScanner.WebApi.Filters;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Net.Mime;
using System.Net;
using System.Net;
using System.Net.Mime;
using FlightScanner.DTOs.Exceptions;

namespace FlightScanner.WebApi.Middleware;
Expand Down
12 changes: 6 additions & 6 deletions source/FlightScanner.WebApi/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using FlightsScanner.Application.Constants;
using FlightsScanner.Application.Services.Contracts;
using FlightScanner.DTOs.Models;
using FlightScanner.Persistence;
using FlightScanner.WebApi.Middleware;
using FlightsScanner.Application.Airports.Queries.GetAirport;
using FlightsScanner.Application.Services.Implementations;
using FlightsScanner.Application.Flights.Queries.GetFlights;
using FlightsScanner.Application.Authentication;
using FlightScanner.WebApi.Middleware;
using FlightScanner.DTOs.Models;
using FlightsScanner.Application.Constants;
using FlightsScanner.Application.Flights.Queries.GetFlights;
using FlightsScanner.Application.Services.Contracts;
using FlightsScanner.Application.Services.Implementations;

public class Program
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FlightScanner.Common.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using FlightScanner.Common.Constants;

namespace FlightScanner.WebApi.Validation;

Expand Down
4 changes: 2 additions & 2 deletions source/FlightScanner.WebApi/Validation/CurrencyValidation.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using FlightScanner.Common.Enumerations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using FlightScanner.Common.Enumerations;

namespace FlightScanner.WebApi.Validation;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using FlightScanner.Common.Constants;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using FlightScanner.Common.Constants;

namespace FlightScanner.WebApi.Validation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public static class CacheConstants

#region Flights


public const int SLIDING_EXPIRATION_FOR_AMADEUS_AUTHORIZATION = 300;

public const int ABSOLUTE_EXPIRATION_FOR_AMADEUS_AUTHORIZATION = 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using FlightScanner.DTOs.Responses;
using System.Net.Http.Json;
using System.Net.Mime;
using System.Text;
using FlightScanner.DTOs.Responses;
using FlightsScanner.Application.Constants;
using FlightsScanner.Application.Services.Contracts;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Configuration;
using System.Net.Http.Json;
using System.Net.Mime;
using System.Text;

namespace FlightsScanner.Application.Services.Implementations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using FlightScanner.Domain.Exceptions;
using System.Net.Http.Json;
using System.Web;
using FlightScanner.Domain.Exceptions;
using FlightScanner.DTOs.Models;
using FlightScanner.DTOs.Responses;
using FlightsScanner.Application.Constants;
using FlightsScanner.Application.Services.Contracts;
using System.Net.Http.Json;
using System.Web;

namespace FlightsScanner.Application.Services.Implementations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using FlightScanner.Domain.Exceptions;
using System.Net.Http.Json;
using FlightScanner.Domain.Exceptions;
using FlightScanner.DTOs.Models;
using FlightScanner.DTOs.Responses;
using FlightsScanner.Application.Constants;
using FlightsScanner.Application.Services.Contracts;
using Microsoft.Extensions.Configuration;
using System.Net.Http.Json;

namespace FlightsScanner.Application.Services.Implementations;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using FlightScanner.Domain.Entities;
using System.Net;
using System.Net.Http.Json;
using FlightScanner.Domain.Entities;
using FlightScanner.Domain.Repositories;
using FlightScanner.DTOs.Responses;
using FlightScanner.WebApi.IntegratoinTests.TestInfrastructure;
using Microsoft.Extensions.DependencyInjection;
using NSubstitute;
using System.Net;
using System.Net.Http.Json;

namespace FlightScanner.WebApi.IntegratoinTests.Controllers;

Expand Down Expand Up @@ -81,27 +81,27 @@ public async Task GetAirportOverHttp_WhenRequestContainsForbiddenIataCode_Should
var expectedErrorTitle = "Forbidden IATA code";
var expectedErrorMessage = $"Airport with IATA code {closedAirport} is currently closed due to war conditions!";

var foundMovieResponse = await httpClient.GetAsync($"api/v2/airport?iataCode={closedAirport}");
var contentString = await foundMovieResponse.Content.ReadAsStringAsync();
var httpResponse = await httpClient.GetAsync($"api/v2/airport?iataCode={closedAirport}");
var contentString = await httpResponse.Content.ReadAsStringAsync();

Assert.Multiple(() =>
{
Assert.That(foundMovieResponse.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
Assert.That(httpResponse.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest));
StringAssert.Contains(expectedErrorTitle, contentString);
StringAssert.Contains(expectedErrorMessage, contentString);
});
}

[Test]
public async Task GetAirportOverHttp_WhenRequestIsValid_ShouldReceiveExpectedMovie()
public async Task GetAirportOverHttp_WhenRequestIsValid_ShouldReceiveExpectedResponse()
{
var searchedAirport = "BOS";
var applicationFactory = new FlightScannerWebApplicationFactory();
var httpClient = applicationFactory.CreateClient();

var foundMovieResponse = await httpClient.GetAsync($"api/v2/airport?iataCode={searchedAirport}");
var httpResponse = await httpClient.GetAsync($"api/v2/airport?iataCode={searchedAirport}");

Assert.That(foundMovieResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
Assert.That(httpResponse.StatusCode, Is.EqualTo(HttpStatusCode.OK));
}

[Test]
Expand Down
Loading

0 comments on commit 83cf413

Please sign in to comment.