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

            _projectBLMock.Setup(x => x.GetSavedProjectByIDAsync(It.IsAny <int>())).Returns(Task.FromResult(savedProject));
            var savedProjectController = new SavedProjectController(_projectBLMock.Object);
            var result = await savedProjectController.GetSavedProjectByIDAsync(savedProjectId);

            Assert.Equal(savedProjectId, ((SavedProject)((OkObjectResult)result).Value).Id);
            _projectBLMock.Verify(x => x.GetSavedProjectByIDAsync(savedProjectId));
        }
Ejemplo n.º 2
0
        public async Task GetSavedProjectByIDAsync_ShouldReturnNotFound_WhenIDIsInvalid()
        {
            //arrange
            var          savedProjectBLMock = new Mock <IProjectBL>();
            int          id           = -41;
            SavedProject savedProject = null;

            savedProjectBLMock.Setup(i => i.GetSavedProjectByIDAsync(id)).ReturnsAsync(savedProject);
            SavedProjectController savedProjectController = new SavedProjectController(savedProjectBLMock.Object);

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

            //assert
            Assert.IsType <NotFoundResult>(result);
        }