示例#1
0
        public async Task GetCourseGroups()
        {
            var ownerId = Guid.NewGuid().ToString();
            var group1  = await groupsRepo.CreateGroupAsync("CourseId1", "Group1", ownerId).ConfigureAwait(false);

            var group2 = await groupsRepo.CreateGroupAsync("CourseId1", "Group2", ownerId).ConfigureAwait(false);

            var group3 = await groupsRepo.CreateGroupAsync("CourseId2", "Group3", ownerId).ConfigureAwait(false);

            var group4 = await groupsRepo.CreateGroupAsync("CourseId2", "Group4", ownerId).ConfigureAwait(false);

            var group5 = await groupsRepo.CreateGroupAsync("CourseId1", "Group5", ownerId).ConfigureAwait(false);

            var course1Groups = await groupsRepo.GetCourseGroupsAsync("CourseId1").ConfigureAwait(false);

            CollectionAssert.AreEqual(new List <Group> {
                group1, group2, group5
            }, course1Groups);

            await groupsRepo.ArchiveGroupAsync(group5.Id, isArchived : true).ConfigureAwait(false);

            var nonArchivedGroups = await groupsRepo.GetCourseGroupsAsync("CourseId1").ConfigureAwait(false);

            CollectionAssert.AreEqual(new List <Group> {
                group1, group2
            }, nonArchivedGroups);

            var allGroupsIncludeArchived = await groupsRepo.GetCourseGroupsAsync("CourseId1", includeArchived : true).ConfigureAwait(false);

            CollectionAssert.AreEqual(new List <Group> {
                group1, group2, group5
            }, allGroupsIncludeArchived);
        }