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); }
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); }
private void AssertAreEqual(Section expected, QuizEngine.Services.SectionService.Contract.Section actual) { Assert.AreEqual(expected.ID, actual.ID); Assert.AreEqual(expected.Name, actual.Name); }