12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using Microsoft.AspNetCore.Mvc.Testing;
- using AnalyzerApi;
- using Xunit;
- using System.Net;
- using System.Text;
- using System.Text.Json;
- using AnalyzerApi.Models;
- namespace AnalyzerApi.Tests;
- public class IntegrationTests : IClassFixture<WebApplicationFactory<Program>>
- {
- private readonly WebApplicationFactory<Program> _factory;
- public IntegrationTests()
- {
- _factory = new WebApplicationFactory<Program>()
- .WithWebHostBuilder(builder =>
- {
- // Äîïîëíèòåëüíàÿ êîíôèãóðàöèÿ ïðè íåîáõîäèìîñòè
- });
- }
- [Theory]
- [InlineData("Biorad")]
- [InlineData("Ledetect")]
- public async Task PostOrder_ValidRequest_ReturnsOk(string analyzerName)
- {
- // Arrange
- var client = _factory.CreateClient();
- var order = new OrderRequest
- {
- Patient = 1,
- Services = new List<Service>
- {
- new() { ServiceCode = analyzerName == "Biorad" ? 548 : 311 }
- }
- };
- var content = new StringContent(JsonSerializer.Serialize(order), Encoding.UTF8, "application/json");
- // Act
- var response = await client.PostAsync($"/api/analyzer/{analyzerName}", content);
- var responseContent = await response.Content.ReadAsStringAsync();
- Console.WriteLine($"Response: {response.StatusCode}, Content: {responseContent}");
- // Assert
- Assert.Equal(HttpStatusCode.OK, response.StatusCode);
- }
- }
|