Addet integration test

This commit is contained in:
2026-07-28 12:02:03 +02:00
parent a30bd769fb
commit 6d55a6e840
5 changed files with 74 additions and 1 deletions

View File

@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.4" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Pos.Ui\Database\Database.csproj" />
</ItemGroup>
<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,29 @@
using Database;
using Database.Repository;
using Microsoft.EntityFrameworkCore;
using Xunit.Abstractions;
namespace IntegrationTests;
public class PosDbContextTests
{
private readonly ITestOutputHelper _output;
public PosDbContextTests(ITestOutputHelper output)
{
_output = output;
}
[Fact]
public void EmployeeRepository_ShouldReturnEmployees()
{
using var repository = new EmployeeRepository();
var employees = repository.GetAll();
_output.WriteLine(
$"Antal medarbejdere hentet: {employees.Count}");
Assert.NotEmpty(employees);
}
}

View File

@@ -0,0 +1,3 @@
{
"SqlServer": "Server=(localdb)\\MSSQLLocalDB;Database=pointofsale;Trusted_Connection=True;TrustServerCertificate=True;"
}