Beispiel #1
0
        public async Task ChangeProjectNameOkStatus()
        {
            //Arrange
            var projectForChangeName = new ProjectForChangeName {
                Name = "newTest"
            };
            var project = new Project {
                ProjectId = 1, Name = "test"
            };

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

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

            mapperMock.Setup(m => m.Map(projectForChangeName, project)).Verifiable();

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

            //Act
            var action = await controller.ChangeProjectName(1, 1, projectForChangeName) as OkResult;

            //Assert
            Assert.Equal(200, action.StatusCode);
            mapperMock.Verify(m => m.Map(projectForChangeName, project), Times.Once());
        }
Beispiel #2
0
        public async Task ChangeProjectNameNotFoundStatus()
        {
            //Arrange
            ProjectController controller = new ProjectController(mapperMock.Object, wrapperMock.Object);

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

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

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