-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: se agrega Integration Test para el controlador Fibonacci
issue: #8
- Loading branch information
1 parent
69c39d9
commit 6f1bd5a
Showing
2 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using FibonacciWebApi; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.TestHost; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace FibonacciExcercise.IntegrationTest | ||
{ | ||
// integration tests frequently involve application infrastructure concerns, such as a database, file system, | ||
// network resources, or web requests and responses | ||
//help: https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/test-aspnet-core-services-web-apps | ||
|
||
|
||
[TestClass] | ||
public class IntegracionTest | ||
{ | ||
private readonly TestServer _server; | ||
private readonly HttpClient _client; | ||
|
||
public IntegracionTest() | ||
{ | ||
// Arrange | ||
_server = new TestServer(new WebHostBuilder() | ||
.UseStartup<Startup>()); | ||
_client = _server.CreateClient(); | ||
} | ||
|
||
[TestMethod] | ||
public async Task InvocarApiCorrecta() | ||
{ | ||
// Act | ||
var response = await _client.GetAsync("/api/fibonacci/2"); | ||
|
||
//Verifico que encabezado sea Exitoso | ||
Assert.IsTrue(response.IsSuccessStatusCode, "El código de la respuesta debería ser exitoso"); | ||
|
||
|
||
// Verifico que la respuesta sea correcta | ||
var responseString = await response.Content.ReadAsAsync<int>(); | ||
Assert.AreEqual(1, responseString); | ||
} | ||
} | ||
} | ||
|
||
|