59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using e_suite.API.Common.models;
|
|
using e_suite.Utilities.Pagination;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
|
|
namespace eSuite.API.UnitTests.Controllers.OrganisationControllerUnitTests;
|
|
|
|
[TestFixture]
|
|
public class GetOrganisationsUnitTests : OrganisationControllerTestBase
|
|
{
|
|
[SetUp]
|
|
public override async Task Setup()
|
|
{
|
|
await base.Setup();
|
|
}
|
|
|
|
[Test]
|
|
public async Task ShouldReturnOk()
|
|
{
|
|
//Arrange
|
|
var organisations = new List<ReadOrganisation>
|
|
{
|
|
new()
|
|
{
|
|
Id = 999,
|
|
Guid = new Guid("d6e5d3e2-d154-4e04-af93-14d2c85e2a86"),
|
|
Name = "Sun-Strategy",
|
|
},
|
|
new()
|
|
{
|
|
Id = 888,
|
|
Guid = new Guid("c8329e94-426a-4d65-84e5-93aa1cf54063"),
|
|
Name = "Amdaris",
|
|
},
|
|
};
|
|
|
|
var paginatedData = new PaginatedData<ReadOrganisation>
|
|
{
|
|
Count = organisations.Count,
|
|
Data = organisations,
|
|
Page = 1,
|
|
PageSize = 10
|
|
};
|
|
|
|
_organisationManagerMock.Setup(x => x.GetOrganisationList(It.IsAny<Paging>(), It.IsAny<CancellationToken>())).ReturnsAsync(paginatedData);
|
|
|
|
//Act
|
|
var actualResult = await _organisationController.GetOrganisationsList(new Paging(), CancellationToken.None);
|
|
|
|
//Assert
|
|
Assert.That(actualResult.GetType(), Is.EqualTo(typeof(OkObjectResult)));
|
|
var objectResult = actualResult as OkObjectResult;
|
|
|
|
Assert.That(objectResult?.StatusCode, Is.EqualTo(200));
|
|
Assert.That(objectResult?.Value, Is.Not.Null);
|
|
Assert.That(objectResult!.Value!.GetType, Is.EqualTo(typeof(PaginatedData<ReadOrganisation>)));
|
|
}
|
|
} |