public async Task UpdateSavedProjectShouldUpdateSavedProject()
        {
            var savedProject = new SavedProject {
                Id = 1
            };

            _projectBLMock.Setup(x => x.UpdateSavedProjectAsync(It.IsAny <SavedProject>())).Returns(Task.FromResult(savedProject));
            var savedProjectController = new SavedProjectController(_projectBLMock.Object);
            var result = await savedProjectController.UpdateSavedProjectAsync(savedProject.Id, savedProject);

            Assert.IsAssignableFrom <NoContentResult>(result);
            _projectBLMock.Verify(x => x.UpdateSavedProjectAsync(savedProject));
        }
Ejemplo n.º 2
0
        public async Task UpdateSavedProjectAsync_ShouldReturnStatusCode500_WhenSavedProjectIsInvalid()
        {
            //arrange
            var          savedProjectBLMock = new Mock <IProjectBL>();
            int          id           = -1;
            SavedProject savedProject = null;

            savedProjectBLMock.Setup(i => i.UpdateSavedProjectAsync(savedProject)).Throws(new Exception());
            SavedProjectController savedProjectController = new SavedProjectController(savedProjectBLMock.Object);

            //act
            var result = await savedProjectController.UpdateSavedProjectAsync(id, savedProject);

            //assert
            Assert.IsType <StatusCodeResult>(result);
            Assert.Equal(500, ((StatusCodeResult)result).StatusCode);
        }