using e_suite.API.Common.exceptions; using e_suite.Database.Core.Tables.UserManager; using eSuite.Core.Miscellaneous; using NUnit.Framework; using SSOManager.UnitTests.Helpers; namespace SSOManager.UnitTests.SsoManager; [TestFixture] public class RemoveSsoProviderAsyncUnitTests : SsoManagerTestBase { [SetUp] public override async Task Setup() { await base.Setup(); } [Test] public async Task RemoveSsoProviderAsync_ActiveSsoProvider_DeactivatesSuccessfully() { //Arrange var ssoProvider = new SsoProvider { Id = 2, Guid = new Guid("48154fbc-33ce-428e-956c-87ebcc7adc83"), Name = "SsoProvider to Delete", IsPublic = true, Deleted = false, ClientId = "ClientId", ClientSecret = "ClientSecret", AuthorizationEndpoint = "AuthEndPoint", TokenEndpoint = "TokenEndpoint", ValidIssuer = "SsoProviderToDelete" }; SsoManagerRepository.SsoProviders.Add(ssoProvider); //Act await SsoManager.RemoveSsoProviderAsync(AuditUserDetails, new GeneralIdRef { Guid = ssoProvider.Guid }, CancellationToken.None); //Assert Assert.That(ssoProvider.Deleted, Is.True); } [Test] public void RemoveSsoProviderAsync_WhenSsoProviderDoesNotExist_ThrowsException() { //Arrange //Assert var result = Assert.ThrowsAsync(async () => { //Act await SsoManager.RemoveSsoProviderAsync(AuditUserDetails, new GeneralIdRef { Guid = new Guid("627b0018-6e79-403e-af67-a184f1483741") }, CancellationToken.None); }); Assert.That(result!.Message, Is.EqualTo("SsoProvider with this id does not exists")); } }