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

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

            Assert.IsAssignableFrom <NoContentResult>(result);
            _projectBLMock.Verify(x => x.DeleteSavedProjectAsync((It.IsAny <SavedProject>())));
        }
コード例 #2
0
        public async Task DeleteSavedProjectAsync_ShouldReturnStatusCode500_WhenIdIsInvalid()
        {
            //arrange
            var          savedprojectBLMock = new Mock <IProjectBL>();
            int          id           = -4;
            SavedProject savedProject = null;

            savedprojectBLMock.Setup(i => i.DeleteSavedProjectAsync(savedProject)).Throws(new Exception());
            SavedProjectController savedProjectController = new SavedProjectController(savedprojectBLMock.Object);

            //act
            var result = await savedProjectController.DeleteSavedProjectAsync(id);

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