public void GetExamByIdFetchingCourse_ShouldThrowExamNotFoundException() { // Arrange Guid mockGuid = new Guid(); var expectedExams = new List <Domain.Entities.Exam> { _exam }; var mockExamsQueryable = expectedExams.AsQueryable().BuildMock(); _mockReadRepository.Setup(repo => repo.GetAll <Domain.Entities.Exam>()).Throws(new ExamNotFoundException(mockGuid)); // Act Func <Task> act = async() => await _examService.GetByIdFetchingCourse(mockGuid); // Assert act.Should().Throw <ExamNotFoundException>(); }