public async Task GetAsyncTestUnhappy() { // Arrange var mockFacultyRepository = GetDefaultIFacultyRepositoryInstance(); var mockUniversityRepository = GetDefaultIUniversityRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); int facultyId = 1; var service = new FacultyService(mockFacultyRepository.Object, mockUniversityRepository.Object, mockUnitOfWork.Object); // Act FacultyResponse result = await service.GetByIdAsync(facultyId); var message = result.Message; // Assert message.Should().Be("Faculty not found"); }
public async Task GetAsyncTestHappy() { // Arrange var mockFacultyRepository = GetDefaultIFacultyRepositoryInstance(); var mockUniversityRepository = GetDefaultIUniversityRepositoryInstance(); var mockUnitOfWork = GetDefaultIUnitOfWorkInstance(); Faculty faculty = new Faculty(); int facultyId = 1; faculty.Id = facultyId; mockFacultyRepository.Setup(r => r.FindById(facultyId)) .Returns(Task.FromResult <Faculty>(faculty)); var service = new FacultyService(mockFacultyRepository.Object, mockUniversityRepository.Object, mockUnitOfWork.Object); // Act FacultyResponse result = await service.GetByIdAsync(facultyId); // Assert Assert.AreEqual(faculty, result.Resource); }