public ICommandResult Handle(DeleteEndpointCommand command) { command.Validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Dados inválidos. Verifique o preenchimento dos campos e tente novamente.", command.Notifications)); } var endpoint = _repository.GetBySerialNumber(command.SerialNumber); if (endpoint == null) { return(new GenericCommandResult(false, "Nenhum Endpoint encontrado com esse Número Serial.", null)); } if (_repository.Delete(command.SerialNumber)) { return(new GenericCommandResult(true, "Registro excluído com sucesso.", endpoint)); } else { return(new GenericCommandResult(false, "Erro ao excluir registro.", endpoint)); } }
public void Deve_interromper_a_exclusao_quando_o_comando_for_invalido() { _deleteEndpointCommand.SerialNumber = null; _deleteEndpointCommand.Validate(); Assert.AreEqual(_deleteEndpointCommand.Invalid, true); }