Example #1
0
        public async Task Cannot_Delete_Inactive_Advice_That_Has_Not_Been_Sent_If_No_Rights()
        {
            //Arrange
            var recipient = CreateDefaultEmailRecipient(CreateWellformedEmail());
            var advice    = CreateDefaultAdvice(Scheduling.Day, AdviceType.Repeat, recipient);

            using var createResult = await AdviceHelper.PostAdviceAsync(advice, OrganizationId);

            Assert.Equal(HttpStatusCode.Created, createResult.StatusCode);
            var createdAdvice = await createResult.ReadResponseBodyAsAsync <Core.DomainModel.Advice.Advice>();

            using var deactivateResult = await AdviceHelper.DeactivateAdviceAsync(createdAdvice.Id);

            Assert.Equal(HttpStatusCode.NoContent, deactivateResult.StatusCode);

            var regularUserCookie = await HttpApi.GetCookieAsync(OrganizationRole.User);

            //Act
            using var deleteResult = await AdviceHelper.DeleteAdviceAsync(createdAdvice.Id, regularUserCookie);

            //Assert
            Assert.Equal(HttpStatusCode.Forbidden, deleteResult.StatusCode);
        }
Example #2
0
        public async Task Can_Delete_Inactive_Advice_That_Has_Not_Been_Sent()
        {
            //Arrange
            var recipient = CreateDefaultEmailRecipient(CreateWellformedEmail());
            var advice    = CreateDefaultAdvice(Scheduling.Day, AdviceType.Repeat, recipient);

            advice.AlarmDate = DateTime.Now.AddDays(2);
            advice.StopDate  = DateTime.Now.AddDays(3);

            using var createResult = await AdviceHelper.PostAdviceAsync(advice, OrganizationId);

            Assert.Equal(HttpStatusCode.Created, createResult.StatusCode);
            var createdAdvice = await createResult.ReadResponseBodyAsAsync <Core.DomainModel.Advice.Advice>();

            using var deactivateResult = await AdviceHelper.DeactivateAdviceAsync(createdAdvice.Id);

            Assert.Equal(HttpStatusCode.NoContent, deactivateResult.StatusCode);

            //Act
            using var deleteResult = await AdviceHelper.DeleteAdviceAsync(createdAdvice.Id);

            //Assert
            Assert.Equal(HttpStatusCode.NoContent, deleteResult.StatusCode);
        }