Açıklama Yok

akapralov 22d9aef3bd lab 2 hafta önce
bin 22d9aef3bd lab 2 hafta önce
obj 22d9aef3bd lab 2 hafta önce
1.png 22d9aef3bd lab 2 hafta önce
AnalyzerApi.Tests.csproj 22d9aef3bd lab 2 hafta önce
UnitTest1.cs 22d9aef3bd lab 2 hafta önce
readme.md 22d9aef3bd lab 2 hafta önce

readme.md

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);
    }
    }