public void GetChapterStatisticsAsyncShouldRetrieveAssignmentsWithLastResultsOfMultipleUsersAndConvertThemToStatistics() { //Arrange var chapterId = _random.NextPositive(); var nowUtc = DateTime.UtcNow; var assignmentWithResultsOfMultipleUsers = new AssignmentWithLastResultsOfMultipleUsers(); var assignmentsWithLastResultsOfMultipleUsers = new List <AssignmentWithLastResultsOfMultipleUsers> { assignmentWithResultsOfMultipleUsers }; _testResultRepositoryMock .Setup(repo => repo.GetLastTestResultsOfChapterAsync(It.IsAny <int>(), It.IsAny <DateTime?>())) .ReturnsAsync(assignmentsWithLastResultsOfMultipleUsers); var assignmentStatisticsDto = new AssignmentStatisticsDto(); _testResultConverterMock .Setup(converter => converter.ToAssignmentStatisticsDto(It.IsAny <AssignmentWithLastResultsOfMultipleUsers>())) .Returns(assignmentStatisticsDto); //Act var results = _service.GetChapterStatisticsAsync(chapterId, nowUtc).Result; //Assert Assert.That(results, Has.Exactly(1).EqualTo(assignmentStatisticsDto)); _testResultRepositoryMock.Verify(repo => repo.GetLastTestResultsOfChapterAsync(chapterId, nowUtc), Times.Once); _testResultConverterMock.Verify(converter => converter.ToAssignmentStatisticsDto(assignmentWithResultsOfMultipleUsers), Times.Once); }