Exemplo n.º 1
0
        public async Task Can_Edit_SystemUsageWithRelations_Resets_Interface()
        {
            //Arrange
            var input = await PrepareFullRelationAsync(true, true, true);

            await SystemRelationHelper.SendPostRelationRequestAsync(input);

            var relations = await SystemRelationHelper.GetRelationsFromAsync(input.FromUsageId);

            var relationToEdit = relations.Single();
            var edited         = PrepareEditedRelation(relationToEdit, relationToEdit.ToUsage, relationToEdit.Contract, relationToEdit.FrequencyType, null);

            //Act
            using (var response = await SystemRelationHelper.SendPatchRelationRequestAsync(edited))
            {
                //Assert
                Assert.Equal(HttpStatusCode.OK, response.StatusCode);
                var relationDTO = await response.ReadResponseBodyAsKitosApiResponseAsync <SystemRelationDTO>();

                Assert.Equal(input.FromUsageId, relationDTO.FromUsage.Id);
                Assert.Equal(edited.ToUsage.Id, relationDTO.ToUsage.Id);
                Assert.Equal(edited.Description, relationDTO.Description);
                Assert.Equal(edited.Reference, relationDTO.Reference);
                Assert.NotNull(relationDTO.FrequencyType);
                Assert.NotNull(relationDTO.Contract);
                Assert.Null(relationDTO.Interface);
            }
        }
Exemplo n.º 2
0
        public async Task Can_Delete_SystemUsageWithRelations()
        {
            //Arrange
            var input = await PrepareFullRelationAsync(false, false, false);

            using (await SystemRelationHelper.SendPostRelationRequestAsync(input))
                using (var deletionResponse = await ItSystemHelper.SendRemoveUsageAsync(input.FromUsageId, OrganizationId))
                    using (var getAfterDeleteResponse = await SystemRelationHelper.SendGetRelationRequestAsync(input.FromUsageId, OrganizationId))
                    {
                        Assert.Equal(HttpStatusCode.OK, deletionResponse.StatusCode);
                        Assert.Equal(HttpStatusCode.NotFound, getAfterDeleteResponse.StatusCode);
                    }
        }
Exemplo n.º 3
0
        public async Task Can_Get_SystemRelations_AssociatedWithContract()
        {
            //Arrange
            var input = await PrepareFullRelationAsync(true, false, false);

            //Act
            using (var response = await SystemRelationHelper.SendPostRelationRequestAsync(input))
            {
                //Assert
                Assert.Equal(HttpStatusCode.Created, response.StatusCode);
                var relationsToContract          = (await SystemRelationHelper.GetRelationsAssociatedWithContractAsync(input.ContractId.GetValueOrDefault(-1))).ToList();
                var originalRelations            = (await SystemRelationHelper.GetRelationsFromAsync(input.FromUsageId)).ToList();
                var relationFromContractResponse = Assert.Single(relationsToContract);
                var relationFromOriginalResponse = Assert.Single(originalRelations);

                relationFromContractResponse.ToExpectedObject().ShouldMatch(relationFromOriginalResponse); //Same relation should yield same data at the dto level
            }
        }
Exemplo n.º 4
0
        public async Task Deleting_ToSystemUsage_Removes_Relation()
        {
            //Arrange
            var input = await PrepareFullRelationAsync(false, false, false);

            //Act
            using (var response = await SystemRelationHelper.SendPostRelationRequestAsync(input))
            {
                Assert.Equal(HttpStatusCode.Created, response.StatusCode);
                var relation = await response.ReadResponseBodyAsKitosApiResponseAsync <SystemRelationDTO>();

                using (var deleteUsageResponse = await ItSystemHelper.SendRemoveUsageAsync(input.ToUsageId, TestEnvironment.DefaultOrganizationId))
                {
                    //Assert
                    Assert.Equal(HttpStatusCode.OK, deleteUsageResponse.StatusCode);
                    var relations = (await SystemRelationHelper.GetRelationsFromAsync(input.FromUsageId)).ToList();
                    Assert.Empty(relations.Where(x => x.Id == relation.Id));
                }
            }
        }
Exemplo n.º 5
0
        private static async Task <SystemRelationDTO> CreateSystemRelation(
            int fromSystemId,
            int toSystemId,
            string description,
            int?interfaceId,
            int?frequencyTypeId,
            int?contractId)
        {
            var relationDTO = new CreateSystemRelationDTO()
            {
                FromUsageId     = fromSystemId,
                ToUsageId       = toSystemId,
                Description     = description,
                InterfaceId     = interfaceId,
                FrequencyTypeId = frequencyTypeId,
                ContractId      = contractId
            };
            var response = await SystemRelationHelper.SendPostRelationRequestAsync(relationDTO);

            Assert.Equal(HttpStatusCode.Created, response.StatusCode);
            return(await response.ReadResponseBodyAsKitosApiResponseAsync <SystemRelationDTO>());
        }