예제 #1
0
        public async Task GetSectionAsync_WhenSectionDoesNotExist_ThenReturnNull()
        {
            Section section = new Section {
                ID = Guid.NewGuid(), Name = "Test Name"
            };

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

            sectionRepositoryMock.Setup(x => x.GetByIDAsync(section.ID)).Returns(Task.FromResult((Section)null));

            QuizEngine.Services.SectionService.Contract.Section returnedSection = await sectionService.GetSectionAsync(section.ID);

            Assert.IsNull(returnedSection);
        }
예제 #2
0
        public async Task GetSectionAsync_WhenSectionExists_ThenReturnExistingSection()
        {
            Section section = new Section {
                ID = Guid.NewGuid(), Name = "Test Section"
            };

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

            sectionRepositoryMock.Setup(x => x.GetByIDAsync(section.ID)).Returns(Task.FromResult(section));

            QuizEngine.Services.SectionService.Contract.Section newSection = await sectionService.GetSectionAsync(section.ID);

            AssertAreEqual(section, newSection);
        }
예제 #3
0
 private void AssertAreEqual(Section expected, QuizEngine.Services.SectionService.Contract.Section actual)
 {
     Assert.AreEqual(expected.ID, actual.ID);
     Assert.AreEqual(expected.Name, actual.Name);
 }