public async Task UpdateAsyncWhenIdIsCorrectReturnsStudyMaterialInstance() { // 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)); mockStudyMaterialRepository.Setup(r => r.Update(studyMaterial)); var service = new StudyMaterialService(mockStudyMaterialRepository.Object, mockUnitOfWork.Object); // Act StudyMaterialResponse result = await service.UpdateAsync(StudyMaterialId, studyMaterial); var resource = result.Resource; // Assert resource.Should().Equals(studyMaterial); }
public async Task DeleteAsyncWhenInvalidIdReturnsStudyMaterialNotFoundResponse() { // 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>(null)); mockStudyMaterialRepository.Setup(r => r.Remove(studyMaterial)); var service = new StudyMaterialService(mockStudyMaterialRepository.Object, mockUnitOfWork.Object); // Act StudyMaterialResponse result = await service.DeleteAsync(StudyMaterialId); var message = result.Message; // Assert message.Should().Be("Study material not found"); }
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"); }