public async Task GetAsyncTestUnhappy() { // Arrange var mockCoordinatorRepository = GetDefaultICoordinatorRepositoryInstance(); var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance(); var mockFacultyRepository = GetDefaultIFacultyRepositoryInstance(); var mockAccountRepository = GetDefaultIAccountRepositoryInstance(); int coordinatorId = 1; var service = new CoordinatorService(mockCoordinatorRepository.Object, mockAccountRepository.Object, mockFacultyRepository.Object, mockIUnitOfWork.Object); // Act CoordinatorResponse result = await service.GetByIdAsync(coordinatorId); var message = result.Message; // Assert message.Should().Be("Coordinator not found"); }
public async Task GetAsyncTestHappy() { // Arrange var mockCoordinatorRepository = GetDefaultICoordinatorRepositoryInstance(); var mockIUnitOfWork = GetDefaultIUnitOfWorkInstance(); var mockFacultyRepository = GetDefaultIFacultyRepositoryInstance(); var mockAccountRepository = GetDefaultIAccountRepositoryInstance(); Coordinator coordinator = new Coordinator(); int coordinatorId = 1; coordinator.Id = coordinatorId; mockCoordinatorRepository.Setup(r => r.FindById(coordinatorId)) .Returns(Task.FromResult <Coordinator>(coordinator)); var service = new CoordinatorService(mockCoordinatorRepository.Object, mockAccountRepository.Object, mockFacultyRepository.Object, mockIUnitOfWork.Object); // Act CoordinatorResponse result = await service.GetByIdAsync(coordinatorId); // Assert Assert.AreEqual(coordinator, result.Resource); }