public async Task Can_Delete_Objects_Which_Are_Referred_By_Report() { //Arrange - a broken link in both a system and an interface PurgeBrokenExternalReferencesReportTable(); var system = await ItSystemHelper.CreateItSystemInOrganizationAsync(A <Guid>().ToString("N"), TestEnvironment.DefaultOrganizationId, AccessModifier.Public); await ReferencesHelper.CreateReferenceAsync(A <string>(), null, SystemReferenceUrl, Display.Url, r => r.ItSystem_Id = system.Id); var referenceToBeExplicitlyDeleted = await ReferencesHelper.CreateReferenceAsync(A <string>(), null, SystemReferenceUrl, Display.Url, r => r.ItSystem_Id = system.Id); var interfaceDto = await InterfaceHelper.CreateInterface(InterfaceHelper.CreateInterfaceDto(A <string>(), A <string>(), TestEnvironment.DefaultOrganizationId, AccessModifier.Public)); interfaceDto = await InterfaceHelper.SetUrlAsync(interfaceDto.Id, InterfaceUrl); await BrokenExternalReferencesReportHelper.TriggerRequestAsync(); var dto = await WaitForReportGenerationCompletedAsync(); Assert.True(dto.Available); //Act using (var deleteReferenceResponse = await ReferencesHelper.DeleteReferenceAsync(referenceToBeExplicitlyDeleted.Id)) using (var deleteItSystemResponse = await ItSystemHelper.DeleteItSystemAsync(system.Id, TestEnvironment.DefaultOrganizationId)) using (var deleteInterfaceResponse = await InterfaceHelper.SendDeleteInterfaceRequestAsync(interfaceDto.Id)) { Assert.Equal(HttpStatusCode.OK, deleteReferenceResponse.StatusCode); Assert.Equal(HttpStatusCode.OK, deleteItSystemResponse.StatusCode); Assert.Equal(HttpStatusCode.OK, deleteInterfaceResponse.StatusCode); } }
public async Task Cannot_Delete_System_With_Interface_Exhibits(OrganizationRole role) { //Arrange var login = await HttpApi.GetCookieAsync(role); const int organizationId = TestEnvironment.DefaultOrganizationId; var system = await ItSystemHelper.CreateItSystemInOrganizationAsync(A <string>(), organizationId, AccessModifier.Public); var itInterfaceDto = InterfaceHelper.CreateInterfaceDto( A <string>(), A <string>(), organizationId, AccessModifier.Public); var itInterface = await InterfaceHelper.CreateInterface(itInterfaceDto); await InterfaceExhibitHelper.CreateExhibit(system.Id, itInterface.Id); //Act using (var result = await ItSystemHelper.DeleteItSystemAsync(system.Id, organizationId, login)) { //Assert await AssertCorrectConflictResponseAsync(SystemDeleteConflict.HasInterfaceExhibits, result, system.Id); } }
public async Task Cannot_Delete_System(OrganizationRole role) { //Arrange var login = await HttpApi.GetCookieAsync(role); const int organizationId = TestEnvironment.DefaultOrganizationId; var system = await ItSystemHelper.CreateItSystemInOrganizationAsync(A <string>(), organizationId, AccessModifier.Public); //Act using (var result = await ItSystemHelper.DeleteItSystemAsync(system.Id, organizationId, login)) { //Assert Assert.Equal(HttpStatusCode.Forbidden, result.StatusCode); await AssertSystemNotDeletedAsync(system.Id); } }
public async Task Cannot_Delete_System_In_Use(OrganizationRole role) { //Arrange var login = await HttpApi.GetCookieAsync(role); const int organizationId = TestEnvironment.DefaultOrganizationId; var system = await ItSystemHelper.CreateItSystemInOrganizationAsync(A <string>(), organizationId, AccessModifier.Public); await ItSystemHelper.TakeIntoUseAsync(system.Id, organizationId); //Act using (var result = await ItSystemHelper.DeleteItSystemAsync(system.Id, organizationId, login)) { //Assert await AssertCorrectConflictResponseAsync(SystemDeleteConflict.InUse, result, system.Id); } }
public async Task Can_Delete_System_With_Task_Ref(OrganizationRole role) { //Arrange var login = await HttpApi.GetCookieAsync(role); const int organizationId = TestEnvironment.DefaultOrganizationId; const int taskRefId = TestEnvironment.DefaultTaskRefId; var system = await ItSystemHelper.CreateItSystemInOrganizationAsync(A <string>(), organizationId, AccessModifier.Public); await ItSystemHelper.SendSetTaskRefOnSystemRequestAsync(system.Id, taskRefId, organizationId, login); //Act using (var result = await ItSystemHelper.DeleteItSystemAsync(system.Id, organizationId, login)) { //Assert Assert.Equal(HttpStatusCode.OK, result.StatusCode); await AssertSystemDeletedAsync(system.Id); } }
public async Task Cannot_Delete_System_With_Child_Systems(OrganizationRole role) { //Arrange var login = await HttpApi.GetCookieAsync(role); const int organizationId = TestEnvironment.DefaultOrganizationId; var mainSystem = await ItSystemHelper.CreateItSystemInOrganizationAsync(A <string>(), organizationId, AccessModifier.Public); var childSystem = await ItSystemHelper.CreateItSystemInOrganizationAsync(A <string>(), organizationId, AccessModifier.Public); await ItSystemHelper.SendSetParentSystemRequestAsync(childSystem.Id, mainSystem.Id, organizationId, login); //Act using (var result = await ItSystemHelper.DeleteItSystemAsync(mainSystem.Id, organizationId, login)) { //Assert await AssertCorrectConflictResponseAsync(SystemDeleteConflict.HasChildren, result, mainSystem.Id); } }