public async Task Delete_Should_Fail_Only_Owner_Can_Delete(string userIdRole)
        {
            // Arrange
            mockProjRepo.Setup(repo => repo.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(GetSampleProjects()[0]);
            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember("IsObserver", It.IsAny <int>())).ReturnsAsync(AppUserRole.Observer);
            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember("IsDeveloper", It.IsAny <int>())).ReturnsAsync(AppUserRole.Developer);
            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember("IsScrumMaster", It.IsAny <int>())).ReturnsAsync(AppUserRole.ScrumMaster);
            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember("IsNone", It.IsAny <int>())).ReturnsAsync(AppUserRole.None);

            var projectBL = new ProjectBl(mockProjRepo.Object, mapper, mockProjectUserRepo.Object, mockSprintRepo.Object);
            // Act
            var result = projectBL.DeleteAsync(It.IsAny <int>(), userIdRole);

            // Assert
            mockProjRepo.Verify(r => r.DeleteAsync(It.IsAny <int>()), Times.Never);
            await Assert.ThrowsAsync <ForbiddenResponseException>(() => projectBL.DeleteAsync(It.IsAny <int>(), userIdRole));
        }
        public void DeleteAsync_Should_Not_Found(int projectId)
        {         // Arrange
            string userId = It.IsAny <string>();

            mockProjRepo.Setup(repo => repo.GetByIdAsync(projectId)).ReturnsAsync(null as Project);
            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember(userId, projectId)).ReturnsAsync(AppUserRole.Owner);
            var projectBL = new ProjectBl(mockProjRepo.Object, mapper, mockProjectUserRepo.Object, mockSprintRepo.Object);
            // Act
            var result = projectBL.DeleteAsync(projectId, userId);

            // Assert
            Assert.IsType <ProjectResponse>(result.Result);
            Assert.False(result.Result.Success);
            Assert.Equal("Project not found", result.Result.Message);
        }
        public void Delete_Should_Call_Once_DeleteAsync_Into_Repository()
        {
            // Arrange
            mockProjRepo.Setup(repo => repo.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(GetSampleProjects()[0]);
            mockProjRepo.Setup(repo => repo.DeleteAsync(It.IsAny <int>()));
            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember(It.IsAny <string>(), It.IsAny <int>())).ReturnsAsync(AppUserRole.Owner);

            var projectBL = new ProjectBl(mockProjRepo.Object, mapper, mockProjectUserRepo.Object, mockSprintRepo.Object);
            // Act
            var result = projectBL.DeleteAsync(It.IsAny <int>(), It.IsAny <string>());

            // Assert
            mockProjRepo.Verify(r => r.DeleteAsync(It.IsAny <int>()), Times.Once);
            Assert.IsType <ProjectResponse>(result.Result);
            Assert.True(result.Result.Success);
        }
        public void Delete_Should_Work()
        {
            // Arrange
            var projectDto = new ProjectDto {
                Id = 1, Name = "Project for deleting", Description = "Some description for Project1"
            };
            Project project = mapper.Map <ProjectDto, Project>(projectDto);

            mockProjRepo.Setup(repo => repo.GetByIdAsync(It.IsAny <int>())).ReturnsAsync(project);
            mockProjectUserRepo.Setup(repo => repo.GetRoleOfMember(It.IsAny <string>(), It.IsAny <int>())).ReturnsAsync(AppUserRole.Owner);

            var projectBL = new ProjectBl(mockProjRepo.Object, mapper, mockProjectUserRepo.Object, mockSprintRepo.Object);
            // Act
            var result = projectBL.DeleteAsync(It.IsAny <int>(), It.IsAny <string>());

            // Assert
            Assert.IsType <ProjectResponse>(result.Result);
            Assert.True(result.Result.Success);
            Assert.Equal(projectDto.Name, result.Result.ProjectDTO.Name);
            Assert.Equal(projectDto.Description, result.Result.ProjectDTO.Description);
        }