Esempio n. 1
0
        public async Task Deleting_Contract_Clears_ContractField_In_All_AssociatedRelations()
        {
            //Arrange
            var input = await PrepareFullRelationAsync(true, false, false);

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

                Assert.NotNull(relation.Contract);

                using (var deleteContractRequest = await ItContractHelper.SendDeleteContractRequestAsync(input.ContractId.GetValueOrDefault()))
                    using (var getAfterDeleteResponse = await SystemRelationHelper.SendGetRelationRequestAsync(input.FromUsageId, relation.Id))
                    {
                        //Assert
                        Assert.Equal(HttpStatusCode.OK, deleteContractRequest.StatusCode);
                        Assert.Equal(HttpStatusCode.OK, getAfterDeleteResponse.StatusCode);
                        var relationAfterChange = await getAfterDeleteResponse.ReadResponseBodyAsKitosApiResponseAsync <SystemRelationDTO>();

                        Assert.Null(relationAfterChange.Contract);
                    }
            }
        }
Esempio n. 2
0
        public async Task Delete_Contract_Removes_Associated_Advices()
        {
            // Arrange
            const int organizationId = TestEnvironment.DefaultOrganizationId;
            var       contract       = await ItContractHelper.CreateContract(A <string>(), OrganizationId);

            var advice = new Core.DomainModel.Advice.Advice
            {
                Id         = A <int>(),
                AlarmDate  = DateTime.Now,
                StopDate   = DateTime.Now.AddDays(365),
                Scheduling = Scheduling.Quarter,
                Subject    = "Can_Delete_Contract_Advices",
                RelationId = contract.Id,
                Type       = RelatedEntityType.itProject
            };

            using var createResponse = await AdviceHelper.PostAdviceAsync(advice, organizationId);

            Assert.Equal(HttpStatusCode.Created, createResponse.StatusCode);

            // Act
            using var deleteResponse = await ItContractHelper.SendDeleteContractRequestAsync(contract.Id);

            Assert.Equal(HttpStatusCode.OK, deleteResponse.StatusCode);

            // Assert
            using var advicesResponse = AdviceHelper.GetContractAdvicesAsync(contract.Id);
            var deletedContractAdvices = await advicesResponse.Result.ReadOdataListResponseBodyAsAsync <Core.DomainModel.Advice.Advice>();

            Assert.True(deletedContractAdvices.Count == 0);
        }