2023-09-22 10:52:17 -05:00
|
|
|
using DamageAssesment.Api.DocuLinks.Controllers;
|
|
|
|
using DamageAssesment.Api.DocuLinks.Interfaces;
|
|
|
|
using DamageAssesment.Api.DocuLinks.Models;
|
2023-08-31 18:00:51 -05:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Moq;
|
|
|
|
using Xunit;
|
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
namespace DamageAssesment.Api.DocuLinks.Test
|
2023-08-31 18:00:51 -05:00
|
|
|
{
|
|
|
|
|
|
|
|
public class DocumentServiceTest
|
|
|
|
{
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Get Documents - NoContent Case")]
|
|
|
|
public async Task GetDocumentsLanguageAsync_ShouldReturnStatusCode204()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
2023-10-24 11:15:13 -05:00
|
|
|
var mockResponse = await MockData.getNoContentResponse();
|
2023-09-22 10:52:17 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetdocumentsByLinkAsync("forms","en",null)).ReturnsAsync(mockResponse);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (NoContentResult)await DocumentProvider.GetDocumentsAsync("", "", null);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(204, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
[Fact(DisplayName = "Get active Documents - NoContent Case")]
|
2023-08-31 18:00:51 -05:00
|
|
|
public async Task GetDocumentsLinkTypeAsync_ShouldReturnStatusCode204()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
2023-10-24 11:15:13 -05:00
|
|
|
var mockResponse = await MockData.getNoContentResponse();
|
2023-09-22 10:52:17 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetdocumentsByLinkAsync("forms", "en", true)).ReturnsAsync(mockResponse);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (NoContentResult)await DocumentProvider.GetDocumentsByActiveAsync("", "");
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(204, result.StatusCode);
|
|
|
|
}
|
|
|
|
[Fact(DisplayName = "Get Documents - Ok case")]
|
|
|
|
public async Task GetDocumentsAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
2023-10-09 19:38:35 -05:00
|
|
|
var mockResponse = await MockData.getOkResponses();
|
2023-10-19 14:59:02 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetdocumentsByLinkAsync("forms", "en", null)).ReturnsAsync(mockResponse);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-10-19 14:59:02 -05:00
|
|
|
var result = (OkObjectResult)await DocumentProvider.GetDocumentsAsync("forms", "en", null);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(200, result.StatusCode);
|
|
|
|
}
|
2023-09-22 10:52:17 -05:00
|
|
|
[Fact(DisplayName = "Get active Documents - Ok case")]
|
|
|
|
public async Task GetActiveDocumentsAsync_ShouldReturnStatusCode200()
|
2023-08-31 18:00:51 -05:00
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
2023-10-09 19:38:35 -05:00
|
|
|
var mockResponse = await MockData.getOkResponses();
|
2023-09-22 10:52:17 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetdocumentsByLinkAsync("forms", "en", true)).ReturnsAsync(mockResponse);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (OkObjectResult)await DocumentProvider.GetDocumentsByActiveAsync("forms", "en");
|
2023-08-31 18:00:51 -05:00
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
Assert.Equal(200, result.StatusCode);
|
2023-08-31 18:00:51 -05:00
|
|
|
}
|
|
|
|
|
2023-10-09 19:38:35 -05:00
|
|
|
[Fact(DisplayName = "Get active Documents by linktypeid - Ok case")]
|
|
|
|
public async Task GetActiveDocumentsLinkTypeIdAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await MockData.getOkResponses();
|
|
|
|
mockDocumentService.Setup(service => service.GetdocumentsByLinkTypeIdAsync(null, "en", true)).ReturnsAsync(mockResponse);
|
|
|
|
|
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (OkObjectResult)await DocumentProvider.GetDocumentsByActiveLinkTypeIdAsync(null, "en");
|
|
|
|
|
|
|
|
Assert.Equal(200, result.StatusCode);
|
|
|
|
}
|
|
|
|
[Fact(DisplayName = "Get active Documents by linktypeid - NoContent Case")]
|
|
|
|
public async Task GetDocumentsLinkTypeIdAsync_ShouldReturnStatusCode204()
|
|
|
|
{
|
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
2023-10-24 11:15:13 -05:00
|
|
|
var mockResponse = await MockData.getNoContentResponse();
|
2023-10-09 19:38:35 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetdocumentsByLinkTypeIdAsync(null, "en", true)).ReturnsAsync(mockResponse);
|
|
|
|
|
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (NoContentResult)await DocumentProvider.GetDocumentsByActiveLinkTypeIdAsync(null, "");
|
|
|
|
|
|
|
|
Assert.Equal(204, result.StatusCode);
|
|
|
|
}
|
2023-08-31 18:00:51 -05:00
|
|
|
[Fact(DisplayName = "Get Document by Id - Ok case")]
|
|
|
|
public async Task GetDocumentAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await MockData.getOkResponse(1);
|
2023-10-19 14:59:02 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetDocumentAsync(1, "forms", "en")).ReturnsAsync(mockResponse);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-09-13 15:49:59 -05:00
|
|
|
var result = (OkObjectResult)await DocumentProvider.GetDocumentAsync(1, "forms", "en");
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(200, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Get Document by Id - NotFound case")]
|
|
|
|
public async Task GetDocumentAsync_ShouldReturnStatusCode404()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await MockData.getNotFoundResponse();
|
2023-09-13 15:49:59 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetDocumentAsync(99, "forms", "en")).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-09-13 15:49:59 -05:00
|
|
|
var result = (NotFoundResult)await DocumentProvider.GetDocumentAsync(99, "forms", "en");
|
2023-08-31 18:00:51 -05:00
|
|
|
Assert.Equal(404, result.StatusCode);
|
|
|
|
}
|
|
|
|
[Fact(DisplayName = "Post Document - Ok case")]
|
|
|
|
public async Task PostDocumentAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await MockData.getOkResponse(1);
|
|
|
|
var mockInputDocument = await MockData.getInputDocumentData();
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentResponse = await MockData.GetDocuLinksInfo(0);
|
2023-08-31 18:00:51 -05:00
|
|
|
mockDocumentService.Setup(service => service.PostDocumentAsync(mockInputDocument)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-08-31 18:00:51 -05:00
|
|
|
var result = (NoContentResult)await DocumentProvider.CreateDocument(DocumentResponse);
|
|
|
|
|
|
|
|
Assert.Equal(204, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Post Document - BadRequest case")]
|
|
|
|
public async Task PostDocumentAsync_ShouldReturnStatusCode400()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockInputDocument = await MockData.getInputDocumentData();
|
|
|
|
var mockResponse = await MockData.getBadRequestResponse();
|
2023-09-22 10:52:17 -05:00
|
|
|
ReqDoculink documentInfo = null;
|
2023-08-31 18:00:51 -05:00
|
|
|
mockDocumentService.Setup(service => service.PostDocumentAsync(mockInputDocument)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-08-31 18:00:51 -05:00
|
|
|
var result = (BadRequestObjectResult)await DocumentProvider.CreateDocument(documentInfo);
|
|
|
|
|
|
|
|
Assert.Equal(400, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Put Document - Ok case")]
|
|
|
|
public async Task PutDocumentAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await MockData.getOkResponse(1);
|
|
|
|
var mockInputDocument = await MockData.getInputDocumentData();
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentResponse = await MockData.GetDocuLinksInfo(1);
|
2023-10-19 14:59:02 -05:00
|
|
|
mockDocumentService.Setup(service => service.UpdateDocumentAsync(1, mockInputDocument)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-10-19 14:59:02 -05:00
|
|
|
var result = (NotFoundResult)await DocumentProvider.UpdateDocument(1, DocumentResponse);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
2023-09-11 12:23:50 -05:00
|
|
|
Assert.Equal(404, result.StatusCode);
|
2023-08-31 18:00:51 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Put Document - BadRequest case")]
|
|
|
|
public async Task PutDocumentAsync_ShouldReturnStatusCode400()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await MockData.getBadRequestResponse();
|
|
|
|
var mockInputDocument = await MockData.getInputDocumentData();
|
2023-10-19 14:59:02 -05:00
|
|
|
mockDocumentService.Setup(service => service.UpdateDocumentAsync(99, mockInputDocument)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-10-19 14:59:02 -05:00
|
|
|
var result = (BadRequestObjectResult)await DocumentProvider.UpdateDocument(99, null);
|
2023-08-31 18:00:51 -05:00
|
|
|
Assert.Equal(400, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Delete Document - Ok case")]
|
|
|
|
public async Task DeleteDocumentAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await MockData.getOkResponse(1);
|
|
|
|
mockDocumentService.Setup(service => service.DeleteDocumentAsync(1)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-08-31 18:00:51 -05:00
|
|
|
var result = (OkObjectResult)await DocumentProvider.DeleteDocument(1);
|
|
|
|
|
|
|
|
Assert.Equal(200, result.StatusCode);
|
|
|
|
}
|
|
|
|
[Fact(DisplayName = "Delete Document - NotFound case")]
|
|
|
|
public async Task DeleteDocumentAsync_ShouldReturnStatusCode404()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await MockData.getNotFoundResponse();
|
|
|
|
mockDocumentService.Setup(service => service.DeleteDocumentAsync(1)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-08-31 18:00:51 -05:00
|
|
|
var result = (NotFoundResult)await DocumentProvider.DeleteDocument(1);
|
|
|
|
Assert.Equal(404, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Link Type Test cases
|
|
|
|
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Get Link types - Ok case")]
|
|
|
|
public async Task GetDocumentCategoriesAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getOkResponse();
|
2023-09-22 10:52:17 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetLinkTypesAsync("en")).ReturnsAsync(mockResponse);
|
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (OkObjectResult)await DocumentProvider.GetLinkTypesAsync("en");
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(200, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Get Link types - NoContent Case")]
|
|
|
|
public async Task GetDocumentCategoriesAsync_ShouldReturnStatusCode204()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getNoContentResponse();
|
2023-09-22 10:52:17 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetLinkTypesAsync("en")).ReturnsAsync(mockResponse);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (NoContentResult)await DocumentProvider.GetLinkTypesAsync("en");
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(204, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Get Link Type by Id - Ok case")]
|
|
|
|
public async Task GetDocumentcategoryAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getOkResponse(1);
|
2023-10-19 14:59:02 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetLinkTypeAsync(1, "en")).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (OkObjectResult)await DocumentProvider.GetLinkTypeAsync(1, "en");
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(200, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Get Link Type by Id - NotFound case")]
|
|
|
|
public async Task GetDocumentcategoryAsync_ShouldReturnStatusCode404()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getNotFoundResponse();
|
2023-09-22 10:52:17 -05:00
|
|
|
mockDocumentService.Setup(service => service.GetLinkTypeAsync(99, "en")).ReturnsAsync(mockResponse);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (NotFoundResult)await DocumentProvider.GetLinkTypeAsync(99, "en");
|
2023-08-31 18:00:51 -05:00
|
|
|
Assert.Equal(404, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Post Link Type - Ok case")]
|
|
|
|
public async Task PostDocumentcategoryAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getOkResponse(1);
|
|
|
|
var mockInputDocument = await LinkTypeMockData.getInputLinkData(0);
|
|
|
|
mockDocumentService.Setup(service => service.PostLinkTypeAsync(mockInputDocument)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-08-31 18:00:51 -05:00
|
|
|
var result = (OkObjectResult)await DocumentProvider.CreateLinkType(mockInputDocument);
|
|
|
|
|
|
|
|
Assert.Equal(200, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Post Link Type - BadRequest case")]
|
|
|
|
public async Task PostDocumentcategoryAsync_ShouldReturnStatusCode400()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockInputDocument = await LinkTypeMockData.getInputLinkData(99);
|
|
|
|
var mockResponse = await LinkTypeMockData.getBadRequestResponse();
|
|
|
|
mockDocumentService.Setup(service => service.PostLinkTypeAsync(mockInputDocument)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-08-31 18:00:51 -05:00
|
|
|
var result = (BadRequestObjectResult)await DocumentProvider.CreateLinkType(mockInputDocument);
|
|
|
|
|
|
|
|
Assert.Equal(400, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Put Document - Ok case")]
|
|
|
|
public async Task PutDocumentcategoryAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getOkResponse(1);
|
|
|
|
var mockInputDocument = await LinkTypeMockData.getInputLinkData(1);
|
2023-10-19 14:59:02 -05:00
|
|
|
mockDocumentService.Setup(service => service.UpdateLinkTypeAsync(1, mockInputDocument)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-10-19 14:59:02 -05:00
|
|
|
var result = (OkObjectResult)await DocumentProvider.UpdateLinkType(1, mockInputDocument);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(200, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Put Document - NotFound case")]
|
|
|
|
public async Task PutDocumentcategoryAsync_ShouldReturnStatusCode404()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getNotFoundResponse();
|
|
|
|
var mockInputDocument = await LinkTypeMockData.getInputLinkData(99);
|
2023-10-19 14:59:02 -05:00
|
|
|
mockDocumentService.Setup(service => service.UpdateLinkTypeAsync(99, mockInputDocument)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-10-19 14:59:02 -05:00
|
|
|
var result = (NotFoundObjectResult)await DocumentProvider.UpdateLinkType(99, mockInputDocument);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(404, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Put Document - BadRequest case")]
|
|
|
|
public async Task PutDocumentcategoryAsync_ShouldReturnStatusCode400()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getBadRequestResponse();
|
|
|
|
var mockInputDocument = await LinkTypeMockData.getInputLinkData(1);
|
2023-10-19 14:59:02 -05:00
|
|
|
mockDocumentService.Setup(service => service.UpdateLinkTypeAsync(1, mockInputDocument)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
|
|
|
var result = (BadRequestObjectResult)await DocumentProvider.UpdateLinkType(1, mockInputDocument);
|
2023-08-31 18:00:51 -05:00
|
|
|
|
|
|
|
Assert.Equal(400, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Fact(DisplayName = "Delete Document - Ok case")]
|
|
|
|
public async Task DeleteDocumentcategoryAsync_ShouldReturnStatusCode200()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getOkResponse(1);
|
|
|
|
|
|
|
|
mockDocumentService.Setup(service => service.DeleteLinkTypeAsync(1)).ReturnsAsync(mockResponse);
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-08-31 18:00:51 -05:00
|
|
|
var result = (OkObjectResult)await DocumentProvider.DeleteLinkType(1);
|
|
|
|
|
|
|
|
Assert.Equal(200, result.StatusCode);
|
|
|
|
}
|
|
|
|
[Fact(DisplayName = "Delete Document - NotFound case")]
|
|
|
|
public async Task DeleteDocumentcategoryAsync_ShouldReturnStatusCode404()
|
|
|
|
{
|
2023-09-22 10:52:17 -05:00
|
|
|
var mockDocumentService = new Mock<IDoculinkProvider>();
|
2023-08-31 18:00:51 -05:00
|
|
|
var mockUploadService = new Mock<IUploadService>();
|
|
|
|
var mockResponse = await LinkTypeMockData.getNotFoundResponse();
|
|
|
|
mockDocumentService.Setup(service => service.DeleteLinkTypeAsync(1)).ReturnsAsync(mockResponse);
|
|
|
|
|
2023-09-22 10:52:17 -05:00
|
|
|
var DocumentProvider = new DoculinkController(mockDocumentService.Object, mockUploadService.Object);
|
2023-08-31 18:00:51 -05:00
|
|
|
var result = (NotFoundResult)await DocumentProvider.DeleteLinkType(99);
|
|
|
|
|
|
|
|
Assert.Equal(404, result.StatusCode);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|