public async Task GetAllOrderedByAsync_ExpectAscendingOrder_And_IncludeCourses()
        {
            //Arrange
            await SetUpData();

            var firstUserName = User + "9";
            var lastUserName  = User + "1";

            //Act
            var courses = await CourseQueryRepository.GetAllAsync();

            var allUsers = await UserQueryRepository.GetAllAsync();

            for (var i = 0; i < courses.Count; i++)
            {
                courses[i].UserId = allUsers[i].Id;
            }

            await CourseCommandRepository.UpdateListAsync(courses);

            var teachers = await this.UserQueryRepository.GetAllOrderedByAsync(user => user.FirstName, Sort.Asc, user => user.Courses);

            //Assert
            Assert.Equal(firstUserName, teachers.First().FirstName);
            Assert.Equal(1, teachers.First().Courses.Count);
            Assert.Equal(lastUserName, teachers.Last().FirstName);
            Assert.Equal(1, teachers.Last().Courses.Count);
        }
        public async Task GetFilteredtWithPagingAndOrderAsync_And_IncludeCourses_PageSizeIsNegative_ExpectArgumentException()
        {
            //Arrange
            await SetUpData();

            //Act
            var courses = await CourseQueryRepository.GetAllAsync();

            var allUsers = await UserQueryRepository.GetAllAsync();

            for (var i = 0; i < courses.Count; i++)
            {
                courses[i].UserId = allUsers[i].Id;
            }

            await CourseCommandRepository.UpdateListAsync(courses);

            //Assert
            await Assert.ThrowsAsync <ArgumentException>(() => this.UserQueryRepository.GetFilteredtWithPagingAndOrderAsync(t => t.FirstName.Contains(User), t => t.FirstName, 0, -1, Sort.Asc, t => t.Courses));
        }
        public async Task GetAllAsync_AllUser_Expect20_And_IncludeCourse()
        {
            //Arrange
            await SetUpData();

            var courses = await CourseQueryRepository.GetAllAsync();

            var allUsers = await UserQueryRepository.GetAllAsync();

            for (var i = 0; i < courses.Count; i++)
            {
                courses[i].UserId = allUsers[i].Id;
            }

            await CourseCommandRepository.UpdateListAsync(courses);

            //Act
            var result = await this.UserQueryRepository.GetAllAsync(t => t.Courses);

            //Assert
            Assert.Equal(20, result.Count);
            Assert.Equal(1, result.First().Courses.Count);
        }
        public async Task GetFilteredtWithPagingAndOrderAsync_ExpectAscendingOrder_And_IncludeCourses()
        {
            //Arrange
            await SetUpData();

            var siteOneFirstUserName = User + "9";
            var SiteOneLastUserName  = User + "5";
            var siteTwoFirstUserName = User + "4";
            var SiteTwoLastUserName  = User + "19";

            //Act
            var courses = await CourseQueryRepository.GetAllAsync();

            var allUsers = await UserQueryRepository.GetAllAsync();

            for (var i = 0; i < courses.Count; i++)
            {
                courses[i].UserId = allUsers[i].Id;
            }

            await CourseCommandRepository.UpdateListAsync(courses);

            var teacherSite1 = await this.UserQueryRepository.GetFilteredtWithPagingAndOrderAsync(t => t.FirstName.Contains(User), t => t.FirstName, 0, 5, Sort.Asc, t => t.Courses);

            var teacherSite2 = await this.UserQueryRepository.GetFilteredtWithPagingAndOrderAsync(t => t.FirstName.Contains(User), t => t.FirstName, 1, 5, Sort.Asc, t => t.Courses);

            //Assert
            Assert.Equal(5, teacherSite1.Count);
            Assert.Equal(siteOneFirstUserName, teacherSite1.First().FirstName);
            Assert.Equal(SiteOneLastUserName, teacherSite1.Last().FirstName);
            Assert.Equal(1, teacherSite1.Last().Courses.Count);

            Assert.Equal(5, teacherSite2.Count);
            Assert.Equal(siteTwoFirstUserName, teacherSite2.First().FirstName);
            Assert.Equal(SiteTwoLastUserName, teacherSite2.Last().FirstName);
            Assert.Equal(1, teacherSite2.Last().Courses.Count);
        }