Xunit testing implemented
And project published to azure
This commit is contained in:
48
H_Plus_SportsX.Tests/CustomerIntegrationTests.cs
Normal file
48
H_Plus_SportsX.Tests/CustomerIntegrationTests.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using H_Plus_Sports;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using Xunit;
|
||||
|
||||
namespace H_Plus_SportsX.Tests
|
||||
{
|
||||
public class CustomerIntegrationTests
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
public CustomerIntegrationTests()
|
||||
{
|
||||
var server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
|
||||
_client = server.CreateClient();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CustomerGetAllTest()
|
||||
{
|
||||
//Arr
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), "/api/Customers");
|
||||
|
||||
//Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
//Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData(100)]
|
||||
public void CustomerGetOneTest(int id)
|
||||
{
|
||||
//Arr
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), $"/api/Customers/{id}");
|
||||
|
||||
//Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
//Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
21
H_Plus_SportsX.Tests/H_Plus_SportsX.Tests.csproj
Normal file
21
H_Plus_SportsX.Tests/H_Plus_SportsX.Tests.csproj
Normal file
@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="3.1.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
|
||||
<PackageReference Include="xunit" Version="2.4.0" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\H_PLUS_Sports\H_Plus_Sports.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user