Example #1
0
        public async Task GetAllSectionsAsync_WhenSectionsExists_ThenReturnListOfSections()
        {
            Section[] sectionsList = new Section[]
            {
                new Section {
                    ID = Guid.NewGuid(), Name = "Section 1"
                },
                new Section {
                    ID = Guid.NewGuid(), Name = "Section 2"
                },
                new Section {
                    ID = Guid.NewGuid(), Name = "Section 3"
                }
            };

            unitOfWorkMock.Setup(x => x.SectionRepository).Returns(sectionRepositoryMock.Object);

            sectionRepositoryMock.Setup(x => x.ListAsync()).Returns(Task.FromResult(sectionsList));

            QuizEngine.Services.SectionService.Contract.Section[] sections = await sectionService.GetAllSectionsAsync();

            AssertAreEqual(sectionsList[0], sections[0]);
            AssertAreEqual(sectionsList[1], sections[1]);
            AssertAreEqual(sectionsList[2], sections[2]);
        }