BaseTestd
This commit is contained in:
42
src/Backend/DiunaBI.Tests/BaseTests.cs
Normal file
42
src/Backend/DiunaBI.Tests/BaseTests.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Xunit;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace DiunaBI.Tests;
|
||||
|
||||
public class ApiConnectionTests : IClassFixture<WebApplicationFactory<Program>>
|
||||
{
|
||||
private readonly WebApplicationFactory<Program> _factory;
|
||||
|
||||
public ApiConnectionTests(WebApplicationFactory<Program> factory)
|
||||
{
|
||||
_factory = factory;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PingToApi()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
var response = await client.GetAsync("/api/Ping/Ping");
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var statusCode = (int)response.StatusCode;
|
||||
|
||||
Assert.Equal(200, statusCode);
|
||||
Assert.Equal("Pong", content);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task DatabaseConnectionTest()
|
||||
{
|
||||
var client = _factory.CreateClient();
|
||||
|
||||
var response = await client.GetAsync("/api/Layers?start=0&limit=1");
|
||||
var content = await response.Content.ReadAsStringAsync();
|
||||
var statusCode = (int)response.StatusCode;
|
||||
|
||||
Assert.Equal(200, statusCode);
|
||||
var layers = JsonSerializer.Deserialize<dynamic>(content);
|
||||
Assert.NotNull(layers);
|
||||
}
|
||||
}
|
||||
24
src/Backend/DiunaBI.Tests/DiunaBI.Tests.csproj
Normal file
24
src/Backend/DiunaBI.Tests/DiunaBI.Tests.csproj
Normal file
@@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.2" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DiunaBI.WebAPI\DiunaBI.WebAPI.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user