You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.4 KiB
49 lines
1.4 KiB
using API.Controllers;
|
|
using DbServices;
|
|
using FluentAssertions;
|
|
using Microsoft.Data.Sqlite;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Model;
|
|
using StubContext;
|
|
|
|
namespace UnitTests;
|
|
|
|
public class UsersControllerTest
|
|
{
|
|
private static UsersController GetUserController(int userId)
|
|
{
|
|
var connection = new SqliteConnection("Data Source=:memory:");
|
|
connection.Open();
|
|
var context = new StubAppContext(
|
|
new DbContextOptionsBuilder<AppContext.AppContext>()
|
|
.UseSqlite(connection)
|
|
.Options
|
|
);
|
|
context.Database.EnsureCreated();
|
|
var controller = new UsersController(
|
|
new DbUserService(context),
|
|
new DbTeamService(context),
|
|
new DbTacticService(context),
|
|
new ManualContextAccessor(userId)
|
|
);
|
|
|
|
return controller;
|
|
}
|
|
|
|
[Fact]
|
|
public async void GetCurrentUserTest()
|
|
{
|
|
var controller = GetUserController(1);
|
|
var result = await controller.GetUser();
|
|
result.Should().BeEquivalentTo(new User(1, "maxime", "maxime@mail.com",
|
|
UsersController.DefaultProfilePicture, true));
|
|
}
|
|
|
|
[Fact]
|
|
public async void GetUserDataTest()
|
|
{
|
|
var controller = GetUserController(1);
|
|
var result = await controller.GetUserData();
|
|
result.Should().BeEquivalentTo(new UsersController.GetUserDataResponse([], []));
|
|
}
|
|
} |