Skip to content

Commit cf63cda

Browse files
committed
Update test method
1 parent 67d5922 commit cf63cda

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

Directory.Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
<SwashbuckleVersion>6.*</SwashbuckleVersion>
1818

1919
<CoverletVersion>6.*</CoverletVersion>
20+
<FluentAssertionsVersion>6.*</FluentAssertionsVersion>
2021
<MicrosoftTestSdkVersion>17.*</MicrosoftTestSdkVersion>
22+
<SystemTextJsonVersion>8.*</SystemTextJsonVersion>
2123
<XunitVersion>2.*</XunitVersion>
2224
</PropertyGroup>
2325
</Project>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using System.Net;
2+
3+
using FluentAssertions;
4+
5+
namespace AzureOpenAIProxy.Tests;
6+
7+
public class AppHostProgramTests
8+
{
9+
[Theory]
10+
[InlineData("apiapp", "/health", HttpStatusCode.OK)]
11+
[InlineData("playgroundapp", "/health", HttpStatusCode.OK)]
12+
public async Task Given_Resource_When_Invoked_Endpoint_Then_It_Should_Return_Healthy(string resourceName, string endpoint, HttpStatusCode statusCode)
13+
{
14+
// Arrange
15+
var appHost = await DistributedApplicationTestingBuilder.CreateAsync<Projects.AzureOpenAIProxy_AppHost>();
16+
await using var app = await appHost.BuildAsync();
17+
await app.StartAsync();
18+
19+
// Act
20+
var httpClient = app.CreateHttpClient(resourceName);
21+
var response = await httpClient.GetAsync(endpoint);
22+
23+
// Assert
24+
response.StatusCode.Should().Be(statusCode);
25+
}
26+
}

test/AzureOpenAIProxy.AppHost.Tests/AzureOpenAIProxy.AppHost.Tests.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
<PrivateAssets>all</PrivateAssets>
1515
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1616
</PackageReference>
17+
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
1718
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftTestSdkVersion)" />
19+
<PackageReference Include="System.Text.Json" Version="$(SystemTextJsonVersion)" />
1820
<PackageReference Include="xunit" Version="$(XunitVersion)" />
1921
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)">
2022
<PrivateAssets>all</PrivateAssets>

test/AzureOpenAIProxy.AppHost.Tests/WebTests.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)