public async void DeleteWorkTest( Status expectedStatus ) { var developer = EntitiesFactory.NewDeveloper().Save(); var project = EntitiesFactory.NewProject(developerIds: new[] { developer.Id }).Save(); var work = EntitiesFactory.NewWork(Guid.NewGuid(), project.DeveloperProjects.Single().Id).Get(); _workRepository.Setup(d => d.ExistAsync(work.Id)) .ReturnsAsync(expectedStatus != Status.NotFund); _workRepository.Setup(d => d.GetByIdAsync(work.Id)) .ReturnsAsync(work); _mockyRepository.Setup(m => m.SendNotificationAsync(It.IsAny <string>(), It.IsAny <string>())) .ReturnsAsync(new Result <bool>(expectedStatus != Status.Error)); var service = new WorkService( _workRepository.Object, _developerRepository.Object, _projectRepository.Object, _mockyRepository.Object ); var result = await service.DeleteWorkAsync(work.Id); Assert.Equal(expectedStatus, result.Status); if (expectedStatus == Status.Success) { _workRepository.Verify(d => d.DeleteAsync(work), Times.Once); _mockyRepository.Verify(d => d.SendNotificationAsync(It.IsAny <string>(), It.IsAny <string>()), Times.Once); } }