Test classes implemented
This commit is contained in:
87
H_Plus_Sports.Tests/CustomerIntegrationTests.cs
Normal file
87
H_Plus_Sports.Tests/CustomerIntegrationTests.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
|
||||
namespace H_Plus_Sports.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class CustomerIntegrationTests
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public CustomerIntegrationTests()
|
||||
{
|
||||
var server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
|
||||
_client = server.CreateClient();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CustomerGetAllTest()
|
||||
{
|
||||
//Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), "/api/Customers");
|
||||
//Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
//Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(100)]
|
||||
public void CustomerGetOneTest(int id)
|
||||
{
|
||||
//Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), $"/api/Customers/{id}");
|
||||
//Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
//Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void CustomerPostTest()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), $"/api/Customers/");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public void CustomerPutTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("PUT"), $"/api/Customers/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public void CustomerDeleteTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("DELETE"), $"/api/Customers/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
21
H_Plus_Sports.Tests/H_Plus_Sports.Tests.csproj
Normal file
21
H_Plus_Sports.Tests/H_Plus_Sports.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="MSTest.TestAdapter" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\H_PLUS_Sports\H_Plus_Sports.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
87
H_Plus_Sports.Tests/OrderIntegrationTests.cs
Normal file
87
H_Plus_Sports.Tests/OrderIntegrationTests.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace H_Plus_Sports.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class OrderIntegrationTests
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public OrderIntegrationTests()
|
||||
{
|
||||
var server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
|
||||
_client = server.CreateClient();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OrderGetAllTest()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), "/api/Orders/");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1001)]
|
||||
public void OrderGetOneTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), $"/api/Orders/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OrderPostTest()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), $"/api/Orders/");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public void OrderPutTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("PUT"), $"/api/Orders/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public void OrderDeleteTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("DELETE"), $"/api/Orders/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
87
H_Plus_Sports.Tests/OrderItemIntegrationTests.cs
Normal file
87
H_Plus_Sports.Tests/OrderItemIntegrationTests.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
namespace H_Plus_Sports.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class OrderItemIntegrationTests
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public OrderItemIntegrationTests()
|
||||
{
|
||||
var server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
|
||||
_client = server.CreateClient();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OrderItemGetAllTest()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), "/api/OrderItems/");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1001)]
|
||||
public void OrderItemGetOneTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), $"/api/OrderItems/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void OrderItemPostTest()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), $"/api/OrderItems/");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public void OrderItemPutTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("PUT"), $"/api/OrderItems/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public void OrderItemDeleteTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("DELETE"), $"/api/OrderItems/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
88
H_Plus_Sports.Tests/ProductIntegrationTests.cs
Normal file
88
H_Plus_Sports.Tests/ProductIntegrationTests.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace H_Plus_Sports.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class ProductIntegrationTests
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public ProductIntegrationTests()
|
||||
{
|
||||
var server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
|
||||
_client = server.CreateClient();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ProductGetAllTest()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), "/api/Products/");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("MWBLU32")]
|
||||
public void ProductGetOneTest(string id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), $"/api/Products/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void ProductPostTest()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), $"/api/Products/");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("MWORA32")]
|
||||
public void ProductPutTest(string id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("PUT"), $"/api/Products/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow("MWORA32")]
|
||||
public void ProductDeleteTest(string id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("DELETE"), $"/api/Products/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
88
H_Plus_Sports.Tests/SalespersonIntegrationTests.cs
Normal file
88
H_Plus_Sports.Tests/SalespersonIntegrationTests.cs
Normal file
@ -0,0 +1,88 @@
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace H_Plus_Sports.Tests
|
||||
{
|
||||
[TestClass]
|
||||
public class SalespersonIntegrationTests
|
||||
{
|
||||
private readonly HttpClient _client;
|
||||
|
||||
public SalespersonIntegrationTests()
|
||||
{
|
||||
var server = new TestServer(new WebHostBuilder().UseStartup<Startup>());
|
||||
_client = server.CreateClient();
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SalespersonGetAllTest()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), "/api/Salespersons/");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(101)]
|
||||
public void SalespersonGetOneTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("GET"), $"/api/Salespersons/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.OK, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void SalespersonPostTest()
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("POST"), $"/api/Salespersons/");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public void SalespersonPutTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("PUT"), $"/api/Salespersons/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.UnsupportedMediaType, response.StatusCode);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
[DataRow(1)]
|
||||
public void SalespersonDeleteTest(int id)
|
||||
{
|
||||
// Arrange
|
||||
var request = new HttpRequestMessage(new HttpMethod("DELETE"), $"/api/Salespersons/{id}");
|
||||
|
||||
// Act
|
||||
var response = _client.SendAsync(request).Result;
|
||||
|
||||
// Assert
|
||||
Assert.AreEqual(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user