Addet integration test
This commit is contained in:
32
PointOfSale/IntegrationTests/IntegrationTests.csproj
Normal file
32
PointOfSale/IntegrationTests/IntegrationTests.csproj
Normal 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>
|
||||
29
PointOfSale/IntegrationTests/PosDbContextTests.cs
Normal file
29
PointOfSale/IntegrationTests/PosDbContextTests.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
3
PointOfSale/IntegrationTests/appsettings.json
Normal file
3
PointOfSale/IntegrationTests/appsettings.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"SqlServer": "Server=(localdb)\\MSSQLLocalDB;Database=pointofsale;Trusted_Connection=True;TrustServerCertificate=True;"
|
||||
}
|
||||
@@ -24,7 +24,7 @@ namespace Database
|
||||
IConfiguration config = l.ByEnvironment();
|
||||
string connectionString = config["SqlServer"].ToString();
|
||||
optionsBuilder
|
||||
.UseMySql(connectionString,ServerVersion.AutoDetect(connectionString))
|
||||
.UseSqlServer(connectionString)
|
||||
.UseLoggerFactory(LoggerFactory.Create(b => b
|
||||
.AddFilter(level => level >= LogLevel.Information)))
|
||||
.EnableSensitiveDataLogging()
|
||||
|
||||
@@ -15,6 +15,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pos.AppHost", "Pos.AppHost\
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Pos.ServiceDefaults", "Pos.ServiceDefaults\Pos.ServiceDefaults.csproj", "{EDC882E6-4983-35BD-3357-E433A3E64369}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Pos.Test", "Pos.Test", "{9051E89F-15CC-40A4-8C60-82C98151139E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IntegrationTests", "IntegrationTests\IntegrationTests.csproj", "{04551552-086E-4CF4-AFD3-A4E51CD36182}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -41,6 +45,10 @@ Global
|
||||
{EDC882E6-4983-35BD-3357-E433A3E64369}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EDC882E6-4983-35BD-3357-E433A3E64369}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EDC882E6-4983-35BD-3357-E433A3E64369}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{04551552-086E-4CF4-AFD3-A4E51CD36182}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{04551552-086E-4CF4-AFD3-A4E51CD36182}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{04551552-086E-4CF4-AFD3-A4E51CD36182}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{04551552-086E-4CF4-AFD3-A4E51CD36182}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -48,6 +56,7 @@ Global
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{6DD387E5-F403-40D5-A816-EAF6AE5809B2} = {5EA5190D-D086-4568-8EDD-359BEBF41CEE}
|
||||
{7865371E-75E4-45A6-99A1-0A32F1D29906} = {5EA5190D-D086-4568-8EDD-359BEBF41CEE}
|
||||
{04551552-086E-4CF4-AFD3-A4E51CD36182} = {9051E89F-15CC-40A4-8C60-82C98151139E}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {47E8B417-57AB-486D-8755-950B4AC84ACF}
|
||||
|
||||
Reference in New Issue
Block a user