From 6fb37cbee9534642ffff77145aac79591ff5feb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Sat, 21 Dec 2019 19:33:17 +0100 Subject: [PATCH] Xunit testing implemented And project published to azure --- H_PLUS_Sports.sln | 8 +++- .../CustomerIntegrationTests.cs | 48 +++++++++++++++++++ .../H_Plus_SportsX.Tests.csproj | 21 ++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 H_Plus_SportsX.Tests/CustomerIntegrationTests.cs create mode 100644 H_Plus_SportsX.Tests/H_Plus_SportsX.Tests.csproj diff --git a/H_PLUS_Sports.sln b/H_PLUS_Sports.sln index e536641..c1a5b0a 100644 --- a/H_PLUS_Sports.sln +++ b/H_PLUS_Sports.sln @@ -5,7 +5,9 @@ VisualStudioVersion = 16.0.29609.76 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H_Plus_Sports", "H_PLUS_Sports\H_Plus_Sports.csproj", "{A5EEAD5D-227A-482E-AD66-F17D87C1E187}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H_Plus_Sports.Tests", "H_Plus_Sports.Tests\H_Plus_Sports.Tests.csproj", "{8389C563-63EF-4ECA-9AE8-93FCE94E0BB7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H_Plus_Sports.Tests", "H_Plus_Sports.Tests\H_Plus_Sports.Tests.csproj", "{8389C563-63EF-4ECA-9AE8-93FCE94E0BB7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H_Plus_SportsX.Tests", "H_Plus_SportsX.Tests\H_Plus_SportsX.Tests.csproj", "{CA73A8FD-3032-428A-A0AB-6A432C414726}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -21,6 +23,10 @@ Global {8389C563-63EF-4ECA-9AE8-93FCE94E0BB7}.Debug|Any CPU.Build.0 = Debug|Any CPU {8389C563-63EF-4ECA-9AE8-93FCE94E0BB7}.Release|Any CPU.ActiveCfg = Release|Any CPU {8389C563-63EF-4ECA-9AE8-93FCE94E0BB7}.Release|Any CPU.Build.0 = Release|Any CPU + {CA73A8FD-3032-428A-A0AB-6A432C414726}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA73A8FD-3032-428A-A0AB-6A432C414726}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA73A8FD-3032-428A-A0AB-6A432C414726}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA73A8FD-3032-428A-A0AB-6A432C414726}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/H_Plus_SportsX.Tests/CustomerIntegrationTests.cs b/H_Plus_SportsX.Tests/CustomerIntegrationTests.cs new file mode 100644 index 0000000..f439725 --- /dev/null +++ b/H_Plus_SportsX.Tests/CustomerIntegrationTests.cs @@ -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()); + _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); + } + + } +} diff --git a/H_Plus_SportsX.Tests/H_Plus_SportsX.Tests.csproj b/H_Plus_SportsX.Tests/H_Plus_SportsX.Tests.csproj new file mode 100644 index 0000000..1918fff --- /dev/null +++ b/H_Plus_SportsX.Tests/H_Plus_SportsX.Tests.csproj @@ -0,0 +1,21 @@ + + + + netcoreapp3.1 + + false + + + + + + + + + + + + + + +