public async Task DeleteSectionAsync_WhenSectionExists_ThenReturnsNoError() { 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)); sectionRepositoryMock.Setup(x => x.Delete(section)); unitOfWorkMock.Setup(x => x.SaveAsync()).Returns(() => Task.CompletedTask); ValidationError[] errors = await sectionService.DeleteSectionAsync(section.ID); Assert.AreEqual(0, errors.Length); }
public async Task <IActionResult> DeleteConfirmed(string sectionName) { await SectionService.DeleteSectionAsync(ClassroomName, sectionName); return(RedirectToAction("Index")); }