Пример #1
0
        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);
            }
        }
Пример #2
0
        public async Task Can_Set_Exposing_System(OrganizationRole role)
        {
            //Arrange
            var login = await HttpApi.GetCookieAsync(role);

            const int organizationId = TestEnvironment.DefaultOrganizationId;
            var       interfaceDto   = await InterfaceHelper.CreateInterface(InterfaceHelper.CreateInterfaceDto(A <string>(), A <string>(), organizationId, AccessModifier.Public));

            var system = await ItSystemHelper.CreateItSystemInOrganizationAsync(A <string>(), organizationId, AccessModifier.Public);

            //Act - perform the action with the actual role
            var result = await InterfaceExhibitHelper.CreateExhibit(system.Id, interfaceDto.Id, login);

            //Assert
            Assert.Equal(interfaceDto.Id, result.ItInterfaceId);
            Assert.Equal(system.Id, result.ItSystemId);
        }
Пример #3
0
        public async Task BelongsTo_Is_Same_As_Exhibit_System()
        {
            //Arrange
            const int organizationId = TestEnvironment.DefaultOrganizationId;
            var       interfaceDto   = await InterfaceHelper.CreateInterface(InterfaceHelper.CreateInterfaceDto(A <string>(), A <string>(), organizationId, AccessModifier.Public));

            var system = await ItSystemHelper.CreateItSystemInOrganizationAsync(A <string>(), organizationId, AccessModifier.Public);

            //Act - perform the action with the actual role
            await InterfaceExhibitHelper.CreateExhibit(system.Id, interfaceDto.Id);

            //Assert
            var interfaceResult = await InterfaceHelper.GetInterfaceById(interfaceDto.Id);

            var systemResult = await ItSystemHelper.GetSystemAsync(system.Id);

            Assert.Equal(systemResult.BelongsToName, interfaceResult.BelongsToName);
        }
Пример #4
0
        private async Task <CreateSystemRelationDTO> PrepareFullRelationAsync(bool withContract, bool withFrequency, bool withInterface)
        {
            var system1 = await ItSystemHelper.CreateItSystemInOrganizationAsync(CreateName(), OrganizationId, AccessModifier.Public);

            var system2 = await ItSystemHelper.CreateItSystemInOrganizationAsync(CreateName(), OrganizationId, AccessModifier.Public);

            var usage1 = await ItSystemHelper.TakeIntoUseAsync(system1.Id, OrganizationId);

            var usage2 = await ItSystemHelper.TakeIntoUseAsync(system2.Id, OrganizationId);

            var targetInterface = Maybe <ItInterfaceDTO> .None;

            if (withInterface)
            {
                targetInterface = await InterfaceHelper.CreateInterface(InterfaceHelper.CreateInterfaceDto(CreateName(), CreateName(), OrganizationId, AccessModifier.Public));

                await InterfaceExhibitHelper.CreateExhibit(system2.Id, targetInterface.Value.Id);
            }

            var contract = withContract ? await ItContractHelper.CreateContract(CreateName(), OrganizationId) : Maybe <ItContractDTO> .None;

            var targetFrequencyTypeId = withFrequency ? DatabaseAccess.MapFromEntitySet <RelationFrequencyType, int>(repo =>
            {
                var first = repo
                            .AsQueryable()
                            .First(x => x.IsEnabled);
                return(first.Id);
            }) : default(int?);

            var input = new CreateSystemRelationDTO
            {
                FromUsageId     = usage1.Id,
                ToUsageId       = usage2.Id,
                ContractId      = contract.Select <int?>(x => x.Id).GetValueOrDefault(),
                InterfaceId     = targetInterface.Select <int?>(x => x.Id).GetValueOrDefault(),
                Description     = A <string>(),
                Reference       = A <string>(),
                FrequencyTypeId = targetFrequencyTypeId
            };

            return(input);
        }
Пример #5
0
 private static async Task <ItInterfaceExhibitDTO> CreateExhibitAsync(ItInterfaceDTO exposedInterface, ItSystemDTO exposingSystem)
 {
     return(await InterfaceExhibitHelper.CreateExhibit(exposingSystem.Id, exposedInterface.Id));
 }