Beispiel #1
0
        public async Task DeleteFromProjectOkStatus()
        {
            //Arrange
            var userProjects = new List <UserProject>()
            {
                new UserProject {
                    UserId = 2
                }
            };
            var project = new Project {
                ProjectId = 1, UserProjects = userProjects
            };

            ProjectController controller = new ProjectController(mapperMock.Object, wrapperMock.Object);

            wrapperMock.Setup(w => w.ProjectRepository.GetProject(1)).Returns(Task.FromResult(project));

            wrapperMock.Setup(w => w.ProjectRepository.Delete(userProjects[0])).Verifiable();

            wrapperMock.Setup(w => w.SaveAll()).Returns(Task.FromResult(true));

            //Act
            var action = await controller.DeleteFromProject(1, 1, 2) as OkResult;

            //Assert
            Assert.Equal(200, action.StatusCode);
            wrapperMock.Verify(w => w.ProjectRepository.Delete(userProjects[0]), Times.Once);
        }
Beispiel #2
0
        public async Task DeleteFromProjectNotFoundProjectStatus()
        {
            //Arrange
            ProjectController controller = new ProjectController(mapperMock.Object, wrapperMock.Object);

            wrapperMock.Setup(w => w.ProjectRepository.GetProject(It.IsAny <int>())).Returns(Task.FromResult((Project)null));

            //Act
            var action = await controller.DeleteFromProject(1, It.IsAny <int>(), It.IsAny <int>()) as NotFoundObjectResult;

            //Assert
            Assert.Equal(404, action.StatusCode);
            Assert.NotNull(action.Value);
        }
Beispiel #3
0
        public async Task DeleteFromProjectNotFoundUserStatus()
        {
            //Arrange
            var userProjects = new List <UserProject>()
            {
                new UserProject {
                    UserId = 2
                }
            };
            var project = new Project {
                ProjectId = 1, UserProjects = userProjects
            };

            ProjectController controller = new ProjectController(mapperMock.Object, wrapperMock.Object);

            wrapperMock.Setup(w => w.ProjectRepository.GetProject(1)).Returns(Task.FromResult(project));

            //Act
            var action = await controller.DeleteFromProject(1, 1, 1) as NotFoundObjectResult;

            //Assert
            Assert.Equal(404, action.StatusCode);
            Assert.NotNull(action.Value);
        }