Example #1
0
        public async Task Api_User_Can_Get_It_System_ParentId(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);

            var token = await HttpApi.GetTokenAsync(role);

            var url = TestEnvironment.CreateUrl($"api/itsystem/{childSystem.Id}?hierarchy=true");

            //Act
            using (var httpResponse = await HttpApi.GetWithTokenAsync(url, token.Token))
            {
                //Assert
                var response = await httpResponse.ReadResponseBodyAsKitosApiResponseAsync <IEnumerable <ItSystemDTO> >();

                Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
                var itSystemDtos = response.ToList();
                Assert.NotEmpty(itSystemDtos);
                Assert.Equal(mainSystem.Id, itSystemDtos.First(x => x.Id == childSystem.Id).ParentId);
            }
        }
Example #2
0
        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);
            }
        }