-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into eduardoworrel-feature-setup-adapter-structure
- Loading branch information
Showing
8 changed files
with
238 additions
and
7 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
10 changes: 10 additions & 0 deletions
10
Apps/Core.BocaSuja/Domain/Interfaces/IContentSafetyService.cs
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,10 @@ | ||
using Core.BocaSuja.Domain.Entities; | ||
|
||
namespace Core.BocaSuja.Domain.Interfaces; | ||
|
||
public interface IContentSafetyService | ||
{ | ||
public Task<bool> Validate(Guid id, string text); | ||
public Task<List<Incidencia>> Rank(); | ||
public Task<List<Incidencia>> Rank(Guid id); | ||
} |
22 changes: 22 additions & 0 deletions
22
Apps/Core.BocaSuja/Domain/Services/AzureContentSafetyService.cs
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,22 @@ | ||
using Core.BocaSuja.Domain.Entities; | ||
using Core.BocaSuja.Domain.Interfaces; | ||
|
||
namespace Core.BocaSuja.Domain.Services; | ||
|
||
public class AzureContentSafetyService : IContentSafetyService | ||
{ | ||
public Task<List<Incidencia>> Rank() | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<List<Incidencia>> Rank(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public Task<bool> Validate(Guid id, string text) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} |
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
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,90 @@ | ||
using Microsoft.AspNetCore.Mvc.Testing; | ||
using System.Net; | ||
|
||
namespace Tests.IntegrationTests.Web.Api.BocaSuja; | ||
|
||
[TestFixture] | ||
public class IntegrationTests | ||
{ | ||
private WebApplicationFactory<Program> _factory; | ||
private HttpClient _client; | ||
|
||
[OneTimeSetUp] | ||
public void Setup() | ||
{ | ||
_factory = new WebApplicationFactory<Program>(); | ||
_client = _factory.CreateClient(); | ||
} | ||
|
||
[OneTimeTearDown] | ||
public void TearDown() | ||
{ | ||
_client.Dispose(); | ||
_factory.Dispose(); | ||
} | ||
|
||
[Test, Category("WebApi - Routing - Health")] | ||
[Description("Verifica endpoint de health")] | ||
public async Task HealthEndpoint_ShouldReturnOk() | ||
{ | ||
var endpoint = "/health"; | ||
|
||
var response = await _client.GetAsync(endpoint); | ||
|
||
var content = await response.Content.ReadAsStringAsync(); | ||
Assert.That(content, Is.EqualTo("OK")); | ||
} | ||
|
||
[Test, Category("WebApi - Routing - Validate")] | ||
[Description("Verifica endpoint de validação")] | ||
public async Task ValidateEndpoint_WithValidIdAndText_ShouldReturnOk() | ||
{ | ||
var textExample = "Example Text"; | ||
var endpoint = "/api/v1/validate?id=" + Guid.NewGuid() + "&text=" + textExample; | ||
|
||
var response = await _client.GetAsync(endpoint); | ||
|
||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotImplemented)); | ||
} | ||
|
||
[Test, Category("WebApi - Routing - Validate")] | ||
[TestCase("")] | ||
[TestCase("texto teste")] | ||
[Description("Verifica endpoint de validação caso falte algum parametro")] | ||
public async Task ValidateEndpoint_WithMissingText_ShouldReturnBadRequest(string text) | ||
{ | ||
var endpoint = $"/api/v1/validate?"; | ||
|
||
if (string.IsNullOrEmpty(text)) | ||
endpoint += "id=" + Guid.NewGuid(); | ||
else | ||
endpoint += "text=" + text; | ||
|
||
var response = await _client.GetAsync(endpoint); | ||
|
||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); | ||
} | ||
|
||
[Test, Category("WebApi - Routing - Rank")] | ||
[Description("Verifica endpoint de rank sem guid")] | ||
public async Task RankEndpoint_ShouldReturnOk() | ||
{ | ||
var endpoint = "/api/v1/rank"; | ||
|
||
var response = await _client.GetAsync(endpoint); | ||
|
||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotImplemented)); | ||
} | ||
|
||
[Test, Category("WebApi - Routing - Rank")] | ||
[Description("Verifica endpoint de rank com guid")] | ||
public async Task RankByIdEndpoint_WithValidId_ShouldReturnOk() | ||
{ | ||
var id = Guid.NewGuid(); | ||
var endpoint = $"/api/v1/rank/{id}"; | ||
|
||
var response = await _client.GetAsync(endpoint); | ||
|
||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotImplemented)); | ||
} | ||
} |
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
48 changes: 48 additions & 0 deletions
48
Tests/UnitTests/Core.BocaSuja/Domain/Services/AzureContentSafetyServiceTest.cs
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,48 @@ | ||
using Core.BocaSuja.Domain.Interfaces; | ||
using Core.BocaSuja.Domain.Services; | ||
|
||
namespace Tests.UnitTests.Core.BocaSuja.Domain.Services; | ||
|
||
[TestFixture] | ||
public class AzureContentSafetyServiceTest | ||
{ | ||
private AzureContentSafetyService _contentSafetyService; | ||
|
||
[SetUp] | ||
public void SetUp() | ||
{ | ||
_contentSafetyService = new AzureContentSafetyService(); | ||
} | ||
|
||
[Test, Category("Core - Domain - Services - AzureContentSafetyService")] | ||
[Description("Não implementado")] | ||
public void Rank_ThrowsNotImplementedException() | ||
{ | ||
async Task action() => await _contentSafetyService.Rank(); | ||
|
||
Assert.ThrowsAsync<NotImplementedException>(action); | ||
} | ||
|
||
[Test, Category("Core - Domain - Services - AzureContentSafetyService")] | ||
[Description("Não implementado")] | ||
public void Rank_WithId_ThrowsNotImplementedException() | ||
{ | ||
var id = Guid.NewGuid(); | ||
|
||
async Task action() => await _contentSafetyService.Rank(id); | ||
|
||
Assert.ThrowsAsync<NotImplementedException>(action); | ||
} | ||
|
||
[Test, Category("Core - Domain - Services - AzureContentSafetyService")] | ||
[Description("Não implementado")] | ||
public void Validate_ThrowsNotImplementedException() | ||
{ | ||
var id = Guid.NewGuid(); | ||
var text = "Test text"; | ||
|
||
async Task action() => await _contentSafetyService.Validate(id, text); | ||
|
||
Assert.ThrowsAsync<NotImplementedException>(action); | ||
} | ||
} |