public async Task GetByIdAsyncWheIdIsCorrectReturnsStudyMaterialInstance() { // Arrange var mockUnitOfWork = GetDefaultUnitOfWorkRepositoryInstance(); var mockStudyMaterialRepository = GetDefaultStudyMaterialRepositoryInstance(); var StudyMaterialId = 1; var StudyMaterial = new StudyMaterial() { Id = 1, Title = "string", Description = "string", TopicId = 1 }; mockStudyMaterialRepository.Setup(r => r.FindById(StudyMaterialId)).Returns(Task.FromResult(StudyMaterial)); var service = new StudyMaterialService(mockStudyMaterialRepository.Object, mockUnitOfWork.Object); // Act StudyMaterialResponse result = await service.GetByIdAsync(StudyMaterialId); var resource = result.Resource; // Assert resource.Should().Equals(StudyMaterial); }
public async Task GetByIdAsyncWhenInvalidIdReturnsStudyMaterialNotFoundResponse() { // Arrange var mockUnitOfWork = GetDefaultUnitOfWorkRepositoryInstance(); var mockStudyMaterialRepository = GetDefaultStudyMaterialRepositoryInstance(); var StudyMaterialId = 1; mockStudyMaterialRepository.Setup(r => r.FindById(StudyMaterialId)).Returns(Task.FromResult <StudyMaterial>(null)); var service = new StudyMaterialService(mockStudyMaterialRepository.Object, mockUnitOfWork.Object); // Act StudyMaterialResponse result = await service.GetByIdAsync(StudyMaterialId); var message = result.Message; // Assert message.Should().Be("Study material not found"); }