73 lines
2.4 KiB
C#
73 lines
2.4 KiB
C#
using e_suite.API.Common.exceptions;
|
|
using e_suite.API.Common.models;
|
|
using e_suite.Database.Core.Models;
|
|
using e_suite.Database.Core.Tables.Printer;
|
|
using e_suite.Modules.OrganisationManager.UnitTests.Helpers;
|
|
using eSuite.Core.Miscellaneous;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
|
|
namespace e_suite.Modules.OrganisationManager.UnitTests;
|
|
|
|
[TestFixture]
|
|
public class EditOrganisationUnitTests : OrganisationManagerTestBase
|
|
{
|
|
[SetUp]
|
|
public override async Task Setup()
|
|
{
|
|
await base.Setup();
|
|
}
|
|
|
|
[Test]
|
|
public async Task ShouldEditOrganisation()
|
|
{
|
|
// Arrange
|
|
var organisation = new Organisation
|
|
{
|
|
Id = 999,
|
|
Guid = Guid.NewGuid(),
|
|
Name = "Sun Strategy",
|
|
Address = "Bristol, United Kindom",
|
|
Status = OrganisationStatus.Active,
|
|
Deleted = false,
|
|
};
|
|
|
|
FakeOrganisationManagerRepository.Organisations.Add(organisation);
|
|
|
|
var editedOrganisation = new EditOrganisation
|
|
{
|
|
GeneralIdRef = new GeneralIdRef { Id = 999, Guid = organisation.Guid },
|
|
Name = "Sun Solutions",
|
|
Address = "London, United Kingdom",
|
|
Status = OrganisationStatus.Pending,
|
|
};
|
|
|
|
// Act
|
|
await OrganisationManager.EditOrganisation(AuditUserDetails, editedOrganisation, true, default);
|
|
var result = await OrganisationManager.GetOrganisation(new GeneralIdRef { Id = 999, Guid = organisation.Guid }, default);
|
|
|
|
// Assert
|
|
Assert.That(result, Is.Not.Null);
|
|
Assert.That(result.Name, Is.EqualTo(editedOrganisation.Name));
|
|
Assert.That(result.Address, Is.EqualTo(editedOrganisation.Address));
|
|
Assert.That(result.Status, Is.EqualTo(editedOrganisation.Status));
|
|
EFlowSyncMessageSenderMock.Verify(x => x.SyncEFlowPrinterCategories(), Times.Once);
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldThrowException_GlossaryNotFound()
|
|
{
|
|
// Arrange
|
|
var editedOrganisation = new EditOrganisation
|
|
{
|
|
GeneralIdRef = new GeneralIdRef { Id = 999, Guid = Guid.NewGuid() },
|
|
Name = "Sun Solutions",
|
|
Address = "London, United Kingdom",
|
|
Status = OrganisationStatus.Pending,
|
|
};
|
|
|
|
// Act
|
|
// Assert
|
|
Assert.ThrowsAsync<NotFoundException>(async () => { await OrganisationManager.EditOrganisation(AuditUserDetails, editedOrganisation, true, default); });
|
|
}
|
|
} |