public async void Delete_ErrorsOccurred_ShouldReturnErrorResponse() { var mock = new ServiceMockFacade <ICallService, ICallRepository>(); var model = new ApiCallServerRequestModel(); var validatorMock = new Mock <IApiCallServerRequestModelValidator>(); validatorMock.Setup(x => x.ValidateDeleteAsync(It.IsAny <int>())).Returns(Task.FromResult(new FluentValidation.Results.ValidationResult(new List <ValidationFailure>() { new ValidationFailure("text", "test") }))); var service = new CallService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, validatorMock.Object, mock.DALMapperMockFactory.DALCallMapperMock, mock.DALMapperMockFactory.DALCallAssignmentMapperMock, mock.DALMapperMockFactory.DALNoteMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeFalse(); validatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <CallDeletedNotification>(), It.IsAny <CancellationToken>()), Times.Never()); }
private void btnRemove_Click(object sender, EventArgs e) { if (_service.Delete(Convert.ToInt32(dgvTaskList.SelectedRows[0].Cells[0].Value))) { dgvTaskList.Rows.Remove(dgvTaskList.SelectedRows[0]); } }
public async void Delete_NoErrorsOccurred_ShouldReturnResponse() { var mock = new ServiceMockFacade <ICallService, ICallRepository>(); var model = new ApiCallServerRequestModel(); mock.RepositoryMock.Setup(x => x.Delete(It.IsAny <int>())).Returns(Task.CompletedTask); var service = new CallService(mock.LoggerMock.Object, mock.MediatorMock.Object, mock.RepositoryMock.Object, mock.ModelValidatorMockFactory.CallModelValidatorMock.Object, mock.DALMapperMockFactory.DALCallMapperMock, mock.DALMapperMockFactory.DALCallAssignmentMapperMock, mock.DALMapperMockFactory.DALNoteMapperMock); ActionResponse response = await service.Delete(default(int)); response.Should().NotBeNull(); response.Success.Should().BeTrue(); mock.RepositoryMock.Verify(x => x.Delete(It.IsAny <int>())); mock.ModelValidatorMockFactory.CallModelValidatorMock.Verify(x => x.ValidateDeleteAsync(It.IsAny <int>())); mock.MediatorMock.Verify(x => x.Publish(It.IsAny <CallDeletedNotification>(), It.IsAny <CancellationToken>())); }