public async Task DeleteEpicAsync_FicticiousEpicId_ThrowsNotFoundException() { //arrange Guid publicProjectId = Guid.NewGuid(); Project expectedProject = new Project() { ProjectId = 1, PublicProjectId = publicProjectId, Name = "name", Description = null, DateTimeCreated = DateTime.UtcNow.AddMinutes(-60) }; var projectRepositoryMock = new Mock <IProjectRepository>(MockBehavior.Strict); projectRepositoryMock.Setup(x => x.GetProjectAsync(publicProjectId)) .ReturnsAsync(expectedProject); Guid publicEpicId = Guid.NewGuid(); Epic expectedEpic = null; var epicRepositoryMock = new Mock <IEpicRepository>(MockBehavior.Strict); epicRepositoryMock.Setup(x => x.GetEpicAsync(publicEpicId)) .ReturnsAsync(expectedEpic); epicRepositoryMock.Setup(x => x.DeleteEpicAsync(publicEpicId)) .Returns(Task.CompletedTask); var epicManager = new EpicManager(projectRepositoryMock.Object, epicRepositoryMock.Object); //act/assert _ = await Assert.ThrowsAsync <NotFoundException>(async() => { await epicManager.DeleteEpicAsync(publicProjectId, publicEpicId); }); }
public async Task DeleteEpicAsync_ValidInput_NoExceptionsThrown() { //arrange Guid publicProjectId = Guid.NewGuid(); Project expectedProject = new Project() { ProjectId = 1, PublicProjectId = publicProjectId, Name = "name", Description = null, DateTimeCreated = DateTime.UtcNow.AddMinutes(-60) }; var projectRepositoryMock = new Mock <IProjectRepository>(MockBehavior.Strict); projectRepositoryMock.Setup(x => x.GetProjectAsync(publicProjectId)) .ReturnsAsync(expectedProject); Guid publicEpicId = Guid.NewGuid(); Epic expectedEpic = new Epic() { EpicId = 1, PublicEpicId = publicEpicId, ProjectId = expectedProject.ProjectId, Project = expectedProject, Name = "name", Description = null, DateTimeCreated = DateTime.UtcNow.AddMinutes(-60) }; var epicRepositoryMock = new Mock <IEpicRepository>(MockBehavior.Strict); epicRepositoryMock.Setup(x => x.GetEpicAsync(publicEpicId)) .ReturnsAsync(expectedEpic); epicRepositoryMock.Setup(x => x.DeleteEpicAsync(publicEpicId)) .Returns(Task.CompletedTask); var epicManager = new EpicManager(projectRepositoryMock.Object, epicRepositoryMock.Object); //act await epicManager.DeleteEpicAsync(publicProjectId, publicEpicId); //assert - implicit }