public async Task GetByIdAsyncWhenInvalidIdReturnsCareersNotFoundResponse() { //Arrange var mockCareerRepository = GetDefaultICareerRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstace(); var careerId = 1; Career career = new Career(); mockCareerRepository.Setup(r => r.FindById(careerId)).Returns(Task.FromResult <Career>(null)); var service = new CareerService(mockCareerRepository.Object, mockUnitOfWork.Object); //Act CareerResponse result = await service.GetByIdAsync(careerId); var message = result.Message; //Assert message.Should().Be("Career not found"); }
public async Task GetAsyncTestHappy() { // Arrange var mockCareerRepository = GetDefaultICareerRepositoryInstance(); var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance(); var mockFacultyRepository = GetDefaultIFacultyRepositoryInstance(); var careerId = 1; Career career = new Career(); mockCareerRepository.Setup(r => r.FindById(careerId)) .Returns(Task.FromResult <Career>(career)); var service = new CareerService(mockCareerRepository.Object, mockFacultyRepository.Object, mockIUnitOfWork.Object); // Act CareerResponse result = await service.GetByIdAsync(careerId); // Assert Assert.AreEqual(career, result.Resource); }
public async Task GetAsyncTestUnhappy() { // Arrange var mockCareerRepository = GetDefaultICareerRepositoryInstance(); var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance(); var mockFacultyRepository = GetDefaultIFacultyRepositoryInstance(); Career career = new Career(); var careerId = 1; career.Id = careerId; var service = new CareerService(mockCareerRepository.Object, mockFacultyRepository.Object, mockIUnitOfWork.Object); // Act CareerResponse result = await service.GetByIdAsync(careerId); var message = result.Message; // Assert Assert.AreEqual(null, result.Resource); message.Should().Be("Career not found"); }