Пример #1
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);
        }
Пример #2
0
        private static async Task AssertAdviceCreationReturns(Core.DomainModel.Advice.Advice advice, Cookie readOnlyUserCookie, HttpStatusCode expectedResult)
        {
            using var createResultBeforeRoleAssignment = await AdviceHelper.PostAdviceAsync(advice, OrganizationId, readOnlyUserCookie);

            Assert.Equal(expectedResult, createResultBeforeRoleAssignment.StatusCode);
        }