Skip to content

Commit

Permalink
Merge branch 'main' of github.com:team-nameless/msoc-web
Browse files Browse the repository at this point in the history
  • Loading branch information
ShiinaKochiya committed Sep 4, 2024
2 parents 2a702fe + 07fc31c commit 91b8803
Show file tree
Hide file tree
Showing 55 changed files with 2,098 additions and 422 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ on:
push:
branches:
- main
pull_request:
pull_request_target:
branches:
- main
types: [opened, reopened, synchronize, assigned]

jobs:
build-and-test:
Expand All @@ -30,4 +31,4 @@ jobs:
run: dotnet restore

- name: Run tests
run: dotnet test MSOC.Backend.Tests -c Release -v n --nologo --no-restore
run: dotnet test MSOC.Backend.Tests -c Release --nologo --no-restore
26 changes: 0 additions & 26 deletions MSOC.Backend.Tests/Api/HealthCheckApiTest.cs

This file was deleted.

52 changes: 0 additions & 52 deletions MSOC.Backend.Tests/BackendTestBedFixture.cs

This file was deleted.

48 changes: 48 additions & 0 deletions MSOC.Backend.Tests/GameApplicationFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using MSOC.Backend.Service;

namespace MSOC.Backend.Tests;

public class GameApplicationFactory<TProgram> : WebApplicationFactory<TProgram> where TProgram : class
{
protected override IHost CreateHost(IHostBuilder builder)
{
builder.ConfigureServices(services =>
{
var gameDatabase = services.SingleOrDefault(d => d.ServiceType == typeof(DbContextOptions<GameDatabaseService>));
var trackDatabase = services.SingleOrDefault(d => d.ServiceType == typeof(DbContextOptions<TrackDatabaseService>));
var schoolDatabase = services.SingleOrDefault(d => d.ServiceType == typeof(DbContextOptions<SchoolDatabaseService>));
if (gameDatabase != null) services.Remove(gameDatabase);
if (trackDatabase != null) services.Remove(trackDatabase);
if (schoolDatabase != null) services.Remove(schoolDatabase);
var path = Directory.CreateDirectory(AppContext.BaseDirectory)
.Parent!.Parent!.Parent!.Parent!.ToString();
services.AddDbContext<SchoolDatabaseService>(
o => o.UseSqlite($"Filename={path}/MSOC.Backend/schools.db")
// ServiceLifetime.Transient
);
services.AddDbContext<TrackDatabaseService>(
o => o.UseSqlite($"Filename={path}/MSOC.Backend/tracks.db")
// ServiceLifetime.Transient
);
services.AddDbContext<GameDatabaseService>(
o => o.UseSqlite($"Filename={path}/MSOC.Backend/MSOC.Test.db")
//ServiceLifetime.Transient
);
// services.AddSingleton<IConfiguration>();
services.AddTransient<MaimaiInquiryService>();
});

return base.CreateHost(builder);
}
}
Loading

0 comments on commit 91b8803

Please sign in to comment.