public async Task Create_ShouldReturnInstanceOfCourseDetailsDto()
        {
            // Arrange
            _mockCourseService.Setup(service => service.GetCourseById(_examCreatingDto.CourseId)).ReturnsAsync(CourseTestUtils.GetCourse());
            _mockExamMapper.Setup(mapper => mapper.Map(_examCreatingDto, CourseTestUtils.GetCourse())).Returns(_exam);
            _mockWriteRepository.Setup(repo => repo.AddNewAsync <Domain.Entities.Exam>(_exam)).Returns(() => Task.FromResult(_exam));
            _mockExamMapper.Setup(mapper => mapper.Map(_exam)).Returns(_examDto);
            var expectedStudents = new List <Student> {
                StudentTestUtils.GetStudent()
            };
            var expectedExams = new List <Domain.Entities.Exam> {
                _exam
            };

            _mockReadRepository.Setup(repo => repo.GetAll <Student>()).Returns(expectedStudents.AsQueryable().BuildMock());
            _mockReadRepository.Setup(repo => repo.GetAll <Domain.Entities.Exam>()).Returns(expectedExams.AsQueryable().BuildMock());
            IGenericEmail email = null;

            _mockEmailService.Setup(service => service.SendEmail(email)).Verifiable();

            var classroomAllocation = new List <ClassroomAllocationCreatingDto> {
            };

            _mockClassroomAllocationMapper.Setup(mapper => mapper.Map(_examCreatingDto, _exam.Id)).Returns(classroomAllocation);

            // Act
            ExamDto actualExam = await this._examService.Create(_examCreatingDto);

            // Assert
            actualExam.Should().BeEquivalentTo(_examDto);
        }
        public async Task GetExamById_ShouldReturnExamDtoWithGivenId()
        {
            //Act
            var response = await client.GetAsync("api/exams/" + exam.Id);

            //Assert
            response.EnsureSuccessStatusCode();
            var responseString = await response.Content.ReadAsStringAsync();

            ExamDto examDtoReturned = JsonConvert.DeserializeObject <ExamDto>(responseString);

            examDtoReturned.Should().BeEquivalentTo(examDto);
        }
        public async Task GetById_ShouldReturnInstanceOfExamDto()
        {
            // Arrange
            var expectedExams = new List <Domain.Entities.Exam> {
                _exam
            };
            var mockExamsQueryable = expectedExams.AsQueryable().BuildMock();

            _mockReadRepository.Setup(repo => repo.GetAll <Domain.Entities.Exam>()).Returns(mockExamsQueryable);
            _mockExamMapper.Setup(mapper => mapper.Map(_exam)).Returns(_examDto);
            // Act
            ExamDto actualExam = await this._examService.GetDtoById(_exam.Id);

            // Assert
            actualExam.Should().BeEquivalentTo(_examDto);
        }
        public async Task PostExam_ShouldReturnExamDtoFromGivenBody()
        {
            //Arrange
            var contents = new StringContent(JsonConvert.SerializeObject(examCreatingDto), Encoding.UTF8,
                                             "application/json");

            //Act
            var response = await client.PostAsync("api/exams", contents);

            //Assert
            response.EnsureSuccessStatusCode();
            var responseString = await response.Content.ReadAsStringAsync();

            ExamDto examDtoReturned = JsonConvert.DeserializeObject <ExamDto>(responseString);

            examDtoReturned.Should().BeEquivalentTo(examCreatingDto, options =>
                                                    options.ExcludingMissingMembers());
        }