92 lines
2.9 KiB
C#
92 lines
2.9 KiB
C#
using e_suite.API.Common.exceptions;
|
|
using e_suite.Database.Core.Extensions;
|
|
using e_suite.Database.Core.Models;
|
|
using e_suite.Database.Core.Tables.Printer;
|
|
using e_suite.Modules.OrganisationManager.UnitTests.Helpers;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
|
|
namespace e_suite.Modules.OrganisationManager.UnitTests;
|
|
|
|
[TestFixture]
|
|
public class DeleteOrganisationUnitTests : OrganisationManagerTestBase
|
|
{
|
|
[SetUp]
|
|
public override async Task Setup()
|
|
{
|
|
await base.Setup();
|
|
}
|
|
|
|
[Test]
|
|
public async Task ShouldDeleteOrganisationHierarcy()
|
|
{
|
|
// Arrange
|
|
var organisation = new Organisation
|
|
{
|
|
Id = 999,
|
|
Guid = new Guid("7305c943-0552-492b-a31a-5f458eba04d7"),
|
|
Name = "Sun Strategy",
|
|
Address = "London, United Kindom",
|
|
Status = OrganisationStatus.Active,
|
|
Deleted = false,
|
|
};
|
|
|
|
var site = new Site
|
|
{
|
|
Id = 888,
|
|
Guid = new Guid("907e808f-b099-47b3-8f0b-7a9e236d2206"),
|
|
Name = "Sun Strategy Printing 1",
|
|
Address = "Bristol, UK",
|
|
Status = OrganisationStatus.Active,
|
|
Deleted = false,
|
|
OrganisationId = organisation.Id
|
|
};
|
|
|
|
var specification = new Specification
|
|
{
|
|
Id = 777,
|
|
Guid = new Guid("ca5fd7ae-53a8-45e4-91ce-6c10243ea027"),
|
|
Name = "Litho printing",
|
|
Deleted = false,
|
|
SiteId = site.Id
|
|
};
|
|
|
|
FakeOrganisationManagerRepository.Organisations.Add(organisation);
|
|
FakeOrganisationManagerRepository.Sites.Add(site);
|
|
FakeOrganisationManagerRepository.Specifications.Add(specification);
|
|
|
|
// Act
|
|
await OrganisationManager.DeleteOrganisation(AuditUserDetails, organisation.ToGeneralIdRef()!, true, default);
|
|
|
|
// Assert
|
|
Assert.Multiple(() =>
|
|
{
|
|
Assert.That(FakeOrganisationManagerRepository.Organisations[0].Deleted, Is.True);
|
|
Assert.That(FakeOrganisationManagerRepository.Sites[0].Deleted, Is.True);
|
|
Assert.That(FakeOrganisationManagerRepository.Specifications[0].Deleted, Is.True);
|
|
EFlowSyncMessageSenderMock.Verify(x => x.SyncEFlowPrinterCategories(), Times.Once);
|
|
});
|
|
}
|
|
|
|
[Test]
|
|
public void ShouldThrowException_GlossaryNotFound()
|
|
{
|
|
// Arrange
|
|
var organisation = new Organisation
|
|
{
|
|
Id = 999,
|
|
Guid = new Guid("bc9ec2c0-b988-4d38-980b-b7fbea878d62"),
|
|
Name = "Sun Strategy",
|
|
Address = "London, United Kindom",
|
|
Status = OrganisationStatus.Active,
|
|
Deleted = false,
|
|
};
|
|
|
|
// Assert
|
|
Assert.ThrowsAsync<NotFoundException>(async () =>
|
|
{
|
|
// Act
|
|
await OrganisationManager.DeleteOrganisation(AuditUserDetails, organisation.ToGeneralIdRef()!, true, default);
|
|
});
|
|
}
|
|
} |