public void testError_CcTruncatedOld() { GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_CcTruncatedOld.patch"); Assert.AreEqual(1, p.getFiles().Count); Assert.AreEqual(3, p.getErrors().Count); { FormatError e = p.getErrors()[0]; Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity()); Assert.AreEqual( "Truncated hunk, at least 1 lines is missing for ancestor 1", e.getMessage()); Assert.AreEqual(346, e.getOffset()); Assert.IsTrue(e.getLineText().StartsWith( "@@@ -55,12 -163,13 +163,15 @@@ public ")); } { FormatError e = p.getErrors()[1]; Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity()); Assert.AreEqual( "Truncated hunk, at least 2 lines is missing for ancestor 2", e.getMessage()); Assert.AreEqual(346, e.getOffset()); Assert.IsTrue(e.getLineText().StartsWith( "@@@ -55,12 -163,13 +163,15 @@@ public ")); } { FormatError e = p.getErrors()[2]; Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity()); Assert.AreEqual("Truncated hunk, at least 3 new lines is missing", e .getMessage()); Assert.AreEqual(346, e.getOffset()); Assert.IsTrue(e.getLineText().StartsWith( "@@@ -55,12 -163,13 +163,15 @@@ public ")); } }
private static bool TryGetFormatErrors( string key, ResourceManagerExt.CulturesAndKeys culturesAndKeys, IEnumerable <CultureInfo> cultures, out FormatError formatErrors) { int?count = null; var translations = culturesAndKeys.GetTranslationsFor(key, cultures); foreach (var translation in translations) { if (!FormatString.IsValidFormat(translation.Value, out var indexCount, out _)) { formatErrors = new FormatError(key, translations); return(true); } if (count == null) { count = indexCount; continue; } if (count != indexCount) { formatErrors = new FormatError(key, translations); return(true); } } formatErrors = null; return(false); }
public void testError_GitBinaryNoForwardHunk() { GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_GitBinaryNoForwardHunk.patch"); Assert.AreEqual(2, p.getFiles().Count); FileHeader fh0 = p.getFiles()[0]; Assert.AreEqual("org.spearce.egit.ui/icons/toolbar/fetchd.png", fh0.NewName); Assert.AreEqual(FileHeader.PatchTypeEnum.GIT_BINARY, fh0.getPatchType()); Assert.IsTrue(fh0.Hunks.isEmpty()); Assert.IsNull(fh0.getForwardBinaryHunk()); FileHeader fh1 = p.getFiles()[1]; Assert.AreEqual("org.spearce.egit.ui/icons/toolbar/fetche.png", fh1.NewName); Assert.AreEqual(FileHeader.PatchTypeEnum.UNIFIED, fh1.getPatchType()); Assert.IsTrue(fh1.Hunks.isEmpty()); Assert.IsNull(fh1.getForwardBinaryHunk()); Assert.AreEqual(1, p.getErrors().Count); FormatError e = p.getErrors()[0]; Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity()); Assert.AreEqual("Missing forward-image in GIT binary patch", e.getMessage()); Assert.AreEqual(297, e.getOffset()); Assert.AreEqual("\n", e.getLineText()); }
private static bool TryGetFormatErrors(string key, IReadOnlyDictionary <CultureInfo, string> translations, out FormatError formatErrors) { int?count = null; foreach (var translation in translations.Values) { int indexCount; bool?anyItemHasFormat; if (!FormatString.IsValidFormat(translation, out indexCount, out anyItemHasFormat)) { formatErrors = new FormatError(key, translations); return(true); } if (count == null) { count = indexCount; continue; } if (count != indexCount) { formatErrors = new FormatError(key, translations); return(true); } } formatErrors = null; return(false); }
public void FixedString32AtMaximumSizeWorks(String a, FormatError expectedError) { FixedString32 aa = default; aa.Junk(); var error = aa.Append(a); Assert.AreEqual(expectedError, error); aa.AssertNullTerminated(); }
private void OnError(string error) { OnCircuitError?.Invoke(error); var exception = FormatError?.Invoke(error) ?? new Exception(error); NextBatchReceived?.Completion?.TrySetException(exception); NextDotNetInteropCompletionReceived?.Completion.TrySetException(exception); NextJSInteropReceived?.Completion.TrySetException(exception); NextErrorReceived?.Completion?.TrySetResult(null); }
public List <FileFormattingError> Validate() { List <FileFormattingError> fileFormatErrorList = new List <FileFormattingError>(); if (!string.IsNullOrEmpty(this.TextData)) { List <string> questionList = paperParser.GetQuestionList(); for (int i = 0; i <= questionList.Count - 1; i++) { logger.AppendLog("Question - " + (i + 1)); if (!(questionList[i].Equals("\n") || questionList[i].Equals(string.Empty))) { List <string> formatErrorList = new List <string>(); FormatError formatError = ValidateOptionStartTag(questionList[i]); if (formatError != FormatError.None) { formatErrorList.Add(formatError.ToString()); } formatError = ValidateOptionEnd(questionList[i]); if (formatError != FormatError.None) { formatErrorList.Add(formatError.ToString()); } formatError = ValidateQuestionAttributes(questionList[i]); if (formatError != FormatError.None) { formatErrorList.Add(formatError.ToString()); } if (formatErrorList.Count > 0) { fileFormatErrorList.Add(new FileFormattingError(i, formatErrorList)); } else { logger.AppendLog("Correct format"); } logger.AppendLog(string.Empty); } } } else { throw new Exception("Empty file."); } return(fileFormatErrorList); }
public void testError_BodyTooLong() { GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_BodyTooLong.patch"); Assert.AreEqual(1, p.getFiles().Count); Assert.AreEqual(1, p.getErrors().Count); FormatError e = p.getErrors()[0]; Assert.AreEqual(FormatError.Severity.WARNING, e.getSeverity()); Assert.AreEqual("Hunk header 4:11 does not match body line count of 4:12", e.getMessage()); Assert.AreEqual(349, e.getOffset()); Assert.IsTrue(e.getLineText().StartsWith("@@ -109,4 +109,11 @@ assert")); }
public void testError_TruncatedNew() { GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_TruncatedNew.patch"); Assert.AreEqual(1, p.getFiles().Count); Assert.AreEqual(1, p.getErrors().Count); FormatError e = p.getErrors()[0]; Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity()); Assert.AreEqual("Truncated hunk, at least 1 new lines is missing", e.getMessage()); Assert.AreEqual(313, e.getOffset()); Assert.IsTrue(e.getLineText().StartsWith("@@ -236,9 +236,9 @@ protected ")); }
public void FixedStringNAppendFloat(float input, FormatError expectedResult) { var localizedDecimalSeparator = Convert.ToChar(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator); var expectedOutput = "foo" + input.ToString(); FixedStringN aa = "foo"; var result = aa.Append(input, localizedDecimalSeparator); Assert.AreEqual(expectedResult, result); if (result == FormatError.None) { var actualOutput = aa.ToString(); Assert.AreEqual(expectedOutput, actualOutput); } }
public void NativeString64FormatFloat(float input, FormatError expectedResult) { var localizedDecimalSeparator = Convert.ToChar(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator); var expectedOutput = input.ToString(); NativeString64 aa = new NativeString64(); var result = aa.Format(input, localizedDecimalSeparator); Assert.AreEqual(expectedResult, result); if (result == FormatError.None) { var actualOutput = aa.ToString(); Assert.AreEqual(expectedOutput, actualOutput); } }
/// <summary> /// Generates a new token from an existing one and a new block /// </summary> /// <param name="rng">random number generator</param> /// <param name="keypair">ephemeral key pair</param> /// <param name="block">new block(should be generated from a Block builder)</param> /// <returns></returns> public Either <Error, Biscuit> Attenuate(RNGCryptoServiceProvider rng, KeyPair keypair, Block block) { Either <Error, Biscuit> e = this.Copy(); if (e.IsLeft) { return(e.Left); } Biscuit copiedBiscuit = e.Right; if (!Collections.Disjoint(copiedBiscuit.Symbols.Symbols, block.Symbols.Symbols)) { return(new SymbolTableOverlap()); } if (block.Index != 1 + this.Blocks.Count) { return(new InvalidBlockIndex(1 + copiedBiscuit.Blocks.Count, block.Index)); } Either <FormatError, SerializedBiscuit> containerRes = copiedBiscuit.container.Get().Append(rng, keypair, block); if (containerRes.IsLeft) { FormatError error = containerRes.Left; return(new Left(error)); } SerializedBiscuit container = containerRes.Right; SymbolTable symbols = new SymbolTable(copiedBiscuit.Symbols); foreach (string s in block.Symbols.Symbols) { symbols.Add(s); } List <Block> blocks = new List <Block>(); foreach (Block b in copiedBiscuit.Blocks) { blocks.Add(b); } blocks.Add(block); List <RevocationIdentifier> revocation_ids = container.RevocationIdentifiers(); return(new Biscuit(copiedBiscuit.Authority, blocks, symbols, Option.Some(container), revocation_ids)); }
private void OnError(string error) { Operations?.Errors.Enqueue(error); OnCircuitError?.Invoke(error); // If we get an error, forcibly terminate anything else we're waiting for. These // tests should only encounter errors in specific situations, and this ensures that // we fail with a good message. var exception = FormatError?.Invoke(error) ?? new Exception(error); NextBatchReceived?.Completion?.TrySetException(exception); NextDotNetInteropCompletionReceived?.Completion.TrySetException(exception); NextJSInteropReceived?.Completion.TrySetException(exception); NextErrorReceived?.Completion?.TrySetResult(null); }
public void testError_DisconnectedHunk() { GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_DisconnectedHunk.patch"); Assert.AreEqual(1, p.getFiles().Count); Assert.AreEqual(1, p.getErrors().Count); FileHeader fh = p.getFiles()[0]; Assert.AreEqual("org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java", fh.NewName); Assert.AreEqual(1, fh.Hunks.Count); Assert.AreEqual(1, p.getErrors().Count); FormatError e = p.getErrors()[0]; Assert.AreEqual(FormatError.Severity.ERROR, e.getSeverity()); Assert.AreEqual("Hunk disconnected from file", e.getMessage()); Assert.AreEqual(18, e.getOffset()); Assert.IsTrue(e.getLineText().StartsWith("@@ -109,4 +109,11 @@ assert")); }
public void testError_GarbageBetweenFiles() { GitSharp.Core.Patch.Patch p = ParseTestPatchFile(PatchsDir + "testError_GarbageBetweenFiles.patch"); Assert.AreEqual(2, p.getFiles().Count); FileHeader fh0 = p.getFiles()[0]; Assert.AreEqual("org.spearce.jgit.test/tst/org/spearce/jgit/lib/RepositoryConfigTest.java", fh0.NewName); Assert.AreEqual(1, fh0.Hunks.Count); FileHeader fh1 = p.getFiles()[1]; Assert.AreEqual("org.spearce.jgit/src/org/spearce/jgit/lib/RepositoryConfig.java", fh1.NewName); Assert.AreEqual(1, fh1.Hunks.Count); Assert.AreEqual(1, p.getErrors().Count); FormatError e = p.getErrors()[0]; Assert.AreEqual(FormatError.Severity.WARNING, e.getSeverity()); Assert.AreEqual("Unexpected hunk trailer", e.getMessage()); Assert.AreEqual(926, e.getOffset()); Assert.AreEqual("I AM NOT HERE\n", e.getLineText()); }
protected void btnSalvar_Click(object sender, EventArgs e) { var Cliente = new Cliente(); try { if (txtId.Text != "") { Cliente.IDCliente = int.Parse(txtId.Text); Cliente.Get(); } Cliente.Nome = txtDescricao.Text; Cliente.IPServidor = txtIPServidor.Text; Cliente.DBName = txtDBName.Text; Cliente.DBUser = txtDBUser.Text; Cliente.DBPassword = txtDBPassword.Text; Cliente.Slug = txtSlug.Text; Cliente.Save(); GetCliente((int)Cliente.IDCliente); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Registro salvo.')</script>"); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
protected void DeleteCliente(int idCliente) { try { var Cliente = new Cliente(); Cliente.IDCliente = idCliente; Cliente.Delete(); GetClientes(); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
protected void DeleteTipoTelefone(int idTipoTelefone) { try { var TipoTelefone = new TipoTelefone(); TipoTelefone.IDTipoTelefone = idTipoTelefone; TipoTelefone.Delete(); GetTipoTelefones(); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
private void saveParceiros(PessoaJuridica pessoaJuridica) { var PessoaFisicaJuridicaDel = new PessoaFisicaJuridica(); try { PessoaFisicaJuridicaDel.IsTransaction = true; PessoaFisicaJuridicaDel.PessoaJuridica = pessoaJuridica; PessoaFisicaJuridicaDel.Delete(); foreach (ListItem item in listPessoasFisicasAdd.Items) { var pessoaFisicaAdd = new PessoaFisica(int.Parse(item.Value)); pessoaFisicaAdd.Get(); var PessoaFisicaJuridica = new PessoaFisicaJuridica(); PessoaFisicaJuridica.Transaction = PessoaFisicaJuridicaDel.Transaction; PessoaFisicaJuridica.PessoaJuridica = pessoaJuridica; PessoaFisicaJuridica.PessoaFisica = pessoaFisicaAdd; PessoaFisicaJuridica.Get(); PessoaFisicaJuridica.Save(); } PessoaFisicaJuridicaDel.Commit(); loadTab(); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); PessoaFisicaJuridicaDel.Rollback(); } }
protected void DeletePrograma(int idPrograma) { try { var Programa = new Programa(); Programa.IDPrograma = idPrograma; Programa.Delete(); GetProgramas(); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
protected void btnSalvar_Click(object sender, EventArgs e) { var Programa = new Programa(); try { if (txtId.Text != "") { Programa.IDPrograma = int.Parse(txtId.Text); Programa.Get(); } Programa.Descricao = txtDescricao.Text; Programa.IDCliente = int.Parse(ddlIDCliente.SelectedValue); Programa.Slug = txtSlug.Text; Programa.Save(); GetPrograma((int)Programa.IDPrograma); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Registro salvo.')</script>"); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
private void salvarPessoaFisica() { var usuario = new Usuario(); try { usuario.IDUsuario = int.Parse(txtId.Text); usuario.Get(); savePessoaFisica(usuario); GetUsuario((int)usuario.IDUsuario); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#aPessoaFisica').trigger(\"click\");alert('Dados pessoa fisica salva.');</script>"); } catch (Exception err) { GetUsuario((int)usuario.IDUsuario); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#aPessoaFisica').trigger(\"click\");alert('" + FormatError.FormatMessageForJAlert(err.Message) + "');</script>"); } }
protected void btnSalvarCredencial_Click(object sender, EventArgs e) { var usuario = new Usuario(); try { if (txtId.Text != "") { usuario.IDUsuario = int.Parse(txtId.Text); usuario.Get(); } usuario.Nome = txtNomeCompleto.Text; usuario.Login = txtLogin.Text; if (!string.IsNullOrEmpty(txtSenha.Text)) { usuario.Senha = txtSenha.Text; } usuario.Email = txtEmail.Text; usuario.Ramal = txtRamal.Text; usuario.Ativo = bool.Parse(rdoAtivo.SelectedValue); usuario.Save(); GetUsuario((int)usuario.IDUsuario); var fisica = usuario.Pessoa.Fisica; if (fisica == null || fisica.IDPessoaFisica == null) { salvarPessoaFisica(); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#aCredencial').trigger(\"click\");alert('Credencial salva.');</script>"); } } catch (Exception err) { GetUsuario((int)usuario.IDUsuario); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#aCredencial').trigger(\"click\");alert('" + FormatError.FormatMessageForJAlert(err.Message) + "');</script>"); } }
protected void btnSalvarTabelaDinamica_Click(object sender, EventArgs e) { var usuario = new Usuario(); try { usuario.IDUsuario = int.Parse(txtId.Text); usuario.Get(); wcTabelaDinamica.SaveTabelaDinamica(usuario.Pessoa); GetUsuario((int)usuario.IDUsuario); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#aDadosAdicionais').trigger(\"click\");alert('Dados adicionais salvo.');</script>"); } catch (Exception err) { GetUsuario((int)usuario.IDUsuario); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>$('#aDadosAdicionais').trigger(\"click\");alert('" + FormatError.FormatMessageForJAlert(err.Message) + "');</script>"); } }
protected void btnSalvar_Click(object sender, EventArgs e) { var Documento = new Documento(); try { if (txtId.Text != "") { Documento.IDDocumento = int.Parse(txtId.Text); Documento.Get(); } Documento.IDPessoa = int.Parse(txtIDPessoa.Text); Documento.IDTipoDocumento = int.Parse(ddlIDTipoDocumento.SelectedValue); Documento.DescDocumento = txtDescDocumento.Text; Documento.DocNumero = txtDocNumero.Text; Documento.DocComplemento = txtDocComplemento.Text; Documento.DocDV = txtDocDV.Text; Documento.Save(); GetDocumento((int)Documento.IDDocumento); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Registro salvo.')</script>"); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
protected void btnSalvar_Click(object sender, EventArgs e) { var Pais = new Pais(); try { if (txtId.Text != "") { Pais.IDPais = int.Parse(txtId.Text); Pais.Get(); } Pais.Nome = txtNome.Text; Pais.Save(); GetPais((int)Pais.IDPais); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Registro salvo.')</script>"); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
protected void btnSalvar_Click(object sender, EventArgs e) { var Cargo = new Cargo(); try { if (txtId.Text != "") { Cargo.IDCargo = int.Parse(txtId.Text); Cargo.Get(); } Cargo.Descricao = txtNome.Text; Cargo.ColunaEstrutura = ddlColunaEstrutura.SelectedValue; Cargo.IDCargoPai = int.Parse(ddlCargoPai.SelectedValue); Cargo.Ordem = int.Parse(txtOrdem.Text); Cargo.Save(); GetCargo((int)Cargo.IDCargo); Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('Registro salvo.')</script>"); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
protected void DeleteCargo(int idCargo) { try { var Cargo = new Cargo(); Cargo.IDCargo = idCargo; Cargo.Delete(); GetCargos(); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
protected void DeletePais(int idPais) { try { var Pais = new Pais(); Pais.IDPais = idPais; Pais.Delete(); GetPaiss(); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }
protected void DeleteDocumento(int idDocumento) { try { var Documento = new Documento(); Documento.IDDocumento = idDocumento; Documento.Delete(); GetDocumentos(); } catch (Exception err) { Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('" + FormatError.FormatMessageForJAlert(err.Message) + "')</script>"); } }